summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKarel Zak2007-04-26 22:25:13 +0200
committerKarel Zak2007-04-26 22:25:13 +0200
commit8d5807b942631fc9bd7894f7a254ed4fd54cb039 (patch)
treea09f6327c8d12576225ed502b0559c7f2464b297 /tests
parenttests: add mount --move test (diff)
downloadkernel-qcow2-util-linux-8d5807b942631fc9bd7894f7a254ed4fd54cb039.tar.gz
kernel-qcow2-util-linux-8d5807b942631fc9bd7894f7a254ed4fd54cb039.tar.xz
kernel-qcow2-util-linux-8d5807b942631fc9bd7894f7a254ed4fd54cb039.zip
tests: add mount -o remount test
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/expected/ts-mount-remount1
-rwxr-xr-xtests/ts-mount-remount72
3 files changed, 76 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d4d8a981b..e306bfe66 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 000000000..35821117c
--- /dev/null
+++ b/tests/expected/ts-mount-remount
@@ -0,0 +1 @@
+Success
diff --git a/tests/ts-mount-remount b/tests/ts-mount-remount
new file mode 100755
index 000000000..16e845824
--- /dev/null
+++ b/tests/ts-mount-remount
@@ -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
+