From f27feed36e589191622c444f7c19a2e4d6cbe51a Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 19 Oct 2010 11:44:30 +0200 Subject: [PATCH] tests: add libmount utils.c tests Signed-off-by: Karel Zak --- tests/commands.sh.in | 5 +- tests/expected/libmount/utils-ends-with | 1 + tests/expected/libmount/utils-fs-root | 1 + tests/expected/libmount/utils-fs-root-subdir | 1 + tests/expected/libmount/utils-fs-root-subdir2 | 1 + tests/expected/libmount/utils-match-fstype | 1 + .../expected/libmount/utils-match-fstype-neg | 1 + .../expected/libmount/utils-match-fstype-neg2 | 1 + tests/expected/libmount/utils-match-options | 1 + .../libmount/utils-match-options-list | 1 + .../expected/libmount/utils-match-options-neg | 1 + .../libmount/utils-match-options-neg-list | 1 + .../libmount/utils-match-options-neg-list2 | 1 + tests/expected/libmount/utils-mountpoint | 1 + tests/expected/libmount/utils-mountpoint-root | 1 + .../expected/libmount/utils-mountpoint-subdir | 1 + tests/expected/libmount/utils-starts-with | 1 + tests/ts/libmount/optstr | 2 +- tests/ts/libmount/tabfiles | 2 +- tests/ts/libmount/tabfiles-tags | 3 +- tests/ts/libmount/utils | 77 +++++++++++++++++++ 21 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 tests/expected/libmount/utils-ends-with create mode 100644 tests/expected/libmount/utils-fs-root create mode 100644 tests/expected/libmount/utils-fs-root-subdir create mode 100644 tests/expected/libmount/utils-fs-root-subdir2 create mode 100644 tests/expected/libmount/utils-match-fstype create mode 100644 tests/expected/libmount/utils-match-fstype-neg create mode 100644 tests/expected/libmount/utils-match-fstype-neg2 create mode 100644 tests/expected/libmount/utils-match-options create mode 100644 tests/expected/libmount/utils-match-options-list create mode 100644 tests/expected/libmount/utils-match-options-neg create mode 100644 tests/expected/libmount/utils-match-options-neg-list create mode 100644 tests/expected/libmount/utils-match-options-neg-list2 create mode 100644 tests/expected/libmount/utils-mountpoint create mode 100644 tests/expected/libmount/utils-mountpoint-root create mode 100644 tests/expected/libmount/utils-mountpoint-subdir create mode 100644 tests/expected/libmount/utils-starts-with create mode 100755 tests/ts/libmount/utils 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 -- 2.39.5