summaryrefslogtreecommitdiff
path: root/test/runtests.sh
blob: e998a12e1a623568c4c89d60ef3a95b501647f7c (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
#!/bin/bash

TESTS="$@"
RET=0

TIMEOUT=30
FAILED=""
MAYBE_FAILED=""

do_kmsg="yes"
if ! [ $(id -u) = 0 ]; then
	do_kmsg="no"
fi

TEST_DIR=$(dirname $0)
TEST_FILES=""
if [ -f "$TEST_DIR/config" ]; then
	. $TEST_DIR/config
	for dev in $TEST_FILES; do
		if [ ! -e "$dev" ]; then
			echo "Test file $dev not valid"
			exit 1
		fi
	done
fi

run_test()
{
	T="$1"
	D="$2"
	if [ "$do_kmsg" = "yes" ]; then
		echo Running test $T $D | tee /dev/kmsg
	else
		echo Running test $T $D
	fi
	timeout --preserve-status -s INT $TIMEOUT ./$T $D
	r=$?
	if [ "${r}" -eq 124 ]; then
		echo "Test $T timed out (may not be a failure)"
	elif [ "${r}" -ne 0 ]; then
		echo "Test $T failed with ret ${r}"
		FAILED="$FAILED $T"
		RET=1
	elif [ ! -z "$D" ]; then
		sleep .1
		ps aux | grep "\[io_wq_manager\]" > /dev/null
		R="$?"
		if [ "$R" -eq 0 ]; then
			MAYBE_FAILED="$MAYBE_FAILED $T"
		fi
	fi
}

for t in $TESTS; do
	run_test $t
	if [ ! -z "$TEST_FILES" ]; then
		for dev in $TEST_FILES; do
			run_test $t $dev
		done
	fi
done

if [ "${RET}" -ne 0 ]; then
	echo "Tests $FAILED failed"
	exit $RET
else
	sleep 1
	ps aux | grep "\[io_wq_manager\]" > /dev/null
	R="$?"
	if [ "$R" -ne 0 ]; then
		MAYBE_FAILED=""
	fi
	if [ ! -z "$MAYBE_FAILED" ]; then
		echo "Tests _maybe_ failed: $MAYBE_FAILED"
	fi
	echo "All tests passed"
	exit 0
fi