summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2015-07-11 00:31:02 +0200
committerDavid Sterba <dsterba@suse.com>2015-08-31 19:25:09 +0200
commit9842d5769117eb46ad116b8e9fb65a5b8cf27856 (patch)
treeddbd6790f06cd2fd002211951f368869c32e45b6 /tests
parentc5fc1d78d70372c0ec96abbce875e031e3f0899d (diff)
btrfs-progs: fsck tests: move code to a function
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/fsck-tests.sh35
1 files changed, 21 insertions, 14 deletions
diff --git a/tests/fsck-tests.sh b/tests/fsck-tests.sh
index b0ded6ae..7e90f25e 100755
--- a/tests/fsck-tests.sh
+++ b/tests/fsck-tests.sh
@@ -31,6 +31,26 @@ check_prereq btrfs-corrupt-block
check_prereq btrfs-image
check_prereq btrfs
+run_one_test() {
+ local testname
+
+ testname="$1"
+ echo " [TEST] $(basename $testname)"
+ cd $testname
+ echo "=== Entering $testname" >> $RESULTS
+ if [ -x test.sh ]; then
+ # Type 2
+ ./test.sh
+ if [ $? -ne 0 ]; then
+ _fail "test failed for case $(basename $testname)"
+ fi
+ else
+ # Type 1
+ check_all_images `pwd`
+ fi
+ cd $TOP
+}
+
# Each dir contains one type of error for btrfsck test.
# Each dir must be one of the following 2 types:
# 1) Only btrfs-image dump
@@ -46,18 +66,5 @@ check_prereq btrfs
for i in $(find $TOP/tests/fsck-tests -maxdepth 1 -mindepth 1 -type d | sort)
do
- echo " [TEST] $(basename $i)"
- cd $i
- echo "=== Entering $i" >> $RESULTS
- if [ -x test.sh ]; then
- # Type 2
- ./test.sh
- if [ $? -ne 0 ]; then
- _fail "test failed for case $(basename $i)"
- fi
- else
- # Type 1
- check_all_images `pwd`
- fi
- cd $TOP
+ run_one_test "$i"
done