summaryrefslogtreecommitdiffstats
path: root/tests/test_one.in
blob: 78499ad0bc54b1170454314e429dee062b1aaa70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh
# run a single regression test

export DD

LC_ALL=C
export LC_ALL

case "$1" in
    --valgrind)
    	export USE_VALGRIND="valgrind -q --sim-hints=lax-ioctls"
	shift;
	;;
    --valgrind-leakcheck)
    	export USE_VALGRIND="valgrind --sim-hints=lax-ioctls --leak-check=full --show-reachable=yes --log-file=/tmp/valgrind-%p.log"
	shift;
	;;
    --skip-slow-tests)
	SKIP_SLOW_TESTS=yes
	shift;
	;;
esac

case "$1" in
    *.failed|*.new|*.ok|*.log|*.tmp|*.slow)	exit 0 ;;
esac

test_dir=$1
cmd_dir=$SRCDIR

if test "$TEST_CONFIG"x = x; then
	TEST_CONFIG=$SRCDIR/test_config
fi

. $TEST_CONFIG

test_name=`echo $test_dir | sed -e 's;.*/;;'`

if [ -f $test_dir ] ; then
	exit 0;
fi
if [ ! -d $test_dir ] ; then
	echo "The test '$test_name' does not exist."
	exit 0;
fi
if [ -z "`ls $test_dir`" ]; then
	exit 0
fi
if [ -f $test_dir/name ]; then
	test_description=`cat $test_dir/name`
else
	test_description=
fi

if [ -n "$SKIP_SLOW_TESTS" -a -f $test_dir/is_slow_test ]; then
    echo "$test_name: $test_description: skipped (slow test)"
    exit 0
fi

rm -f $test_name.ok $test_name.failed $test_name.log $test_name.slow
#echo -e -n "$test_name: $test_description:\r"

TMPFILE=$(mktemp ${TMPDIR:-/tmp}/e2fsprogs-tmp-$test_name.XXXXXX)
[ "$SKIP_UNLINK" != "true" ] && trap 'rm -f $TMPFILE ; exit' 0 1 2 15

start=$SECONDS
if [ -f $test_dir/script ]; then
	. $test_dir/script
else
	test_base=`echo $test_name | sed -e 's/_.*//'`
	default_script=$SRCDIR/defaults/${test_base}_script
	if [ -f $default_script ]; then
		. $SRCDIR/defaults/${test_base}_script
	else
		echo "$test_name: Missing test script $default_script!"
	fi
fi
elapsed=$((SECONDS - start))
if [ $elapsed -gt 60 -a ! -f $test_dir/is_slow_test ]; then
	echo "$test_name:  *** took $elapsed seconds to finish ***" |
		tee $test_name.slow
	echo "$test_name:  consider adding $test_dir/is_slow_test"
fi

if [ -n "$PRINT_FAILED" -a -f $test_name.failed ] ; then
	cat $test_name.failed
fi

if [ "$SKIP_UNLINK" != "true" ] ; then
	rm -f $TMPFILE
fi