From 76a65760b61c17644660247a6fba512009a981e6 Mon Sep 17 00:00:00 2001 From: Rachita Kothiyal Date: Sat, 13 Oct 2007 03:38:25 -0400 Subject: [PATCH] Adding more modified tests for ODF. chmod, creat-open, flock, fsync, lookup, mknod are now generic(ie, they can handle both ODF and non-ODF cases) --- run-tests | 2 +- scaffold | 28 ++++++++++++++++++--- t-chmod.sh | 33 +++++++++++++++++++------ t-creat-open.sh | 14 +++++++++-- t-create.sh | 18 +++++++------- t-flock.sh | 27 +++++++++++++++++--- t-fsync.sh | 13 +++++++++- t-lookup.sh | 45 ++++++++++++++++++++++++++++------ t-mknod.sh | 65 +++++++++++++++++++++++++++++++++++++++++++------ 9 files changed, 204 insertions(+), 41 deletions(-) diff --git a/run-tests b/run-tests index 924c224..074aad1 100755 --- a/run-tests +++ b/run-tests @@ -254,7 +254,7 @@ do # Export the type of file systems, as some tests need to know. # For example: jffs2, cramfs, and squashfs. - export FS0 FS1 FS2 FS3 ODF_FS DEV0 DEV1 DEV2 DEV3 ODF_DEV ODF_DIR SPECIAL_FS delay OUTPUT_COLOR POPULATE_ODF + export FS0 FS1 FS2 FS3 ODF_FS DEV0 DEV1 DEV2 DEV3 ODF_DEV ODF_DIR SPECIAL_FS delay OUTPUT_COLOR ODF POPULATE_ODF # run actual test and abort on error (test script tries to umount unionfs) runcmd bash $t diff --git a/scaffold b/scaffold index 3fd2eed..48c6392 100644 --- a/scaffold +++ b/scaffold @@ -40,7 +40,6 @@ function havechattr { } function create_hierarchy { - if [ "$POPULATE_ODF" -eq "0" ]; then havechattr $LOWER_DIR0 && chattr -R -i $LOWER_DIR0 havechattr $LOWER_DIR1 && chattr -R -i $LOWER_DIR1 @@ -59,7 +58,12 @@ function create_hierarchy { continue fi TYPE=`echo $LINE | cut -d' ' -f 1` - NAME=`echo $LINE | cut -d' ' -f 2` + if [ "$TYPE" = "w" ]; then + WH_LOC=`echo $LINE | cut -d' ' -f 2` + NAME=`echo $LINE | cut -d' ' -f 3` + else + NAME=`echo $LINE | cut -d' ' -f 2` + fi unset DIR FILE IMMUTABLE SOURCE SYMLINK WH @@ -124,8 +128,16 @@ function create_hierarchy { elif [ ! -z "$SYMLINK" ] ; then ln -s "linktext:$NAME" $NAME elif [ ! -z "$WH" ]; then - mkdir -p `dirname $NAME` || exit $? - ln $ODF_DIR/whiteout $NAME + if [ "$ODF" -eq "1" ]; then + mkdir -p `dirname $WH_LOC"/"$NAME` || exit $? + ln $ODF_DIR/whiteout $WH_LOC"/"$NAME + else + wh_abs_path=$WH_LOC"/"$NAME + wh_dir=`dirname $wh_abs_path` + wh_file=".wh."`basename $wh_abs_path` + wh_abs_path=$wh_dir""$wh_file + touch $wh_abs_path + fi else echo "What type am i: $TYPE" 1>&2 exit $? @@ -208,6 +220,14 @@ function setup_odf } +function fill_odf { +mkdir $ODF_DIR/ic +mkdir $ODF_DIR/ns +mkdir $ODF_DIR/reclaim +mkdir $ODF_DIR/sr +touch $ODF_DIR/whiteout +} + function mount_union { # support compressed ram/rom file systems diff --git a/t-chmod.sh b/t-chmod.sh index de7a7cb..40b9d12 100755 --- a/t-chmod.sh +++ b/t-chmod.sh @@ -59,10 +59,17 @@ function do_chmod { function test1 { # The read-write tests +if [ $ODF -eq 1 ]; then + POPULATE_ODF=0 +fi ( beforefiles ) | create_hierarchy - -mount_union "" $LOWER_DIR0 $LOWER_DIR1 - +if [ $ODF -eq 1 ]; then + setup_odf + mount_union "odf=$ODF_DIR" $LOWER_DIR0 $LOWER_DIR1 +else + mount_union "" $LOWER_DIR0 $LOWER_DIR1 +fi + do_chmod $MOUNTPOINT/a do_chmod $MOUNTPOINT/b do_chmod $MOUNTPOINT/c @@ -71,26 +78,38 @@ do_chmod $MOUNTPOINT/e do_chmod $MOUNTPOINT/f unmount_union - ( beforefiles ) | check_hierarchy $TOP_LOWER_DIR echo -n "[rw] " + +if [ $ODF -eq 1 ]; then + discard_odf +fi } function test2 { # The readonly tests +if [ $ODF -eq 1 ]; then + POPULATE_ODF=0 +fi ( beforefiles ) | create_hierarchy -mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro - +if [ $ODF -eq 1 ]; then + setup_odf + mount_union "odf=$ODF_DIR" $LOWER_DIR0 $LOWER_DIR1=ro +else + mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro +fi do_chmod $MOUNTPOINT/a do_chmod $MOUNTPOINT/b do_chmod $MOUNTPOINT/c do_chmod $MOUNTPOINT/d do_chmod $MOUNTPOINT/e do_chmod $MOUNTPOINT/f - unmount_union ( beforefiles ; afterfiles_ro ) | check_hierarchy $TOP_LOWER_DIR echo -n "[ro] " +if [ $ODF -eq 1 ]; then + discard_odf +fi } test1 diff --git a/t-creat-open.sh b/t-creat-open.sh index 614a9e3..43b1db2 100755 --- a/t-creat-open.sh +++ b/t-creat-open.sh @@ -20,13 +20,20 @@ d $LOWER_DIR0/b f $LOWER_DIR0/b/creat-open FILES } - +if [ $ODF -eq 1 ]; then + POPULATE_ODF=0 +fi ( files ) | create_hierarchy EXPECTED_SIZE=`ls -l progs/creat-open | awk '{print $5}'` cp progs/creat-open $LOWER_DIR0/b/ -mount_union "" $LOWER_DIR0/b +if [ $ODF -eq 1 ]; then + setup_odf + mount_union "odf=$ODF_DIR" $LOWER_DIR0/b +else + mount_union "" $LOWER_DIR0/b +fi RET=0 $MOUNTPOINT/creat-open || RET="$?" @@ -44,4 +51,7 @@ unmount_union ( afterfiles ) | check_hierarchy $LOWER_DIR0 +if [ $ODF -eq 1 ]; then + discard_odf +fi complete_test diff --git a/t-create.sh b/t-create.sh index 855d172..32552cd 100644 --- a/t-create.sh +++ b/t-create.sh @@ -61,8 +61,8 @@ FILES # initial set of ODF files function odf_beforefiles { cat </dev/null +else + mount_union "" $TOP_LOWER_DIR/b? +fi + +checktype $MOUNTPOINT/a 'f' +checktype $MOUNTPOINT/b 'd' +checktype $MOUNTPOINT/c '-' unmount_union -files | check_hierarchy $TOP_LOWER_DIR +if [ $ODF -eq 1 ]; then + files | check_hierarchy $TOP_LOWER_DIR + odf_afterfiles | check_hierarchy $ODF_DIR/ns + discard_odf +else + ( files ; beforefiles ) | check_hierarchy $TOP_LOWER_DIR +fi complete_test + diff --git a/t-mknod.sh b/t-mknod.sh index 40a6a56..11757d9 100755 --- a/t-mknod.sh +++ b/t-mknod.sh @@ -30,7 +30,7 @@ FILES # initial set of files function beforefiles { cat </dev/null +else + mount_union "" $LOWER_DIR0 $LOWER_DIR1 +fi mknod $MOUNTPOINT/a b 200 0 checktype "$MOUNTPOINT/a" 'b' @@ -79,12 +101,33 @@ checktype "$MOUNTPOINT/d1/d2/d3/d4/c" 'b' unmount_union -( directories ; afterfiles_rw ) | check_hierarchy $TOP_LOWER_DIR +if [ $ODF -eq 1 ]; then + ( directories ; afterfiles_odf_rw ) | check_hierarchy $TOP_LOWER_DIR +else + ( directories ; afterfiles_rw ) | check_hierarchy $TOP_LOWER_DIR +fi +if [ $ODF -eq 1 ]; then + discard_odf +fi + + + +if [ $ODF -eq 1 ]; then + POPULATE_ODF=0 + setup_odf + fill_odf + ./progs/make_sb 2 $LOWER_DIR0 6 $LOWER_DIR1 4 +fi ( directories ; beforefiles) | create_hierarchy -mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro +if [ $ODF -eq 1 ]; then + mount_union "odf=$ODF_DIR" + ls -lR $MOUNTPOINT >/dev/null +else + mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro +fi mknod $MOUNTPOINT/a b 200 0 checktype "$MOUNTPOINT/a" 'b' @@ -94,6 +137,14 @@ mknod $MOUNTPOINT/d1/d2/d3/d4/c b 200 0 checktype "$MOUNTPOINT/d1/d2/d3/d4/c" 'b' unmount_union -( directories ; afterfiles_ro ) | check_hierarchy $TOP_LOWER_DIR +if [ $ODF -eq 1 ]; then + ( directories ; afterfiles_odf_rw ) | check_hierarchy $TOP_LOWER_DIR +else + ( directories ; afterfiles_ro ) | check_hierarchy $TOP_LOWER_DIR +fi + +if [ $ODF -eq 1 ]; then + discard_odf +fi complete_test -- 2.43.0