btrfs-progs: tests: Fix mount fail of 013-extent-tree-rebuild
[platform/upstream/btrfs-progs.git] / tests / misc-tests.sh
1 #!/bin/bash
2 #
3 # Misc tests
4
5 unset TOP
6 unset LANG
7 LANG=C
8 SCRIPT_DIR=$(dirname $(readlink -f $0))
9 TOP=$(readlink -f $SCRIPT_DIR/../)
10 TEST_DEV=${TEST_DEV:-}
11 RESULTS="$TOP/tests/misc-tests-results.txt"
12 IMAGE="$TOP/tests/test.img"
13
14 source $TOP/tests/common
15
16 # Allow child test to use $TOP and $RESULTS
17 export TOP
18 export RESULTS
19 # For custom script needs to verfiy recovery
20 export LANG
21 # For tests that only use a loop device
22 export IMAGE
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 btrfstune
30 check_prereq btrfs
31
32 # The tests are driven by their custom script called 'test.sh'
33
34 for i in $(find $TOP/tests/misc-tests -maxdepth 1 -mindepth 1 -type d   \
35         ${TEST:+-name "$TEST"} | sort)
36 do
37         echo "    [TEST]   $(basename $i)"
38         cd $i
39         echo "=== Entering $i" >> $RESULTS
40         if [ -x test.sh ]; then
41                 ./test.sh
42                 if [ $? -ne 0 ]; then
43                         _fail "test failed for case $(basename $i)"
44                 fi
45         fi
46         cd $TOP
47 done