From 970532bbed95a47d4fbc993d535b09b32e29cd37 Mon Sep 17 00:00:00 2001 From: Rachita Kothiyal Date: Tue, 16 Oct 2007 23:24:16 -0400 Subject: [PATCH] Changes to make some tests generic(ODF and non-ODF cases) Modifed the following tests: 1) t-lookup 2) t-flock 3) t-fsync 4) t-creat-open --- scaffold | 40 ++++++++++++++++++++++------------------ t-creat-open.sh | 18 +++++------------- t-flock.sh | 31 ++++++++----------------------- t-fsync.sh | 17 ++++------------- t-lookup.sh | 11 +++-------- 5 files changed, 42 insertions(+), 75 deletions(-) mode change 100755 => 100644 t-creat-open.sh mode change 100755 => 100644 t-lookup.sh diff --git a/scaffold b/scaffold index 2f5479e..c736367 100644 --- a/scaffold +++ b/scaffold @@ -128,7 +128,7 @@ function create_hierarchy { 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 + wh_abs_path=$wh_dir"/"$wh_file touch $wh_abs_path fi else @@ -192,15 +192,15 @@ function uncramit { function check_hierarchy { grep -v '^$' > /tmp/expected-$$ + # Get a hint on which dirs we are expected to browse for i in 0 1 2 3; do - cat "/tmp/expected-$$" | grep "\/n\/lower\/b$i" >/dev/null - ret=$? - if [ $ret == 0 ]; then - browse_path="/n/lower/b$i "$browse_path - fi + ( grep -q "$TOP_LOWER_DIR/b$i" /tmp/expected-$$ ) && browse_path="$TOP_LOWER_DIR/b$i "$browse_path done - browse_path=$browse_path" $ODF_DIR/ns/" + if [ $ODF -eq 1 ]; then + browse_path=$browse_path" $ODF_DIR/ns/" + fi + for i in $browse_path; do ( if [ "$i" == $ODF_DIR/ns/ ]; then @@ -210,7 +210,7 @@ function check_hierarchy { find $i -type d -printf 'd %p\n' find $i -type f -not -name ".wh.*" -printf 'f %p\n' if [ $ODF -eq 0 ]; then - find $i -type f -name ".wh.*" | sed "s:$i:w $i :g" | sed "s:\.wh\.::g" + find $i -type f -name ".wh.*" | sed "s:$i/:w $i :g" | sed "s:\.wh\.::g" fi find $i -type b -printf 'b %p\n' find $i -type c -printf 'c %p\n' @@ -219,24 +219,28 @@ function check_hierarchy { done # Test cases expect this - echo "d $TOP_LOWER_DIR" >> /tmp/check-$$ + ( grep -q "$TOP_LOWER_DIR$" /tmp/expected-$$ ) && ( echo "d $TOP_LOWER_DIR" >> /tmp/check-$$ ) + sort /tmp/check-$$ > /tmp/check-$$-tmp mv /tmp/check-$$-tmp /tmp/check-$$ - while read line ; do - first=`echo $line | cut -d" " -f 1` - if [ "$first" == "w" ]; then - echo $line | sed "s: [a-zA-Z0-9\/\_\-]* : $ODF_DIR/ns/ :g" >> /tmp/expected-$$-tmp - else - echo $line >> /tmp/expected-$$-tmp - fi - done < /tmp/expected-$$ + if [ $ODF -eq 1 ]; then + while read line ; do + first=`echo $line | cut -d" " -f 1` + if [ "$first" == "w" ]; then + echo $line | sed "s: [a-zA-Z0-9\/\_\-]* : $ODF_DIR/ns/ :g" >> /tmp/expected-$$-tmp + else + echo $line >> /tmp/expected-$$-tmp + fi + done < /tmp/expected-$$ + else + cp /tmp/expected-$$ /tmp/expected-$$-tmp + fi sort /tmp/expected-$$-tmp > /tmp/expected-$$ rm /tmp/expected-$$-tmp diff -u /tmp/expected-$$ /tmp/check-$$ - ERR=$? rm -f /tmp/check-$$ rm -f /tmp/expected-$$ diff --git a/t-creat-open.sh b/t-creat-open.sh old mode 100755 new mode 100644 index 43b1db2..4260794 --- a/t-creat-open.sh +++ b/t-creat-open.sh @@ -20,20 +20,14 @@ d $LOWER_DIR0/b f $LOWER_DIR0/b/creat-open FILES } -if [ $ODF -eq 1 ]; then - POPULATE_ODF=0 -fi + +init_odf ( files ) | create_hierarchy EXPECTED_SIZE=`ls -l progs/creat-open | awk '{print $5}'` cp progs/creat-open $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 +mount_union "" $LOWER_DIR0/b RET=0 $MOUNTPOINT/creat-open || RET="$?" @@ -49,9 +43,7 @@ fi unmount_union -( afterfiles ) | check_hierarchy $LOWER_DIR0 +( afterfiles ) | check_hierarchy -if [ $ODF -eq 1 ]; then - discard_odf -fi +discard_odf complete_test diff --git a/t-flock.sh b/t-flock.sh index 7a62d68..5fd9676 100755 --- a/t-flock.sh +++ b/t-flock.sh @@ -37,38 +37,23 @@ FILES } -if [ $ODF -eq 1 ]; then - POPULATE_ODF=0 -fi +init_odf ( files ) | create_hierarchy -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 +mount_union "" $LOWER_DIR0 $LOWER_DIR1=ro ./progs/flock-copyup $MOUNTPOINT/a || exit $? unmount_union -( afterfiles_ro ) | check_hierarchy $TOP_LOWER_DIR +( afterfiles_ro ) | check_hierarchy -if [ $ODF -eq 1 ]; then - discard_odf -fi +discard_odf ( files ) | create_hierarchy -if [ $ODF -eq 1 ]; then - setup_odf - mount_union "odf=$ODF_DIR" $LOWER_DIR0 $LOWER_DIR1 -else - mount_union "" $LOWER_DIR0 $LOWER_DIR1 -fi +init_odf +mount_union "" $LOWER_DIR0 $LOWER_DIR1 ./progs/flock-copyup $MOUNTPOINT/a || exit $? unmount_union -( afterfiles_rw ) | check_hierarchy $TOP_LOWER_DIR +( afterfiles_rw ) | check_hierarchy -if [ $ODF -eq 1 ]; then - discard_odf -fi +discard_odf complete_test diff --git a/t-fsync.sh b/t-fsync.sh index 2c4af0b..395d9ef 100755 --- a/t-fsync.sh +++ b/t-fsync.sh @@ -16,22 +16,13 @@ FILES } function rw { - if [ $ODF -eq 1 ]; then - POPULATE_ODF=0 - fi + init_odf ( files ) | create_hierarchy - if [ $ODF -eq 1 ]; then - setup_odf - mount_union "odf=$ODF_DIR" $LOWER_DIR0 $LOWER_DIR1 - else - mount_union "" $LOWER_DIR0 $LOWER_DIR1 - fi + mount_union "" $LOWER_DIR0 $LOWER_DIR1 ./progs/fsync $MOUNTPOINT/a || exit $? unmount_union - ( files ) | check_hierarchy $TOP_LOWER_DIR - if [ $ODF -eq 1 ]; then - discard_odf - fi + ( files ) | check_hierarchy + discard_odf } if [ -z "$FXNS" ] ; then diff --git a/t-lookup.sh b/t-lookup.sh old mode 100755 new mode 100644 index 1b64bdf..76ed85a --- a/t-lookup.sh +++ b/t-lookup.sh @@ -23,19 +23,14 @@ d $LOWER_DIR0/b f $LOWER_DIR1/b d $LOWER_DIR2/b +w $LOWER_DIR1 c d $LOWER_DIR2/c f $LOWER_DIR2/c/d FILES } -function beforefiles { -cat <