btrfs-progs: typo review of strings and comments
[platform/upstream/btrfs-progs.git] / tests / fsck-tests.sh
1 #!/bin/bash
2 #
3 # loop through all of our bad images and make sure fsck repairs them properly
4 #
5 # It's GPL, same as everything else in this tree.
6 #
7
8 unset TOP
9 unset LANG
10 LANG=C
11 SCRIPT_DIR=$(dirname $(readlink -f $0))
12 TOP=$(readlink -f $SCRIPT_DIR/../)
13 TEST_DEV=${TEST_DEV:-}
14 RESULTS="$TOP/tests/fsck-tests-results.txt"
15
16 source $TOP/tests/common
17
18 # Allow child test to use $TOP and $RESULTS
19 export TOP
20 export RESULTS
21 # For custom script needs to verify recovery
22 export LANG
23
24 rm -f $RESULTS
25
26 # test rely on corrupting blocks tool
27 check_prereq btrfs-corrupt-block
28 check_prereq btrfs-image
29 check_prereq btrfs
30
31 run_one_test() {
32         local testname
33
34         testname="$1"
35         echo "    [TEST/fsck]   $(basename $testname)"
36         cd $testname
37         echo "=== Entering $testname" >> $RESULTS
38         if [ -x test.sh ]; then
39                 # Type 2
40                 ./test.sh
41                 if [ $? -ne 0 ]; then
42                         _fail "test failed for case $(basename $testname)"
43                 fi
44         else
45                 # Type 1
46                 check_all_images `pwd`
47         fi
48         cd $TOP
49 }
50
51 # Each dir contains one type of error for btrfsck test.
52 # Each dir must be one of the following 2 types:
53 # 1) Only btrfs-image dump
54 #    Only contains one or several btrfs-image dumps (.img)
55 #    Each image will be tested by generic test routine
56 #    (btrfsck --repair and btrfsck).
57 #    This is for case that btree-healthy images.
58 # 2) Custom test script
59 #    This dir contains test.sh which will do custom image
60 #    generation/check/verification.
61 #    This is for case btrfs-image can't dump or case needs extra
62 #    check/verify
63
64 for i in $(find $TOP/tests/fsck-tests -maxdepth 1 -mindepth 1 -type d   \
65         ${TEST:+-name "$TEST"} | sort)
66 do
67         run_one_test "$i"
68 done