Whamcloud - gitweb
mke2fs: warn that bigalloc is experimental only for large cluster sizes
[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
31 if test "$TEST_CONFIG"x = x; then
32         TEST_CONFIG=$SRCDIR/test_config
33 fi
34
35 . $TEST_CONFIG
36
37 test_name=`echo $test_dir | sed -e 's;.*/;;'`
38
39 if [ -f $test_dir ] ; then
40         exit 0;
41 fi
42 if [ ! -d $test_dir ] ; then
43         echo "The test '$test_name' does not exist."
44         exit 0;
45 fi
46 if [ -z "`ls $test_dir`" ]; then
47         exit 0
48 fi
49 if [ -f $test_dir/name ]; then
50         test_description=`cat $test_dir/name`
51 else
52         test_description=
53 fi
54
55 if [ -n "$SKIP_SLOW_TESTS" -a -f $test_dir/is_slow_test ]; then
56     echo "$test_name: $test_description: skipped (slow test)"
57     exit 0
58 fi
59
60 rm -f $test_name.ok $test_name.failed $test_name.log $test_name.slow
61 #echo -e -n "$test_name: $test_description:\r"
62
63 TMPFILE=$(mktemp ${TMPDIR:-/tmp}/e2fsprogs-tmp-$test_name.XXXXXX)
64 [ "$SKIP_UNLINK" != "true" ] && trap 'rm -f $TMPFILE ; exit' 0 1 2 15
65
66 start=$SECONDS
67 if [ -f $test_dir/script ]; then
68         . $test_dir/script
69 else
70         test_base=`echo $test_name | sed -e 's/_.*//'`
71         default_script=$SRCDIR/defaults/${test_base}_script
72         if [ -f $default_script ]; then
73                 . $SRCDIR/defaults/${test_base}_script
74         else
75                 echo "$test_name: Missing test script $default_script!"
76         fi
77 fi
78 elapsed=$((SECONDS - start))
79 if [ $elapsed -gt 60 -a ! -f $test_dir/is_slow_test ]; then
80         echo "$test_name:  *** took $elapsed seconds to finish ***" |
81                 tee $test_name.slow
82         echo "$test_name:  consider adding $test_dir/is_slow_test"
83 fi
84
85 if [ "$SKIP_UNLINK" != "true" ] ; then
86         rm -f $TMPFILE
87 fi
88