btrfs-progs: tests: add quotation around variables in support scripts
[platform/upstream/btrfs-progs.git] / tests / convert-tests.sh
1 #!/bin/bash
2 #
3 # convert ext2/3/4 images to btrfs images, and make sure the results are
4 # clean.
5
6 LANG=C
7 SCRIPT_DIR=$(dirname $(readlink -f "$0"))
8 TOP=$(readlink -f "$SCRIPT_DIR/../")
9 TEST_DEV=${TEST_DEV:-}
10 RESULTS="$TOP/tests/convert-tests-results.txt"
11 IMAGE="$TOP/tests/test.img"
12
13 source "$TOP/tests/common"
14 source "$TOP/tests/common.convert"
15
16 export TOP
17 export RESULTS
18 export LANG
19 export IMAGE
20 export TEST_DEV
21
22 rm -f "$RESULTS"
23
24 check_kernel_support
25
26 run_one_test() {
27         local testdir
28         local testname
29
30         testdir="$1"
31         testname=$(basename "$testdir")
32         echo "    [TEST/conv]   $testname"
33         cd "$testdir"
34         echo "=== Entering $testname" >> "$RESULTS"
35         if [ -x test.sh ]; then
36                 # Only support custom test scripts
37                 ./test.sh
38                 if [ $? -ne 0 ]; then
39                         _fail "test failed for case $testname"
40                 fi
41         else
42                 _fail "custom test script not found"
43         fi
44 }
45
46 # Test special images
47 for i in $(find "$TOP/tests/convert-tests" -maxdepth 1 -mindepth 1 -type d \
48            ${TEST:+-name "$TEST"} | sort)
49 do
50         run_one_test "$i"
51 done