From: Filipe David Borba Manana Date: Thu, 13 Mar 2014 04:17:44 +0000 (+1100) Subject: btrfs: add function _require_fssum() X-Git-Tag: v2022.05.01~3225 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2dd0dbe3f8ce87ce78b30702261f7e8ecf2f8106;p=users%2Fhch%2Fxfstests-dev.git btrfs: add function _require_fssum() To avoid repeating detection of fssum presence in many btrfs tests, as suggested by Dave Chinner. Also exported the variable "here" from the main control script, to avoid repeating its declaration in every single testcase file. Also removed the declaration of "here" from btrfs test cases that require the fssum program only. Removing it from all other test cases will be a separate change. Signed-off-by: Filipe David Borba Manana Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/check b/check index 268417c25..b619f6db2 100755 --- a/check +++ b/check @@ -32,7 +32,7 @@ diff="diff -u" showme=false have_test_arg=false randomize=false -here=`pwd` +export here=`pwd` xfile="" # start the initialisation work now diff --git a/common/rc b/common/rc index f2c3c3a3e..449fbb42b 100644 --- a/common/rc +++ b/common/rc @@ -2158,6 +2158,12 @@ _require_cp_reflink() _notrun "This test requires a cp with --reflink support." } +_require_fssum() +{ + FSSUM_PROG=$here/src/fssum + [ -x $FSSUM_PROG ] || _notrun "fssum not built" +} + # Given 2 files, verify that they have the same mapping but different # inodes - i.e. an undisturbed reflink # Silent if so, make noise if not diff --git a/tests/btrfs/007 b/tests/btrfs/007 index 5df9ccba0..54306133d 100755 --- a/tests/btrfs/007 +++ b/tests/btrfs/007 @@ -31,7 +31,6 @@ seq=`basename $0` seqres=$RESULT_DIR/$seq echo "QA output created by $seq" -here=`pwd` tmp=`mktemp -d` status=1 @@ -52,11 +51,9 @@ _need_to_be_root _supported_fs btrfs _supported_os Linux _require_scratch +_require_fssum _require_seek_data_hole -FSSUM_PROG=$here/src/fssum -[ -x $FSSUM_PROG ] || _notrun "fssum not built" - rm -f $seqres.full workout() diff --git a/tests/btrfs/016 b/tests/btrfs/016 old mode 100644 new mode 100755 index 6faead107..d04c21ad3 --- a/tests/btrfs/016 +++ b/tests/btrfs/016 @@ -26,7 +26,6 @@ seq=`basename $0` seqres=$RESULT_DIR/$seq echo "QA output created by $seq" -here=`pwd` tmp=`mktemp -d` tmp_dir=send_temp_$seq @@ -51,9 +50,7 @@ trap "_cleanup ; exit \$status" 0 1 2 3 15 _supported_fs btrfs _supported_os Linux _require_scratch - -FSSUM_PROG=$here/src/fssum -[ -x $FSSUM_PROG ] || _notrun "fssum not built" +_require_fssum _scratch_mkfs > /dev/null 2>&1 diff --git a/tests/btrfs/030 b/tests/btrfs/030 index a9f5fb41b..a76a410c7 100755 --- a/tests/btrfs/030 +++ b/tests/btrfs/030 @@ -36,7 +36,6 @@ seq=`basename $0` seqres=$RESULT_DIR/$seq echo "QA output created by $seq" -here=`pwd` tmp=`mktemp -d` status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -54,11 +53,9 @@ _cleanup() _supported_fs btrfs _supported_os Linux _require_scratch +_require_fssum _need_to_be_root -FSSUM_PROG=$here/src/fssum -[ -x $FSSUM_PROG ] || _notrun "fssum not built" - rm -f $seqres.full _scratch_mkfs >/dev/null 2>&1 diff --git a/tests/btrfs/038 b/tests/btrfs/038 index 8893696b4..4941d3e74 100755 --- a/tests/btrfs/038 +++ b/tests/btrfs/038 @@ -32,7 +32,6 @@ seq=`basename $0` seqres=$RESULT_DIR/$seq echo "QA output created by $seq" -here=`pwd` tmp=`mktemp -d` status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -50,11 +49,9 @@ _cleanup() _supported_fs btrfs _supported_os Linux _require_scratch +_require_fssum _need_to_be_root -FSSUM_PROG=$here/src/fssum -[ -x $FSSUM_PROG ] || _notrun "fssum not built" - rm -f $seqres.full _scratch_mkfs >/dev/null 2>&1 diff --git a/tests/btrfs/039 b/tests/btrfs/039 index 41e09be50..758b23c70 100755 --- a/tests/btrfs/039 +++ b/tests/btrfs/039 @@ -35,7 +35,6 @@ seq=`basename $0` seqres=$RESULT_DIR/$seq echo "QA output created by $seq" -here=`pwd` tmp=`mktemp -d` status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -53,11 +52,9 @@ _cleanup() _supported_fs btrfs _supported_os Linux _require_scratch +_require_fssum _need_to_be_root -FSSUM_PROG=$here/src/fssum -[ -x $FSSUM_PROG ] || _notrun "fssum not built" - rm -f $seqres.full _scratch_mkfs >/dev/null 2>&1 diff --git a/tests/btrfs/040 b/tests/btrfs/040 index 77c4a846a..dfd495caf 100755 --- a/tests/btrfs/040 +++ b/tests/btrfs/040 @@ -35,7 +35,6 @@ seq=`basename $0` seqres=$RESULT_DIR/$seq echo "QA output created by $seq" -here=`pwd` tmp=`mktemp -d` status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -53,11 +52,9 @@ _cleanup() _supported_fs btrfs _supported_os Linux _require_scratch +_require_fssum _need_to_be_root -FSSUM_PROG=$here/src/fssum -[ -x $FSSUM_PROG ] || _notrun "fssum not built" - rm -f $seqres.full _scratch_mkfs >/dev/null 2>&1