xfs/331: don't run this test if fallocate isn't supported
[xfstests-dev.git] / check
diff --git a/check b/check
index ecd1d39ab0c8c759b51d7dc456d7143a65758506..5ffa8777110393b96bb57960acb461d2f4355bf8 100755 (executable)
--- a/check
+++ b/check
@@ -26,6 +26,7 @@ subdir_xfile=""
 brief_test_summary=false
 do_report=false
 DUMP_OUTPUT=false
+iterations=1
 
 # This is a global variable used to pass test failure text to reporting gunk
 _err_msg=""
@@ -52,19 +53,21 @@ usage()
     echo "Usage: $0 [options] [testlist]"'
 
 check options
-    -nfs                test NFS
-    -glusterfs                test GlusterFS
-    -cifs               test CIFS
+    -nfs               test NFS
+    -glusterfs         test GlusterFS
+    -cifs              test CIFS
     -9p                        test 9p
+    -virtiofs          test virtiofs
     -overlay           test overlay
-    -pvfs2          test PVFS2
-    -tmpfs              test TMPFS
-    -ubifs              test ubifs
+    -pvfs2             test PVFS2
+    -tmpfs             test TMPFS
+    -ubifs             test ubifs
     -l                 line mode diff
     -udiff             show unified diff (default)
     -n                 show me, do not run tests
     -T                 output timestamps
     -r                 randomize test order
+    -i <n>             iterate the test list <n> times
     -d                 dump test output to stdout
     -b                 brief test summary
     -R fmt[,fmt]       generate report in formats specified. Supported format: [xunit]
@@ -130,6 +133,7 @@ get_group_list()
        local grp=$1
        local grpl=""
        local sub=$(dirname $grp)
+       local fsgroup="$FSTYP"
 
        if [ -n "$sub" -a "$sub" != "." -a -d "$SRC_DIR/$sub" ]; then
                # group is given as <subdir>/<group> (e.g. xfs/quick)
@@ -138,7 +142,10 @@ get_group_list()
                return
        fi
 
-       for d in $SRC_GROUPS $FSTYP; do
+       if [ "$FSTYP" = ext2 -o "$FSTYP" = ext3 ]; then
+           fsgroup=ext4
+       fi
+       for d in $SRC_GROUPS $fsgroup; do
                if ! test -d "$SRC_DIR/$d" ; then
                        continue
                fi
@@ -243,7 +250,11 @@ _prepare_test_list()
 
        # sort the list of tests into numeric order
        if $randomize; then
-               sorter="awk -v seed=$RANDOM -f randomize.awk"
+               if type shuf >& /dev/null; then
+                       sorter="shuf"
+               else
+                       sorter="awk -v seed=$RANDOM -f randomize.awk"
+               fi
        else
                sorter="cat"
        fi
@@ -260,6 +271,7 @@ while [ $# -gt 0 ]; do
        -glusterfs)     FSTYP=glusterfs ;;
        -cifs)          FSTYP=cifs ;;
        -9p)            FSTYP=9p ;;
+       -virtiofs)      FSTYP=virtiofs ;;
        -overlay)       FSTYP=overlay; export OVERLAY=true ;;
        -pvfs2)         FSTYP=pvfs2 ;;
        -tmpfs)         FSTYP=tmpfs ;;
@@ -287,7 +299,7 @@ while [ $# -gt 0 ]; do
 
        -n)     showme=true ;;
         -r)    randomize=true ;;
-
+       -i)     iterations=$2; shift ;;
        -T)     timestamp=true ;;
        -d)     DUMP_OUTPUT=true ;;
        -b)     brief_test_summary=true;;
@@ -479,9 +491,8 @@ _check_filesystems()
        if [ -f ${RESULT_DIR}/require_scratch ]; then
                _check_scratch_fs || err=true
                rm -f ${RESULT_DIR}/require_scratch*
-       else
-               _scratch_unmount 2> /dev/null
        fi
