summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2010-10-19 11:44:30 +0200
committerKarel Zak2011-01-03 12:28:45 +0100
commitf27feed36e589191622c444f7c19a2e4d6cbe51a (patch)
tree04185fb256adea13c65a4be3324f0f3fe8ae01d6
parenttests: add libmount tags tests (diff)
downloadkernel-qcow2-util-linux-f27feed36e589191622c444f7c19a2e4d6cbe51a.tar.gz
kernel-qcow2-util-linux-f27feed36e589191622c444f7c19a2e4d6cbe51a.tar.xz
kernel-qcow2-util-linux-f27feed36e589191622c444f7c19a2e4d6cbe51a.zip
tests: add libmount utils.c tests
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--tests/commands.sh.in5
-rw-r--r--tests/expected/libmount/utils-ends-with1
-rw-r--r--tests/expected/libmount/utils-fs-root1
-rw-r--r--tests/expected/libmount/utils-fs-root-subdir1
-rw-r--r--tests/expected/libmount/utils-fs-root-subdir21
-rw-r--r--tests/expected/libmount/utils-match-fstype1
-rw-r--r--tests/expected/libmount/utils-match-fstype-neg1
-rw-r--r--tests/expected/libmount/utils-match-fstype-neg21
-rw-r--r--tests/expected/libmount/utils-match-options1
-rw-r--r--tests/expected/libmount/utils-match-options-list1
-rw-r--r--tests/expected/libmount/utils-match-options-neg1
-rw-r--r--tests/expected/libmount/utils-match-options-neg-list1
-rw-r--r--tests/expected/libmount/utils-match-options-neg-list21
-rw-r--r--tests/expected/libmount/utils-mountpoint1
-rw-r--r--tests/expected/libmount/utils-mountpoint-root1
-rw-r--r--tests/expected/libmount/utils-mountpoint-subdir1
-rw-r--r--tests/expected/libmount/utils-starts-with1
-rwxr-xr-xtests/ts/libmount/optstr2
-rwxr-xr-xtests/ts/libmount/tabfiles2
-rwxr-xr-xtests/ts/libmount/tabfiles-tags3
-rwxr-xr-xtests/ts/libmount/utils77
21 files changed, 100 insertions, 5 deletions
diff --git a/tests/commands.sh.in b/tests/commands.sh.in
index 94c34e77e..d5e166bdf 100644
--- a/tests/commands.sh.in
+++ b/tests/commands.sh.in
@@ -16,8 +16,9 @@ TS_HELPER_STRTOSIZE="$top_builddir/lib/test_strtosize"
TS_HELPER_CPUSET="$top_builddir/lib/test_cpuset"
# libmount
-TS_HELPER_OPTSTR="$top_builddir/shlibs/mount/src/test_optstr"
-TS_HELPER_TABFILES="$top_builddir/shlibs/mount/src/test_tab"
+TS_HELPER_LIBMOUNT_OPTSTR="$top_builddir/shlibs/mount/src/test_optstr"
+TS_HELPER_LIBMOUNT_TAB="$top_builddir/shlibs/mount/src/test_tab"
+TS_HELPER_LIBMOUNT_UTILS="$top_builddir/shlibs/mount/src/test_utils"
# TODO: use partx
TS_HELPER_PARTITIONS="$top_builddir/shlibs/blkid/samples/partitions"
diff --git a/tests/expected/libmount/utils-ends-with b/tests/expected/libmount/utils-ends-with
new file mode 100644
index 000000000..f033a5010
--- /dev/null
+++ b/tests/expected/libmount/utils-ends-with
@@ -0,0 +1 @@
+YES
diff --git a/tests/expected/libmount/utils-fs-root b/tests/expected/libmount/utils-fs-root
new file mode 100644
index 000000000..7746b2850
--- /dev/null
+++ b/tests/expected/libmount/utils-fs-root
@@ -0,0 +1 @@
+/proc: /
diff --git a/tests/expected/libmount/utils-fs-root-subdir b/tests/expected/libmount/utils-fs-root-subdir
new file mode 100644
index 000000000..09cdb8d46
--- /dev/null
+++ b/tests/expected/libmount/utils-fs-root-subdir
@@ -0,0 +1 @@
+/proc/sys/kernel: /sys/kernel
diff --git a/tests/expected/libmount/utils-fs-root-subdir2 b/tests/expected/libmount/utils-fs-root-subdir2
new file mode 100644
index 000000000..2e8b89a2e
--- /dev/null
+++ b/tests/expected/libmount/utils-fs-root-subdir2
@@ -0,0 +1 @@
+/etc: /etc
diff --git a/tests/expected/libmount/utils-match-fstype b/tests/expected/libmount/utils-match-fstype
new file mode 100644
index 000000000..4736e0800
--- /dev/null
+++ b/tests/expected/libmount/utils-match-fstype
@@ -0,0 +1 @@
+MATCH
diff --git a/tests/expected/libmount/utils-match-fstype-neg b/tests/expected/libmount/utils-match-fstype-neg
new file mode 100644
index 000000000..82622399d
--- /dev/null
+++ b/tests/expected/libmount/utils-match-fstype-neg
@@ -0,0 +1 @@
+NOT-MATCH
diff --git a/tests/expected/libmount/utils-match-fstype-neg2 b/tests/expected/libmount/utils-match-fstype-neg2
new file mode 100644
index 000000000..82622399d
--- /dev/null
+++ b/tests/expected/libmount/utils-match-fstype-neg2
@@ -0,0 +1 @@
+NOT-MATCH
diff --git a/tests/expected/libmount/utils-match-options b/tests/expected/libmount/utils-match-options
new file mode 100644
index 000000000..4736e0800
--- /dev/null
+++ b/tests/expected/libmount/utils-match-options
@@ -0,0 +1 @@
+MATCH
diff --git a/tests/expected/libmount/utils-match-options-list b/tests/expected/libmount/utils-match-options-list
new file mode 100644
index 000000000..4736e0800
--- /dev/null
+++ b/tests/expected/libmount/utils-match-options-list
@@ -0,0 +1 @@
+MATCH
diff --git a/tests/expected/libmount/utils-match-options-neg b/tests/expected/libmount/utils-match-options-neg
new file mode 100644
index 000000000..4736e0800
--- /dev/null
+++ b/tests/expected/libmount/utils-match-options-neg
@@ -0,0 +1 @@
+MATCH
diff --git a/tests/expected/libmount/utils-match-options-neg-list b/tests/expected/libmount/utils-match-options-neg-list
new file mode 100644
index 000000000..82622399d
--- /dev/null
+++ b/tests/expected/libmount/utils-match-options-neg-list
@@ -0,0 +1 @@
+NOT-MATCH
diff --git a/tests/expected/libmount/utils-match-options-neg-list2 b/tests/expected/libmount/utils-match-options-neg-list2
new file mode 100644
index 000000000..4736e0800
--- /dev/null
+++ b/tests/expected/libmount/utils-match-options-neg-list2
@@ -0,0 +1 @@
+MATCH
diff --git a/tests/expected/libmount/utils-mountpoint b/tests/expected/libmount/utils-mountpoint
new file mode 100644
index 000000000..47fb251cd
--- /dev/null
+++ b/tests/expected/libmount/utils-mountpoint
@@ -0,0 +1 @@
+/proc: /proc
diff --git a/tests/expected/libmount/utils-mountpoint-root b/tests/expected/libmount/utils-mountpoint-root
new file mode 100644
index 000000000..c86cf0d8d
--- /dev/null
+++ b/tests/expected/libmount/utils-mountpoint-root
@@ -0,0 +1 @@
+/: /
diff --git a/tests/expected/libmount/utils-mountpoint-subdir b/tests/expected/libmount/utils-mountpoint-subdir
new file mode 100644
index 000000000..f21d31bd0
--- /dev/null
+++ b/tests/expected/libmount/utils-mountpoint-subdir
@@ -0,0 +1 @@
+/proc/sys/kernel: /proc
diff --git a/tests/expected/libmount/utils-starts-with b/tests/expected/libmount/utils-starts-with
new file mode 100644
index 000000000..f033a5010
--- /dev/null
+++ b/tests/expected/libmount/utils-starts-with
@@ -0,0 +1 @@
+YES
diff --git a/tests/ts/libmount/optstr b/tests/ts/libmount/optstr
index 1bc8d18c6..11b707d07 100755
--- a/tests/ts/libmount/optstr
+++ b/tests/ts/libmount/optstr
@@ -8,7 +8,7 @@ TS_DESC="options string"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-TESTPROG="$TS_HELPER_OPTSTR"
+TESTPROG="$TS_HELPER_LIBMOUNT_OPTSTR"
ts_init_subtest "append"
$TESTPROG --append "aaa,bbb=BBB,ccc" "ddd" &> $TS_OUTPUT
diff --git a/tests/ts/libmount/tabfiles b/tests/ts/libmount/tabfiles
index 3367fab5b..2de86807c 100755
--- a/tests/ts/libmount/tabfiles
+++ b/tests/ts/libmount/tabfiles
@@ -8,7 +8,7 @@ TS_DESC="tab files"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-TESTPROG="$TS_HELPER_TABFILES"
+TESTPROG="$TS_HELPER_LIBMOUNT_TAB"
ts_init_subtest "parse-fstab"
$TESTPROG --parse "$TS_SELF/files/fstab" &> $TS_OUTPUT
diff --git a/tests/ts/libmount/tabfiles-tags b/tests/ts/libmount/tabfiles-tags
index 2f9f6c45d..da76724bb 100755
--- a/tests/ts/libmount/tabfiles-tags
+++ b/tests/ts/libmount/tabfiles-tags
@@ -7,6 +7,8 @@ TS_DESC="tags"
ts_init "$*"
ts_skip_nonroot
+TESTPROG="$TS_HELPER_LIBMOUNT_TAB"
+
#
# Init device
#
@@ -32,7 +34,6 @@ UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9"
mkfs.ext3 -F -L $LABEL $DEVICE -U $UUID &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE
ts_device_has_uuid $DEVICE || ts_die "Cannot found UUID on $DEVICE" $DEVICE
-TESTPROG="$TS_HELPER_TABFILES"
FSTAB="$TS_OUTDIR/fstab"
#
diff --git a/tests/ts/libmount/utils b/tests/ts/libmount/utils
new file mode 100755
index 000000000..e06c9b9cd
--- /dev/null
+++ b/tests/ts/libmount/utils
@@ -0,0 +1,77 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="utils"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+TESTPROG="$TS_HELPER_LIBMOUNT_UTILS"
+
+ts_init_subtest "match-fstype"
+$TESTPROG --match-fstype ext3 "ext2,ext3,cifs" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "match-fstype-neg"
+$TESTPROG --match-fstype cifs "ext2,ext3,nocifs" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "match-fstype-neg2"
+$TESTPROG --match-fstype cifs "noext2,ext3,cifs" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "match-options"
+$TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "ccc" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "match-options-list"
+$TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "ccc,aaa,ddd" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "match-options-neg"
+$TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "noxxx" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "match-options-neg-list"
+$TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "ddd,noaaa" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "match-options-neg-list2"
+$TESTPROG --match-options "aaa,bbb=BBB,ccc,ddd" "noxxx,ccc,aaa" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "starts-with"
+$TESTPROG --starts-with "AAAbbbCCC" "AAA" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "ends-with"
+$TESTPROG --ends-with "AAAbbbCCC" "CCC" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "mountpoint"
+$TESTPROG --mountpoint /proc &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "mountpoint-subdir"
+$TESTPROG --mountpoint /proc/sys/kernel &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "mountpoint-root"
+$TESTPROG --mountpoint / &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "fs-root"
+$TESTPROG --fs-root /proc &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "fs-root-subdir"
+$TESTPROG --fs-root /proc/sys/kernel &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "fs-root-subdir2"
+$TESTPROG --fs-root /etc &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_finalize