common: unify _require_batched_discard
authorDushan Tcholich <dusanc@gmail.com>
Mon, 15 Dec 2014 23:53:57 +0000 (10:53 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 15 Dec 2014 23:53:57 +0000 (10:53 +1100)
To check for FITRIM tests used  _require_fstrim() and
_test_batched_discard() but as _test_batched_discard() already
includes _test_fstrim() unify FSTRIM check throughout xfstests with
_require_batched_discard().

Signed-off-by: Dushan Tcholich <dusanc@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
common/rc
tests/generic/038
tests/generic/251
tests/generic/251.out
tests/generic/260
tests/generic/288

index ec4440b33359f7b0cebcca98dd735a56505270b7..cddc8487dbd3fb40692fd4e44238e398cae4ee1b 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2347,14 +2347,14 @@ _require_fstrim()
        fi
 }
 
-_test_batched_discard()
+_require_batched_discard()
 {
        if [ $# -ne 1 ]; then
-               echo "Usage: _test_batched_discard mnt_point" 1>&2
+               echo "Usage: _require_batched_discard mnt_point" 1>&2
                exit 1
        fi
        _require_fstrim
-       $FSTRIM_PROG ${1} &>/dev/null
+       [$FSTRIM_PROG $1 > /dev/null 2>&1] || _notrun "FITRIM not supported on $1"
 }
 
 _require_dumpe2fs()
index 5db718c2f9047df3d428ae5a5938a7d6c1544047..2e55c1a937723d0272719a5f0f2a1a4dcb4c595a 100755 (executable)
@@ -69,7 +69,6 @@ _need_to_be_root
 _supported_fs generic
 _supported_os Linux
 _require_scratch
-_require_fstrim
 
 rm -f $seqres.full
 
@@ -123,6 +122,7 @@ create_files()
 _scratch_mkfs >>$seqres.full 2>&1
 _require_fs_space $SCRATCH_MNT $((10 * 1024 * 1024))
 _scratch_mount
+_require_batched_discard $SCRATCH_MNT
 
 for ((i = 0; i < $((4 * $LOAD_FACTOR)); i++)); do
        trim_loop &
index d88c48b9abbb35812a6da06cbc89bd1a4c1083ed..848ee747313ab7f7daa9355bcbc0a1c7bc2d91b4 100755 (executable)
@@ -43,9 +43,9 @@ mypid=$$
 _supported_fs generic
 _supported_os Linux
 _require_scratch
-_require_fstrim
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount
+_require_batched_discard $SCRATCH_MNT
 
 _cleanup()
 {
@@ -150,11 +150,6 @@ function run_process() {
 nproc=20
 content=$here
 
-# Check for FITRIM support
-echo -n "Checking FITRIM support: "
-_test_batched_discard $SCRATCH_MNT || _notrun "FITRIM not supported on $SCRATCH_DEV"
-echo "done."
-
 mkdir -p $tmp
 
 (
index 3017b5e2871e6ed077d880db540af4a4f73466dd..142eb251b69a3b98c5b9f547d2843ea58d8a2125 100644 (file)
@@ -1,3 +1,2 @@
 QA output created by 251
-Checking FITRIM support: done.
 Running the test: done.
index 23ea40fbbba1c4bc5960481f777b1c721e281197..312e6d206fb3136b58d2d9d67d427eebd8e2d8bd 100755 (executable)
@@ -40,13 +40,12 @@ mypid=$$
 _supported_fs generic
 _supported_os Linux
 _require_math
-_require_fstrim
 
 _require_scratch
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount
 
-_test_batched_discard $SCRATCH_MNT || _notrun "FITRIM not supported on $SCRATCH_DEV"
+_require_batched_discard $SCRATCH_MNT
 
 fssize=$($DF_PROG -k | grep "$SCRATCH_MNT" | grep "$SCRATCH_DEV"  | awk '{print $3}')
 
index 2bde8a273322af853e7fe4cc74bd2c3582b26ecb..0368828557e4372eacaf6d5b3b28177aa194e02d 100755 (executable)
@@ -36,12 +36,11 @@ trap "exit \$status" 0 1 2 3 15
 _supported_fs generic
 _supported_os Linux
 
-_require_fstrim
 _require_scratch
 
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount
-_test_batched_discard $SCRATCH_MNT || _notrun "FITRIM not supported on $SCRATCH_DEV"
+_require_batched_discard $SCRATCH_MNT
 
 echo "[+] Length is zero (should fail)"
 out=$("$FSTRIM_PROG" -v -o0 -l0 $SCRATCH_MNT 2>&1)