From 8d5807b942631fc9bd7894f7a254ed4fd54cb039 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 26 Apr 2007 22:25:13 +0200 Subject: [PATCH] tests: add mount -o remount test Signed-off-by: Karel Zak --- tests/Makefile.am | 4 +- tests/expected/ts-mount-remount | 1 + tests/ts-mount-remount | 72 +++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 tests/expected/ts-mount-remount create mode 100755 tests/ts-mount-remount diff --git a/tests/Makefile.am b/tests/Makefile.am index d4d8a981..e306bfe6 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 00000000..35821117 --- /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 00000000..16e84582 --- /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 + -- 2.39.5