btrfs-progs: fsck tests: move code to a function
authorDavid Sterba <dsterba@suse.com>
Fri, 10 Jul 2015 22:31:02 +0000 (00:31 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 31 Aug 2015 17:25:09 +0000 (19:25 +0200)
Signed-off-by: David Sterba <dsterba@suse.com>
tests/fsck-tests.sh

index b0ded6ae8c0caab33d1182a41213dab1bc959a54..7e90f25ed521634caa7ea06fcf689a15bab51571 100755 (executable)
@@ -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