btrfs-progs: tests: convert: separate ext4 tests
[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
7 unset TOP
8 unset LANG
9 LANG=C
10 SCRIPT_DIR=$(dirname $(readlink -f $0))
11 TOP=$(readlink -f $SCRIPT_DIR/../)
12 RESULTS="$TOP/tests/convert-tests-results.txt"
13
14 source $TOP/tests/common
15 source $TOP/tests/common.convert
16
17 # Allow child test to use $TOP and $RESULTS
18 export TOP
19 export RESULTS
20 export LANG
21
22 rm -f $RESULTS
23
24 setup_root_helper
25 prepare_test_dev 512M
26
27 run_one_test() {
28         local testname
29
30         testname="$1"
31         echo "    [TEST/conv]   $testname"
32         cd $testname
33         echo "=== Entering $testname" >> $RESULTS
34         if [ -x test.sh ]; then
35                 # Difference convert test case needs different tools to restore
36                 # and check image, so only support custom test scripts
37                 ./test.sh
38                 if [ $? -ne 0 ]; then
39                         _fail "test failed for case $(basename $testname)"
40                 fi
41         else
42                 _fail "custom test script not found"
43         fi
44 }
45
46 if ! [ -z "$TEST" ]; then
47         echo "    [TEST/conv]   skipped all convert tests, TEST=$TEST"
48         exit 0
49 fi
50
51 for feature in '' 'extref' 'skinny-metadata' 'no-holes'; do
52         :
53 done
54
55 # Test special images
56 for i in $(find $TOP/tests/convert-tests -maxdepth 1 -mindepth 1 -type d \
57            ${TEST:+-name "$TEST"} | sort)
58 do
59         run_one_test "$i"
60 done