summaryrefslogtreecommitdiffstats
path: root/test/system/run
blob: 5516ed41df22122ceb1a4ddcbe70547f9d020c5d (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
#!/usr/bin/env bash

print_help() {
	echo "$1 [-a] [-d] [TEST]..."
}

run_test() {
	local result name=$1

	if [ $destructive -ne 1 ] && [[ "$name" == 1[0-9][0-9]-* ]]; then
		echo "SKIP (destructive test)"
		return 9
	fi

	./$name
	result=$?

	if [ $result -ne 0 -a $result -ne 9 ]; then
		if [ $abort_on_fail -ne 0 ]; then
			exit 1
		fi
	fi

	return $result
}

passed=() failed=() skipped=()

abort_on_fail=0
destructive=0

while getopts ":ad" opt; do
	case $opt in
		a) abort_on_fail=1;;
		d) destructive=1;;
		*) print_help "$0"; exit 3;;
	esac
done

shift $[$OPTIND - 1]

[ $# -gt 0 ] && tests=($@) || tests=([0-9]*-*[^_])

for test in "${tests[@]}"; do
	printf "%s   " "$test"
	run_test $test
	result=$?
	echo

	case $result in
		0) passed=(${passed[@]} $test);;
		9) skipped=(${skipped[@]} $test);;
		*) failed=(${failed[@]} $test);;
	esac
done

echo
echo "SUMMARY:"
echo "  TOTAL  $[${#passed[@]} + ${#failed[@]} + ${#skipped[@]}]"
echo "  PASSED ${#passed[@]}"
echo "  FAILED ${#failed[@]}    (${failed[@]})"
echo "  SKIPPED ${#skipped[@]}   (${skipped[@]})"

[ ${#failed[@]} -eq 0 ]