From: Karel Zak Date: Tue, 19 Oct 2010 09:44:30 +0000 (+0200) Subject: tests: add libmount utils.c tests X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f27feed36e589191622c444f7c19a2e4d6cbe51a;p=util-linux tests: add libmount utils.c tests Signed-off-by: Karel Zak --- diff --git a/tests/commands.sh.in b/tests/commands.sh.in index 94c34e77..d5e166bd 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 00000000..f033a501 --- /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 00000000..7746b285 --- /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 00000000..09cdb8d4 --- /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 00000000..2e8b89a2 --- /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 00000000..4736e080 --- /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 00000000..82622399 --- /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 00000000..82622399 --- /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 00000000..4736e080 --- /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 00000000..4736e080 --- /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 00000000..4736e080 --- /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 00000000..82622399 --- /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 00000000..4736e080 --- /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 00000000..47fb251c --- /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 00000000..c86cf0d8 --- /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 00000000..f21d31bd --- /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 00000000..f033a501 --- /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 1bc8d18c..11b707d0 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 3367fab5..2de86807 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 2f9f6c45..da76724b 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 00000000..e06c9b9c --- /dev/null +++ b/tests/ts/libmount/utils @@ -0,0 +1,77 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +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