xref: /minix/external/bsd/libevent/dist/test/test.sh (revision ebfedea0)
1#!/bin/sh
2
3FAILED=no
4
5if test "x$TEST_OUTPUT_FILE" = "x"
6then
7	TEST_OUTPUT_FILE=/dev/null
8fi
9
10# /bin/echo is a little more likely to support -n than sh's builtin echo,
11# printf is even more likely
12if test "`printf %s hello 2>&1`" = "hello"
13then
14	ECHO_N="printf %s"
15else
16	if test -x /bin/echo
17	then
18		ECHO_N="/bin/echo -n"
19	else
20		ECHO_N="echo -n"
21	fi
22fi
23
24if test "$TEST_OUTPUT_FILE" != "/dev/null"
25then
26	touch "$TEST_OUTPUT_FILE" || exit 1
27fi
28
29TEST_DIR=.
30
31T=`echo "$0" | sed -e 's/test.sh$//'`
32if test -x "$T/test-init"
33then
34	TEST_DIR="$T"
35fi
36
37setup () {
38	EVENT_NOKQUEUE=yes; export EVENT_NOKQUEUE
39	EVENT_NODEVPOLL=yes; export EVENT_NODEVPOLL
40	EVENT_NOPOLL=yes; export EVENT_NOPOLL
41	EVENT_NOSELECT=yes; export EVENT_NOSELECT
42	EVENT_NOEPOLL=yes; export EVENT_NOEPOLL
43	unset EVENT_EPOLL_USE_CHANGELIST
44	EVENT_NOEVPORT=yes; export EVENT_NOEVPORT
45	EVENT_NOWIN32=yes; export EVENT_NOWIN32
46}
47
48announce () {
49	echo "$@"
50	echo "$@" >>"$TEST_OUTPUT_FILE"
51}
52
53announce_n () {
54	$ECHO_N "$@"
55	echo "$@" >>"$TEST_OUTPUT_FILE"
56}
57
58
59run_tests () {
60	if $TEST_DIR/test-init 2>>"$TEST_OUTPUT_FILE" ;
61	then
62		true
63	else
64		announce Skipping test
65		return
66	fi
67
68	announce_n " test-eof: "
69	if $TEST_DIR/test-eof >>"$TEST_OUTPUT_FILE" ;
70	then
71		announce OKAY ;
72	else
73		announce FAILED ;
74		FAILED=yes
75	fi
76	announce_n " test-weof: "
77	if $TEST_DIR/test-weof >>"$TEST_OUTPUT_FILE" ;
78	then
79		announce OKAY ;
80	else
81		announce FAILED ;
82		FAILED=yes
83	fi
84	announce_n " test-time: "
85	if $TEST_DIR/test-time >>"$TEST_OUTPUT_FILE" ;
86	then
87		announce OKAY ;
88	else
89		announce FAILED ;
90		FAILED=yes
91	fi
92	announce_n " test-changelist: "
93	if $TEST_DIR/test-changelist >>"$TEST_OUTPUT_FILE" ;
94	then
95		announce OKAY ;
96	else
97		announce FAILED ;
98		FAILED=yes
99	fi
100	test -x $TEST_DIR/regress || return
101	announce_n " regress: "
102	if test "$TEST_OUTPUT_FILE" = "/dev/null" ;
103	then
104		$TEST_DIR/regress --quiet
105	else
106		$TEST_DIR/regress >>"$TEST_OUTPUT_FILE"
107	fi
108	if test "$?" = "0" ;
109	then
110		announce OKAY ;
111	else
112		announce FAILED ;
113		FAILED=yes
114	fi
115}
116
117announce "Running tests:"
118
119# Need to do this by hand?
120setup
121unset EVENT_NOEVPORT
122announce "EVPORT"
123run_tests
124
125setup
126unset EVENT_NOKQUEUE
127announce "KQUEUE"
128run_tests
129
130setup
131unset EVENT_NOEPOLL
132announce "EPOLL"
133run_tests
134
135setup
136unset EVENT_NOEPOLL
137EVENT_EPOLL_USE_CHANGELIST=yes; export EVENT_EPOLL_USE_CHANGELIST
138announce "EPOLL (changelist)"
139run_tests
140
141setup
142unset EVENT_NODEVPOLL
143announce "DEVPOLL"
144run_tests
145
146setup
147unset EVENT_NOPOLL
148announce "POLL"
149run_tests
150
151setup
152unset EVENT_NOSELECT
153announce "SELECT"
154run_tests
155
156setup
157unset EVENT_NOWIN32
158announce "WIN32"
159run_tests
160
161if test "$FAILED" = "yes"; then
162	exit 1
163fi
164