]> err.no Git - util-linux/commitdiff
tests: add mount -o remount test
authorKarel Zak <kzak@redhat.com>
Thu, 26 Apr 2007 20:25:13 +0000 (22:25 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 26 Apr 2007 20:25:13 +0000 (22:25 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/Makefile.am
tests/expected/ts-mount-remount [new file with mode: 0644]
tests/ts-mount-remount [new file with mode: 0755]

index d4d8a981bf408424b96e33a00b934fbf956ca7b9..e306bfe66d27760a0b9dc2349b04fb9b7bb28ea8 100644 (file)
@@ -21,7 +21,9 @@ EXTRA_DIST =  expected/* \
                ts-hwclock-systohc \
                ts-mount-special \
                ts-mount-mtablock \
-               ts-mount-move
+               ts-mount-move \
+               ts-mount-remount
+
 
 distclean-local:
        rm -rf output diff
diff --git a/tests/expected/ts-mount-remount b/tests/expected/ts-mount-remount
new file mode 100644 (file)
index 0000000..3582111
--- /dev/null
@@ -0,0 +1 @@
+Success
diff --git a/tests/ts-mount-remount b/tests/ts-mount-remount
new file mode 100755 (executable)
index 0000000..16e8458
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+#
+# test for mount -o remount,ro
+#
+
+. commands.sh
+. functions.sh
+
+TS_COMPONENT="mount"
+TS_DESC="remount"
+
+ts_init
+
+if [ $UID != 0 ]; then
+       ts_skip "not root permissions"
+fi
+
+# clean up
+test_cleanup() {
+       $TS_CMD_UMOUNT $MOUNTPOINT &> /dev/null
+       rmdir $MOUNTPOINT &> /dev/null
+       $TS_CMD_LOSETUP -d $DEVICE &> /dev/null
+       rm -f $IMAGE
+}
+
+touch $TS_OUTPUT
+
+PWD=$(pwd)
+
+# mountpoint
+MOUNTPOINT="$PWD/$TS_OUTDIR/mnt-remount"
+mkdir $MOUNTPOINT
+
+# initializa device
+IMAGE="$TS_OUTDIR/loop-remount.img"
+
+dd if=/dev/zero of=$IMAGE bs=1M count=20 &> /dev/null
+
+DEVICE=$( $TS_CMD_LOSETUP -f )
+$TS_CMD_LOSETUP $DEVICE $IMAGE 2>&1 >> $TS_OUTPUT
+mkfs.ext2 $DEVICE &> /dev/null
+
+# mount read-write
+$TS_CMD_MOUNT $DEVICE $MOUNTPOINT
+
+# check the mount
+egrep -q "^$DEVICE $MOUNTPOINT" /etc/mtab
+
+if [ "$?" != "0" ]; then
+        echo "Cannot found $MOUNTPOINT in /etc/mtab" >> $TS_OUTPUT
+       test_cleanup
+        ts_finalize
+fi
+
+# remount
+$TS_CMD_MOUNT -o remount,ro $MOUNTPOINT
+
+# check the remount
+egrep -q "^$DEVICE $MOUNTPOINT ext2 ro 0 0" /etc/mtab
+
+if [ "$?" != "0" ]; then
+        echo "Cannot found remounted $MOUNTPOINT in /etc/mtab" >> $TS_OUTPUT
+        test_cleanup
+       ts_finalize
+fi
+
+test_cleanup
+
+echo "Success" >> $TS_OUTPUT
+ts_finalize
+