72f7865a905c3756d0a68e1897d8832465cc33aa
[platform/upstream/btrfs-progs.git] / tests / cli-tests.sh
1 #!/bin/bash
2 #
3 # command line interface coverage tests
4
5 LANG=C
6 SCRIPT_DIR=$(dirname $(readlink -f $0))
7 TOP=$(readlink -f $SCRIPT_DIR/../)
8 TEST_DEV=${TEST_DEV:-}
9 RESULTS="$TOP/tests/cli-tests-results.txt"
10 IMAGE="$TOP/tests/test.img"
11
12 source $TOP/tests/common
13
14 export TOP
15 export RESULTS
16 export LANG
17 export IMAGE
18 export TEST_DEV
19
20 rm -f $RESULTS
21
22 check_prereq btrfs
23
24 # The tests are driven by their custom script called 'test.sh'
25
26 for i in $(find $TOP/tests/cli-tests -maxdepth 1 -mindepth 1 -type d    \
27         ${TEST:+-name "$TEST"} | sort)
28 do
29         name=$(basename $i)
30         cd $i
31         if [ -x test.sh ]; then
32                 echo "=== Entering $i" >> $RESULTS
33                 echo "    [TEST/cli]   $name"
34                 ./test.sh
35                 if [ $? -ne 0 ]; then
36                         _fail "test failed for case $(basename $i)"
37                 fi
38         fi
39         cd $TOP
40 done