check: avoid spurious complaints that tests/$FSTYP/group does not exist
[xfstests-dev.git] / check
diff --git a/check b/check
index 8281322e01dd6c91168ed302857e468b5ef060db..2986d84d84b2ae0f6f4bdad68ce22dd3fa0ae7d3 100755 (executable)
--- a/check
+++ b/check
@@ -53,13 +53,6 @@ timestamp=${TIMESTAMP:=false}
 
 rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist
 
-# we need common/config
-if ! . ./common/config
-then
-    echo "$iam: failed to source common/config"
-    exit 1
-fi
-
 SRC_GROUPS="generic shared"
 export SRC_DIR="tests"
 
@@ -70,6 +63,7 @@ usage()
 check options
     -nfs                test NFS
     -cifs               test CIFS
+    -overlay           test overlay
     -tmpfs              test TMPFS
     -l                 line mode diff
     -udiff             show unified diff (default)
@@ -79,6 +73,7 @@ check options
     -d                 dump test output to stdout
     --large-fs         optimise scratch device for large filesystems
     -s section         run only specified section from config file
+    -S section         exclude the specified section from the config file
 
 testlist options
     -g group[,group...]        include tests from these groups
@@ -95,6 +90,9 @@ get_group_list()
        grp=$1
 
        for d in $SRC_GROUPS $FSTYP; do
+               if ! test -d "$SRC_DIR/$d" ; then
+                       continue
+               fi
                l=$(sed -n < $SRC_DIR/$d/group \
                        -e 's/#.*//' \
                        -e 's/$/ /' \
@@ -110,6 +108,9 @@ get_all_tests()
 {
        touch $tmp.list
        for d in $SRC_GROUPS $FSTYP; do
+               if ! test -d "$SRC_DIR/$d" ; then
+                       continue
+               fi
                ls $SRC_DIR/$d/* | \
                        grep -v "\..*" | \
                        grep "^$SRC_DIR/$d/$VALID_TEST_NAME"| \
@@ -207,9 +208,10 @@ while [ $# -gt 0 ]; do
        case "$1" in
        -\? | -h | --help) usage ;;
 
-       -nfs)   FSTYP=nfs ;;
-       -cifs)  FSTYP=cifs ;;
-       -tmpfs) FSTYP=tmpfs ;;
+       -nfs)           FSTYP=nfs ;;
+       -cifs)          FSTYP=cifs ;;
+       -overlay)       FSTYP=overlay ;;
+       -tmpfs)         FSTYP=tmpfs ;;
 
        -g)     group=$2 ; shift ;
                GROUP_LIST="$GROUP_LIST ${group//,/ }"
@@ -233,6 +235,7 @@ while [ $# -gt 0 ]; do
                fi
                ;;
        -s)     RUN_SECTION="$RUN_SECTION $2"; shift ;;
+       -S)     EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;;
        -l)     diff="diff" ;;
        -udiff) diff="$diff -u" ;;
 
@@ -260,6 +263,13 @@ while [ $# -gt 0 ]; do
        shift
 done
 
+# we need common/config, source it after processing args, overlay needs FSTYP
+# set before sourcing common/config
+if ! . ./common/config; then
+       echo "$iam: failed to source common/config"
+       exit 1
+fi
+
 # Process tests from command line now.
 if $have_test_arg; then
        while [ $# -gt 0 ]; do
@@ -419,6 +429,21 @@ for section in $HOST_OPTIONS_SECTIONS; do
                for s in $RUN_SECTION; do
                        if [ $section == $s ]; then
                                skip=false
+                               break;
+                       fi
+               done
+               if $skip; then
+                       continue
+               fi
+       fi
+
+       # Did this section get excluded?
+       if [ ! -z "$EXCLUDE_SECTION" ]; then
+               skip=false
+               for s in $EXCLUDE_SECTION; do
+                       if [ $section == $s ]; then
+                               skip=true
+                               break;
                        fi
                done
                if $skip; then
@@ -439,7 +464,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
 
        if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
                echo "RECREATING    -- $FSTYP on $TEST_DEV"
-               umount $TEST_DEV 2> /dev/null
+               _test_unmount 2> /dev/null
                if ! _test_mkfs >$tmp.err 2>&1
                then
                        echo "our local _test_mkfs routine ..."
@@ -456,7 +481,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
                fi
                _prepare_test_list
        elif [ "$OLD_MOUNT_OPTIONS" != "$MOUNT_OPTIONS" ]; then
-               umount $TEST_DEV 2> /dev/null
+               _test_unmount 2> /dev/null
                out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
                if [ $? -ne 1 ]; then
                        echo $out
@@ -486,7 +511,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
        needwrap=true
 
        if [ ! -z "$SCRATCH_DEV" ]; then
-         umount $SCRATCH_DEV 2>/dev/null
+         _scratch_unmount 2> /dev/null
          # call the overridden mkfs - make sure the FS is built
          # the same as we'll create it later.
 
@@ -679,8 +704,8 @@ for section in $HOST_OPTIONS_SECTIONS; do
        _wrapup
        echo
 
-       umount $TEST_DEV 2> /dev/null
-       umount $SCRATCH_DEV 2> /dev/null
+       _test_unmount 2> /dev/null
+       _scratch_unmount 2> /dev/null
 done
 
 interrupt=false