summaryrefslogtreecommitdiffstats
path: root/tests/run_test.sh.in
blob: 47f092e71b99f5632422f89a1cbc38981370a518 (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
#!/bin/bash
#
# json dbus bridge
#
# Copyright (c) 2010 by Michael Olbrich <m.olbrich@pengutronix.de>
#
# To the extent possible under law, Pengutronix e.K. has waived all copyright
# and related or neighboring rights to JSON-DBus-Bridge Demo Code.
#

. "@abs_srcdir@/libtest.sh"

tests=()
if [ $# -eq 0 ]; then
	names=`cd "@abs_srcdir@";echo *_test.sh`
else
	names="$@"
fi
for t in $names; do
	name=
	for tt in \
			"@abs_srcdir@/$t" \
			"@abs_srcdir@/${t}_test.sh" \
			"@abs_srcdir@/$t.sh"; do
		if [ -x "$tt" ]; then
			name="$tt"
			break
		fi
	done
	if [ -z "$name" ]; then
		echo "Test '$t' not found."
		exit 1
	fi
	tests[${#tests[@]}]="$name"
done

errors=0
finish() {
	kill $test_service_pid
	kill $lighttpd_pid

	if [ $errors -eq 0 ]; then
		echo "Success."
	else
		echo "$errors tests failed."
		exit 1
	fi
}

trap finish SIGINT
trap finish SIGQUIT

"@abs_srcdir@/dbus-test-service.py" &
test_service_pid=$!

/usr/sbin/lighttpd -f "@abs_builddir@/lighttpd.conf" -D &
lighttpd_pid=$!

JDB_TEST_URL="http://localhost:8080/rpc"

echo -n "waiting for lighttpd "
for i in `seq 10`; do
	sleep 1
	echo -n "."
	jdb_test_bridge > /dev/null 2>&1 && break
done

if [ $? -ne 0 ]; then
	echo
	echo
	echo starting lighttpd failed!
	finish
	exit 1
else
	echo
	echo
	echo lighttpd sucessfully started. Running tests
	echo
fi

export JDB_TEST_URL="http://localhost:8080/rpc"
export JDB_TEST_SERVICE="com.pengutronix.jdb.test|/"
export JDB_TEST_VERBOSE="yes"

for t in "${tests[@]}"; do
	echo running `basename "$t"`:
	"$t" || errors=$[errors+1]
done

finish