+       _scratch_unmount 2> /dev/null
 }
 
 _expunge_test()
@@ -496,6 +507,17 @@ _expunge_test()
        return 0
 }
 
+# Make the check script unattractive to the OOM killer...
+OOM_SCORE_ADJ="/proc/self/oom_score_adj"
+test -w ${OOM_SCORE_ADJ} && echo -1000 > ${OOM_SCORE_ADJ}
+
+# ...and make the tests themselves somewhat more attractive to it, so that if
+# the system runs out of memory it'll be the test that gets killed and not the
+# test framework.
+_run_seq() {
+       bash -c "test -w ${OOM_SCORE_ADJ} && echo 250 > ${OOM_SCORE_ADJ}; exec ./$seq"
+}
+
 _detect_kmemleak
 _prepare_test_list
 
@@ -505,7 +527,10 @@ else
        trap "_wrapup; exit \$status" 0 1 2 3 15
 fi
 
-for section in $HOST_OPTIONS_SECTIONS; do
+function run_section()
+{
+       local section=$1
+
        OLD_FSTYP=$FSTYP
        OLD_TEST_FS_MOUNT_OPTS=$TEST_FS_MOUNT_OPTS
        get_next_config $section
@@ -520,7 +545,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
                        fi
                done
                if $skip; then
-                       continue
+                       return
                fi
        fi
 
@@ -534,7 +559,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
                        fi
                done
                if $skip; then
-                       continue
+                       return
                fi
        fi
 
@@ -621,6 +646,8 @@ for section in $HOST_OPTIONS_SECTIONS; do
              echo "check: failed to mount \$SCRATCH_DEV using specified options"
              status=1
              exit
+         else
+             _scratch_unmount
          fi
        fi
 
@@ -678,6 +705,8 @@ for section in $HOST_OPTIONS_SECTIONS; do
                seqres="$REPORT_DIR/$seqnum"
 
                mkdir -p $RESULT_DIR
+               rm -f ${RESULT_DIR}/require_scratch*
+               rm -f ${RESULT_DIR}/require_test*
                echo -n "$seqnum"
 
                if $showme; then
@@ -733,12 +762,18 @@ for section in $HOST_OPTIONS_SECTIONS; do
                        # _check_dmesg depends on this log in dmesg
                        touch ${RESULT_DIR}/check_dmesg
                fi
+               _try_wipe_scratch_devs > /dev/null 2>&1
+
+               # clear the WARN_ONCE state to allow a potential problem
+               # to be reported for each test
+               (echo 1 > $DEBUGFS_MNT/clear_warn_once) > /dev/null 2>&1
+
                if [ "$DUMP_OUTPUT" = true ]; then
-                       ./$seq 2>&1 | tee $tmp.out
+                       _run_seq 2>&1 | tee $tmp.out
                        # Because $? would get tee's return code
                        sts=${PIPESTATUS[0]}
                else
-                       ./$seq >$tmp.out 2>&1
+                       _run_seq >$tmp.out 2>&1
                        sts=$?
                fi
 
@@ -765,6 +800,8 @@ for section in $HOST_OPTIONS_SECTIONS; do
                        _dump_err_cont "[failed, exit status $sts]"
                        _test_unmount 2> /dev/null
                        _scratch_unmount 2> /dev/null
+                       rm -f ${RESULT_DIR}/require_test*
+                       rm -f ${RESULT_DIR}/require_scratch*
                        err=true
                else
                        # the test apparently passed, so check for corruption
@@ -833,6 +870,12 @@ for section in $HOST_OPTIONS_SECTIONS; do
 
        _test_unmount 2> /dev/null
        _scratch_unmount 2> /dev/null
+}
+
+for ((iters = 0; iters < $iterations; iters++)) do
+       for section in $HOST_OPTIONS_SECTIONS; do
+               run_section $section
+       done
 done
 
 interrupt=false