check: wipe scratch devices between tests
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 16 Apr 2019 22:36:28 +0000 (15:36 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 21 Apr 2019 15:37:19 +0000 (23:37 +0800)
Wipe the scratch devices in between each test to ensure that tests are
formatting them and not making assumptions about previous contents.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
check
common/rc
common/xfs

diff --git a/check b/check
index 0f1417038c85f17ec7bddf86080d67bff356e65d..8677141b1d0f1a3e959e7b0fb933a1d21b490bed 100755 (executable)
--- a/check
+++ b/check
@@ -483,9 +483,8 @@ _check_filesystems()
        if [ -f ${RESULT_DIR}/require_scratch ]; then
                _check_scratch_fs || err=true
                rm -f ${RESULT_DIR}/require_scratch*
        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
        fi
+       _scratch_unmount 2> /dev/null
 }
 
 _expunge_test()
 }
 
 _expunge_test()
@@ -625,6 +624,8 @@ for section in $HOST_OPTIONS_SECTIONS; do
              echo "check: failed to mount \$SCRATCH_DEV using specified options"
              status=1
              exit
              echo "check: failed to mount \$SCRATCH_DEV using specified options"
              status=1
              exit
+         else
+             _scratch_unmount
          fi
        fi
 
          fi
        fi
 
@@ -737,6 +738,7 @@ for section in $HOST_OPTIONS_SECTIONS; do
                        # _check_dmesg depends on this log in dmesg
                        touch ${RESULT_DIR}/check_dmesg
                fi
                        # _check_dmesg depends on this log in dmesg
                        touch ${RESULT_DIR}/check_dmesg
                fi
+               _try_wipe_scratch_devs > /dev/null 2>&1
                if [ "$DUMP_OUTPUT" = true ]; then
                        ./$seq 2>&1 | tee $tmp.out
                        # Because $? would get tee's return code
                if [ "$DUMP_OUTPUT" = true ]; then
                        ./$seq 2>&1 | tee $tmp.out
                        # Because $? would get tee's return code
index 92ef9c7d0392dea927a48e416fbb85dac44d7836..8b503eb6340f05da6a4bdb5d5f0978d6e2056765 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3977,6 +3977,15 @@ _require_fibmap()
        rm -f $file
 }
 
        rm -f $file
 }
 
+_try_wipe_scratch_devs()
+{
+       test -x "$WIPEFS_PROG" || return 0
+
+       for dev in $SCRATCH_DEV_POOL $SCRATCH_DEV $SCRATCH_LOGDEV $SCRATCH_RTDEV; do
+               test -b $dev && $WIPEFS_PROG -a $dev
+       done
+}
+
 init_rc
 
 ################################################################################
 init_rc
 
 ################################################################################
index 24065813ca2afc0eb618e65c12d372358c95eaf9..af2b62ba920a8a069fe31abd58963800aae783f7 100644 (file)
@@ -295,6 +295,7 @@ _require_xfs_db_command()
        fi
        command=$1
 
        fi
        command=$1
 
+       _scratch_mkfs_xfs >/dev/null 2>&1
        _scratch_xfs_db -x -c "help" | grep $command > /dev/null || \
                _notrun "xfs_db $command support is missing"
 }
        _scratch_xfs_db -x -c "help" | grep $command > /dev/null || \
                _notrun "xfs_db $command support is missing"
 }