From fcc3303d729b270cb459e7b88bf1ef6e857c8663 Mon Sep 17 00:00:00 2001 From: Erez_Zadok Date: Wed, 1 Aug 2007 10:24:49 -0400 Subject: [PATCH] Rewrite truncate-all test more cleanly. --- t-truncate-all.sh | 109 ++++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 51 deletions(-) mode change 100644 => 100755 t-truncate-all.sh diff --git a/t-truncate-all.sh b/t-truncate-all.sh old mode 100644 new mode 100755 index e4b0bcf..ff24a51 --- a/t-truncate-all.sh +++ b/t-truncate-all.sh @@ -36,91 +36,98 @@ d $LOWER_DIR3 FILES } +# read-only test +function rw_test { + (directories) | create_hierarchy -(directories) | create_hierarchy + dd if=/dev/zero of=$LOWER_DIR0/a bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR0/b bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR0/c bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR0/a bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR0/b bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR0/c bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR0/d bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR1/d bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR2/d bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR0/d bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR1/d bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR2/d bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR2/d1/d2/d3/d4/e bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR2/d1/d2/d3/d4/e bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR2/d1/d2/d3/d4/f bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR2/d1/d2/d3/d4/f bs=4000 count=2 2>/dev/null + # mount unionfs + mount_union "" $LOWER_DIR0 $LOWER_DIR1 $LOWER_DIR2 -# mount unionfs -mount_union "" $LOWER_DIR0 $LOWER_DIR1 $LOWER_DIR2 - -# check for chattr support after mount_union, because it may have changed -# the underlying mounts to cramfs/squashfs. -CHATTR="" -if havechattr $LOWER_DIR2 ; then + # check for chattr support after mount_union, because it may have + # changed the underlying mounts to cramfs/squashfs. + CHATTR="" + if havechattr $LOWER_DIR2 ; then CHATTR=1 chattr +i $LOWER_DIR2/d1/d2/d3/d4/f -fi + fi -./progs/truncate -f $MOUNTPOINT/a 0 || exit $? + ./progs/truncate -f $MOUNTPOINT/a 0 || exit $? -./progs/truncate -f $MOUNTPOINT/b 5000 || exit $? + ./progs/truncate -f $MOUNTPOINT/b 5000 || exit $? -./progs/truncate -f $MOUNTPOINT/c 10000 || exit $? + ./progs/truncate -f $MOUNTPOINT/c 10000 || exit $? -./progs/truncate -f $MOUNTPOINT/d 10000 || exit $? + ./progs/truncate -f $MOUNTPOINT/d 10000 || exit $? -./progs/truncate -f $MOUNTPOINT/d1/d2/d3/d4/e 10000 || exit $? + ./progs/truncate -f $MOUNTPOINT/d1/d2/d3/d4/e 10000 || exit $? -if [ ! -z "$CHATTR" ] ; then + if [ ! -z "$CHATTR" ] ; then shouldfail ./truncate -f $MOUNTPOINT/d1/d2/d3/d4/f 10000 -fi - -unmount_union - + fi + unmount_union + echo -n "[rw] " +} -#### do same tests with mix of ro branches +# read-only tests +function ro_test { -(directories) | create_hierarchy + (directories) | create_hierarchy -dd if=/dev/zero of=$LOWER_DIR0/a bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR0/b bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR0/c bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR0/a bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR0/b bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR0/c bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR0/d bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR1/d bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR2/d bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR0/d bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR1/d bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR2/d bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR2/d1/d2/d3/d4/e bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR2/d1/d2/d3/d4/e bs=4000 count=2 2>/dev/null -dd if=/dev/zero of=$LOWER_DIR2/d1/d2/d3/d4/f bs=4000 count=2 2>/dev/null + dd if=/dev/zero of=$LOWER_DIR2/d1/d2/d3/d4/f bs=4000 count=2 2>/dev/null + mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro $LOWER_DIR2=ro -mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro $LOWER_DIR2=ro + # recheck for chattr support after mount_union, because it may have + # changed the underlying mounts to cramfs/squashfs. -# recheck for chattr support after mount_union, because it may have changed -# the underlying mounts to cramfs/squashfs. -CHATTR="" -if havechattr $LOWER_DIR2 ; then + CHATTR="" + if havechattr $LOWER_DIR2 ; then CHATTR=1 chattr +i $LOWER_DIR2/d1/d2/d3/d4/f -fi + fi -./progs/truncate -f $MOUNTPOINT/a 0 || exit $? + ./progs/truncate -f $MOUNTPOINT/a 0 || exit $? -./progs/truncate -f $MOUNTPOINT/b 5000 || exit $? + ./progs/truncate -f $MOUNTPOINT/b 5000 || exit $? -./progs/truncate -f $MOUNTPOINT/c 10000 || exit $? + ./progs/truncate -f $MOUNTPOINT/c 10000 || exit $? -./progs/truncate -f $MOUNTPOINT/d 10000 || exit $? + ./progs/truncate -f $MOUNTPOINT/d 10000 || exit $? -./progs/truncate -f $MOUNTPOINT/d1/d2/d3/d4/e 10000 || exit $? + ./progs/truncate -f $MOUNTPOINT/d1/d2/d3/d4/e 10000 || exit $? -if [ ! -z "$CHATTR" ] ; then + if [ ! -z "$CHATTR" ] ; then shouldfail ./progs/truncate -f $MOUNTPOINT/d1/d2/d3/d4/f 10000 -fi + fi + + unmount_union + echo -n "[ro] " +} -unmount_union +rw_test +ro_test complete_test -- 2.43.0