From: Karel Zak Date: Thu, 21 Oct 2010 07:00:50 +0000 (+0200) Subject: tests: add libmount mtab update test X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=418187ce9644bcb996ef160444f7d7dc72b5eee0;p=util-linux tests: add libmount mtab update test Signed-off-by: Karel Zak --- diff --git a/tests/commands.sh.in b/tests/commands.sh.in index bcb428d4..d39dcb98 100644 --- a/tests/commands.sh.in +++ b/tests/commands.sh.in @@ -20,6 +20,7 @@ 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" TS_HELPER_LIBMOUNT_LOCK="$top_builddir/shlibs/mount/src/test_lock" +TS_HELPER_LIBMOUNT_UPDATE="$top_builddir/shlibs/mount/src/test_tab_update" # TODO: use partx TS_HELPER_PARTITIONS="$top_builddir/shlibs/blkid/samples/partitions" diff --git a/tests/expected/libmount/optstr-remove-quoted b/tests/expected/libmount/optstr-remove-quoted new file mode 100644 index 00000000..92fc5e33 --- /dev/null +++ b/tests/expected/libmount/optstr-remove-quoted @@ -0,0 +1 @@ +result: >aaa,bbb=BBB,ccc< diff --git a/tests/expected/libmount/update-fstab-add b/tests/expected/libmount/update-fstab-add new file mode 100644 index 00000000..2b36d588 --- /dev/null +++ b/tests/expected/libmount/update-fstab-add @@ -0,0 +1,3 @@ +/dev/sda1 /mnt/foo ext3 rw,bbb,ccc,fff=FFF,ddd,noexec 1 2 +/dev/sda2 /mnt/bar auto defaults 1 2 +/dev/sda3 /mnt/bar auto rw,context="some,selinux,junk",noatime 1 2 diff --git a/tests/expected/libmount/update-mtab-mount b/tests/expected/libmount/update-mtab-mount new file mode 100644 index 00000000..6744e8c0 --- /dev/null +++ b/tests/expected/libmount/update-mtab-mount @@ -0,0 +1,4 @@ +/dev/sda1 /mnt/foo ext3 rw,bbb,ccc,fff=FFF,ddd,noexec 0 0 +/dev/sdb1 /mnt/bar ext3 gg=G,ffff=f,ro,noatime 0 0 +/dev/sda2 /mnt/bar ext3 rw,noatime 0 0 +/dev/sda1 /mnt/gogo ext3 rw,noatime,nosuid 0 0 diff --git a/tests/expected/libmount/update-mtab-move b/tests/expected/libmount/update-mtab-move new file mode 100644 index 00000000..6c6ec666 --- /dev/null +++ b/tests/expected/libmount/update-mtab-move @@ -0,0 +1,4 @@ +/dev/sda1 /mnt/newfoo ext3 rw,bbb,ccc,fff=FFF,ddd,noexec 0 0 +/dev/sdb1 /mnt/bar ext3 gg=G,ffff=f,ro,noatime 0 0 +/dev/sda2 /mnt/newbar ext3 rw,noatime 0 0 +/dev/sda1 /mnt/gogo ext3 rw,noatime,nosuid 0 0 diff --git a/tests/expected/libmount/update-mtab-remount b/tests/expected/libmount/update-mtab-remount new file mode 100644 index 00000000..ee7fb86f --- /dev/null +++ b/tests/expected/libmount/update-mtab-remount @@ -0,0 +1,4 @@ +/dev/sda1 /mnt/newfoo ext3 ro,noatime 0 0 +/dev/sdb1 /mnt/bar ext3 rw,atime,nosuid 0 0 +/dev/sda2 /mnt/newbar ext3 rw,noatime 0 0 +/dev/sda1 /mnt/gogo ext3 rw,noatime,nosuid 0 0 diff --git a/tests/expected/libmount/update-mtab-umount b/tests/expected/libmount/update-mtab-umount new file mode 100644 index 00000000..be025730 --- /dev/null +++ b/tests/expected/libmount/update-mtab-umount @@ -0,0 +1,2 @@ +/dev/sda1 /mnt/newfoo ext3 ro,noatime 0 0 +/dev/sda2 /mnt/newbar ext3 rw,noatime 0 0 diff --git a/tests/ts/libmount/update b/tests/ts/libmount/update new file mode 100755 index 00000000..c3d26e3e --- /dev/null +++ b/tests/ts/libmount/update @@ -0,0 +1,64 @@ +#!/bin/bash + +# Copyright (C) 2010 Karel Zak + +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="tab update" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +TESTPROG="$TS_HELPER_LIBMOUNT_UPDATE" + +# IMPORTANT notes: +# +# - the $TS_OUTPUT variable is between ts_init_subtest and ts_finalize_subtest +# redefined to subtest specific namespace -- it means that $TS_OUTPUT is a +# different file within a subtest. +# +# - all this test uses global $TS_OUTPUT.{mtab,mountinfo} + + +# +# Traditional /etc/mtab +# +export LIBMOUNT_MTAB=$TS_OUTPUT.mtab +export LIBMOUNT_FSTAB=$TS_OUTPUT.fstab + +> $LIBMOUNT_MTAB +> $LIBMOUNT_FSTAB + +ts_init_subtest "mtab-mount" +$TESTPROG --add /dev/sda1 /mnt/foo ext3 "rw,bbb,ccc,fff=FFF,ddd,noexec" +$TESTPROG --add /dev/sdb1 /mnt/bar ext3 "gg=G,ffff=f,ro,noatime" +$TESTPROG --add /dev/sda2 /mnt/bar ext3 "rw,noatime" +$TESTPROG --add /dev/sda1 /mnt/gogo ext3 "rw,noatime,nosuid" +cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside +ts_finalize_subtest # checks the mtab + +ts_init_subtest "mtab-move" +$TESTPROG --move /mnt/foo /mnt/newfoo +$TESTPROG --move /mnt/bar /mnt/newbar +cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside +ts_finalize_subtest # checks the mtab + +ts_init_subtest "mtab-remount" +$TESTPROG --remount /mnt/newfoo "ro,noatime" +$TESTPROG --remount /mnt/bar "rw,atime,nosuid" +cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside +ts_finalize_subtest # checks the mtab + +ts_init_subtest "mtab-umount" +$TESTPROG --remove /mnt/bar +$TESTPROG --remove /mnt/gogo +cp $LIBMOUNT_MTAB $TS_OUTPUT # save the mtab aside +ts_finalize_subtest # checks the mtab + +ts_init_subtest "fstab-add" +$TESTPROG --add-fstab /dev/sda1 /mnt/foo ext3 "rw,bbb,ccc,fff=FFF,ddd,noexec" 1 2 +$TESTPROG --add-fstab /dev/sda2 /mnt/bar auto "defaults" 1 2 +$TESTPROG --add-fstab /dev/sda3 /mnt/bar auto "rw,context=\"some,selinux,junk\",noatime" 1 2 +cp $LIBMOUNT_FSTAB $TS_OUTPUT # save the fstab aside +ts_finalize_subtest # checks the fstab + +ts_finalize