]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: make tests more portable due to mtab
authorKarel Zak <kzak@redhat.com>
Fri, 15 Apr 2016 12:10:23 +0000 (14:10 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 15 Apr 2016 12:10:23 +0000 (14:10 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/tab_parse.c
tests/functions.sh
tests/ts/libmount/context
tests/ts/libmount/context-py
tests/ts/libmount/update
tests/ts/mount/devname
tests/ts/mount/remount
tests/ts/mount/rlimit
tests/ts/mount/umount-alltargets

index 45276a057996edf535fd016f8d3c855c07d887db..044e15415ca33552f576090dadc81831b6e4b063 100644 (file)
@@ -1100,7 +1100,9 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
 
        if (!is_mountinfo(tb))
                return 0;
+#ifdef USE_LIBMOUNT_SUPPORT_MTAB
 read_utab:
+#endif
        DBG(TAB, ul_debugobj(tb, "mtab parse: #2 read utab"));
 
        if (mnt_table_get_nents(tb) == 0)
index fe7ce6d7b03a89a3db9a0cb9183e93ddf028ccf9..19e8a46b8b89137a0346f594dad2474cf419b154 100644 (file)
@@ -719,3 +719,13 @@ function ts_init_socket_to_file {
                ts_skip "socat socket stopped listening"
        fi
 }
+
+function ts_has_mtab_support {
+       grep -q '#define USE_LIBMOUNT_SUPPORT_MTAB' ${top_builddir}/config.h
+       if [ $? == 0 ]; then
+               echo "yes"
+       else
+               echo "no"
+       fi
+}
+
index 2566ccb5385a81c29e8ac160c572847348bb714c..bcb9534e8d90094860c981d7a1d533c3ebc5f666 100755 (executable)
@@ -36,8 +36,8 @@ ts_scsi_debug_init dev_size_mb=100
 DEVNAME=$(basename $TS_DEVICE)
 
 MOUNTINFO_ONLY=yes
-grep -q '#define USE_LIBMOUNT_SUPPORT_MTAB' ${top_builddir}/config.h
-if [ $? == 0 ]; then
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
        MOUNTINFO_ONLY=no
 fi
 
index 5188309be448c9cb653216f54933d4c2d2e4b8f8..66b2eec52a41b03d9954ea5c611a563aada3055a 100755 (executable)
@@ -38,8 +38,8 @@ ts_scsi_debug_init dev_size_mb=100
 DEVNAME=$(basename $TS_DEVICE)
 
 MOUNTINFO_ONLY=yes
-grep -q '#define USE_LIBMOUNT_SUPPORT_MTAB' ${top_builddir}/config.h
-if [ $? == 0 ]; then
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
        MOUNTINFO_ONLY=no
 fi
 
index 89279ba26226abe5519ea663465d9d6f7ee89ca1..1db16d99fe594ff94df6b58ca7ff95fa088d9617 100755 (executable)
@@ -21,41 +21,45 @@ TESTPROG="$TS_HELPER_LIBMOUNT_UPDATE"
 #
 #  - all this test uses global $TS_OUTPUT.{mtab,mountinfo}
 
-
-#
-# Traditional /etc/mtab
-#
 export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
 rm -f $LIBMOUNT_MTAB
 > $LIBMOUNT_MTAB
 
-ts_init_subtest "mtab-mount"
-ts_valgrind $TESTPROG --add /dev/sda1 /mnt/foo ext3 "rw,bbb,ccc,fff=FFF,ddd,noexec"
-ts_valgrind $TESTPROG --add /dev/sdb1 /mnt/bar ext3 "gg=G,ffff=f,ro,noatime"
-ts_valgrind $TESTPROG --add /dev/sda2 /mnt/bar ext3 "rw,noatime"
-ts_valgrind $TESTPROG --add /dev/sda1 /mnt/gogo ext3 "rw,noatime,nosuid"
-ts_valgrind $TESTPROG --add none /proc proc defaults
-cp $LIBMOUNT_MTAB $TS_OUTPUT   # save the mtab aside
-ts_finalize_subtest            # checks the mtab
-
-ts_init_subtest "mtab-move"
-ts_valgrind $TESTPROG --move /mnt/foo /mnt/newfoo
-ts_valgrind $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"
-ts_valgrind $TESTPROG --remount /mnt/newfoo "ro,noatime"
-ts_valgrind $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"
-ts_valgrind $TESTPROG --remove /mnt/bar
-ts_valgrind $TESTPROG --remove /mnt/gogo
-ts_valgrind $TESTPROG --remove /proc
-cp $LIBMOUNT_MTAB $TS_OUTPUT   # save the mtab aside
-ts_finalize_subtest            # checks the mtab
+#
+# Traditional /etc/mtab
+#
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+       
+       ts_init_subtest "mtab-mount"
+       ts_valgrind $TESTPROG --add /dev/sda1 /mnt/foo ext3 "rw,bbb,ccc,fff=FFF,ddd,noexec"
+       ts_valgrind $TESTPROG --add /dev/sdb1 /mnt/bar ext3 "gg=G,ffff=f,ro,noatime"
+       ts_valgrind $TESTPROG --add /dev/sda2 /mnt/bar ext3 "rw,noatime"
+       ts_valgrind $TESTPROG --add /dev/sda1 /mnt/gogo ext3 "rw,noatime,nosuid"
+       ts_valgrind $TESTPROG --add none /proc proc defaults
+       cp $LIBMOUNT_MTAB $TS_OUTPUT    # save the mtab aside
+       ts_finalize_subtest             # checks the mtab
+
+       ts_init_subtest "mtab-move"
+       ts_valgrind $TESTPROG --move /mnt/foo /mnt/newfoo
+       ts_valgrind $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"
+       ts_valgrind $TESTPROG --remount /mnt/newfoo "ro,noatime"
+       ts_valgrind $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"
+       ts_valgrind $TESTPROG --remove /mnt/bar
+       ts_valgrind $TESTPROG --remove /mnt/gogo
+       ts_valgrind $TESTPROG --remove /proc
+       cp $LIBMOUNT_MTAB $TS_OUTPUT    # save the mtab aside
+       ts_finalize_subtest             # checks the mtab
+fi
 
 #
 # utab
index caa79f7bbc790426062752a392cd562ffb183783..65a1ba21769150a2b39bbbce54b7e0b38e85bbc3 100755 (executable)
@@ -32,6 +32,12 @@ ts_check_prog "mkfs.ext3"
 ts_device_init
 DEVICE=$TS_LODEV
 
+MTAB_FILE="/proc/mounts"
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+       MTAB_FILE="/etc/mtab"
+fi
+
 mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE"
 
 ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 on $DEVICE"
@@ -42,13 +48,13 @@ $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1
 
 ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
 
-grep -q $DEVICE /etc/mtab ||
-       echo "mount failed: cannot find $DEVICE in mtab" >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $MTAB_FILE ||
+       echo "mount failed: cannot find $DEVICE in $MTAB_FILE" >> $TS_OUTPUT 2>&1
 
 $TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE"
 
-grep -q $DEVICE /etc/mtab &&
-       echo "umount failed: found $DEVICE in mtab" >> $TS_OUTPUT 2>&1
+grep -q $DEVICE $MTAB_FILE &&
+       echo "umount failed: found $DEVICE in $MTAB_FILE" >> $TS_OUTPUT 2>&1
 
 ts_log "Success"
 ts_finalize
index 71769275298707c44660dffe17fb02db48c906fc..38db9bf9f3068858e50cd90c363a85b32d19d2b2 100755 (executable)
@@ -34,14 +34,20 @@ ts_check_prog "mkfs.ext2"
 ts_device_init
 DEVICE=$TS_LODEV
 
+MTAB_FILE="/proc/mounts"
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+       MTAB_FILE="/etc/mtab"
+fi
+
 mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE"
 
 # mount read-write
 $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT || ts_die "Cannot mount $TS_MOUNTPOINT"
 
 # check the mount
-egrep -q "^$DEVICE $TS_MOUNTPOINT" /etc/mtab \
- || ts_die "Cannot find $TS_MOUNTPOINT in /etc/mtab"
+egrep -q "^$DEVICE $TS_MOUNTPOINT" $MTAB_FILE \
+ || ts_die "Cannot find $TS_MOUNTPOINT in $MTAB_FILE"
 
 # remount
 $TS_CMD_MOUNT -o remount,ro $TS_MOUNTPOINT \
index d6a64ec75f7a1168aac0c60bee7ef371888ff34e..9564d7046a0635dddb7e7eb1ab3e57470a8e15d7 100755 (executable)
@@ -37,6 +37,9 @@ ts_skip_nonroot
 ts_check_losetup
 ts_check_prog "mkfs.ext3"
 
+has_mtab=$( ts_has_mtab_support )
+[ "$has_mtab" == "yes" ] || ts_skip "mtab unsupported"
+
 [ -L /etc/mtab ] && ts_skip "mtab is symlink"
 [ "$(stat --format '%s' /etc/mtab)" -gt "1024" ] || ts_skip "mtab is too small"
 
index 59c7e039497403fb517a34aa3b272ba922706a22..53073023a660ba76b9d1899a74710dcfb4e29ae6 100755 (executable)
@@ -18,7 +18,10 @@ ts_check_prog "mkfs.ext2"
 $TS_CMD_UMOUNT --help | grep -q all-targets
 [ $? -eq 1 ] && ts_skip "all-targets unsupported"
 
-[ -L /etc/mtab ] || ts_skip "regular mtab"
+has_mtab=$( ts_has_mtab_support )
+if [ "$has_mtab" == "yes" ]; then
+       [ -L /etc/mtab ] || ts_skip "regular mtab"
+fi
 
 # set global variable TS_DEVICE
 ts_scsi_debug_init dev_size_mb=50