Whamcloud - gitweb
e2fsck: configure one pfsck thread
[tools/e2fsprogs.git] / tests / test_one.in
1 #!/bin/sh
2 # run a single regression test
3
4 export DD
5
6 LC_ALL=C
7 export LC_ALL
8
9 case "$1" in
10     --valgrind)
11         export USE_VALGRIND="valgrind -q --sim-hints=lax-ioctls"
12         shift;
13         ;;
14     --valgrind-leakcheck)
15         export USE_VALGRIND="valgrind --sim-hints=lax-ioctls --leak-check=full --show-reachable=yes --log-file=/tmp/valgrind-%p.log"
16         shift;
17         ;;
18     --skip-slow-tests)
19         SKIP_SLOW_TESTS=yes
20         shift;
21         ;;
22 esac
23
24 case "$1" in
25     *.failed|*.new|*.ok|*.log|*.tmp|*.slow)     exit 0 ;;
26 esac
27
28 test_dir=$1
29 cmd_dir=$SRCDIR
30 pfsck_enabled="no"
31
32 if test "$TEST_CONFIG"x = x; then
33         TEST_CONFIG=$SRCDIR/test_config
34 fi
35
36 . $TEST_CONFIG
37
38 test_name=`echo $test_dir | sed -e 's;.*/;;'`
39
40 if [ -f $test_dir ] ; then
41         exit 0;
42 fi
43 if [ ! -d $test_dir ] ; then
44         echo "The test '$test_name' does not exist."
45         exit 0;
46 fi
47 if [ -z "`ls $test_dir`" ]; then
48         exit 0
49 fi
50 if [ -f $test_dir/name ]; then
51         test_description=`cat $test_dir/name`
52 else
53         test_description=
54 fi
55
56 $FSCK --help 2>&1 | grep -q -w -- -m && pfsck_enabled=yes
57 if [ "$pfsck_enabled" != "yes" ] ; then
58         echo "$test_dir" | grep -q multithread &&
59         echo "$test_name: $test_description: skipped (pfsck disabled)" &&
60         exit 0
61 fi
62
63 if [ -n "$SKIP_SLOW_TESTS" -a -f $test_dir/is_slow_test ]; then
64     echo "$test_name: $test_description: skipped (slow test)"
65     exit 0
66 fi
67
68 rm -f $test_name.ok $test_name.failed $test_name.log $test_name.slow
69 #echo -e -n "$test_name: $test_description:\r"
70
71 TMPFILE=$(mktemp ${TMPDIR:-/tmp}/e2fsprogs-tmp-$test_name.XXXXXX)
72 [ "$SKIP_UNLINK" != "true" ] && trap 'rm -f $TMPFILE ; exit' 0 1 2 15
73
74 start=$SECONDS
75 if [ -f $test_dir/script ]; then
76         . $test_dir/script
77 else
78         test_base=`echo $test_name | sed -e 's/_.*//'`
79         default_script=$SRCDIR/defaults/${test_base}_script
80         if [ -f $default_script ]; then
81                 . $SRCDIR/defaults/${test_base}_script
82         else
83                 echo "$test_name: Missing test script $default_script!"
84         fi
85 fi
86 elapsed=$((SECONDS - start))
87 if [ $elapsed -gt 60 -a ! -f $test_dir/is_slow_test ]; then
88         echo "$test_name:  *** took $elapsed seconds to finish ***" |
89                 tee $test_name.slow
90         echo "$test_name:  consider adding $test_dir/is_slow_test"
91 fi
92
93 if [ -n "$PRINT_FAILED" -a -f $test_name.failed ] ; then
94         cat $test_name.failed
95 fi
96
97 if [ "$SKIP_UNLINK" != "true" ] ; then
98         rm -f $TMPFILE
99 fi
100