btrfs-progs: Introduce a misc test for thread conflict in btrfs-convert
[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 TEST_MNT=${TEST_MNT:-$TOP/tests/mnt}
12 RESULTS="$TOP/tests/misc-tests-results.txt"
13 IMAGE="$TOP/tests/test.img"
14
15 source $TOP/tests/common
16
17 # Allow child test to use $TOP and $RESULTS
18 export TOP
19 export RESULTS
20 # For custom script needs to verfiy recovery
21 export TEST_MNT
22 export LANG
23 # For tests that only use a loop device
24 export IMAGE
25
26 rm -f $RESULTS
27 mkdir -p $TEST_MNT || _fail "unable to create mount point on $TEST_MNT"
28
29 # test rely on corrupting blocks tool
30 check_prereq btrfs-corrupt-block
31 check_prereq btrfs-image
32 check_prereq btrfstune
33 check_prereq btrfs
34
35 # The tests are driven by their custom script called 'test.sh'
36
37 for i in $(find $TOP/tests/misc-tests -maxdepth 1 -mindepth 1 -type d   \
38         ${TEST:+-name "$TEST"} | sort)
39 do
40         echo "    [TEST]   $(basename $i)"
41         cd $i
42         echo "=== Entering $i" >> $RESULTS
43         if [ -x test.sh ]; then
44                 ./test.sh
45                 if [ $? -ne 0 ]; then
46                         _fail "test failed for case $(basename $i)"
47                 fi
48         fi
49         cd $TOP
50 done