1#!/bin/sh
2#
3# This Source Code Form is subject to the terms of the Mozilla Public
4# License, v. 2.0. If a copy of the MPL was not distributed with this
5# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#
8# runtests.sh
9#	Bourne shell script for nspr tests
10#
11
12SYSTEM_INFO=`uname -a`
13OS_ARCH=`uname -s`
14
15if [ $OS_ARCH = "Windows_NT" ] || [ $OS_ARCH = "OS/2" ]
16then
17	NULL_DEVICE=nul
18else
19	NULL_DEVICE=/dev/null
20	FILE_D=`ulimit -n`
21	if [ $FILE_D -lt 512 ]
22	then
23		ulimit -n 512
24	fi
25fi
26
27#
28# Irrevelant tests
29#
30#bug1test 	- used to demonstrate a bug on NT
31#bigfile2   - requires 4Gig file creation. See BugZilla #5451
32#bigfile3   - requires 4Gig file creation. See BugZilla #5451
33#dbmalloc	- obsolete; originally for testing debug version of nspr's malloc
34#dbmalloc1	- obsolete; originally for testing debug version of nspr's malloc
35#depend		- obsolete; used to test a initial spec for library dependencies
36#dceemu		- used to tests special functions in NSPR for DCE emulation
37#ipv6		- IPV6 not in use by NSPR clients
38#mbcs       - tests use of multi-byte charset for filenames. See BugZilla #25140
39#sproc_ch	- obsolete; sproc-based tests for Irix
40#sproc_p	- obsolete; sproc-based tests for Irix
41#io_timeoutk - obsolete; subsumed in io_timeout
42#io_timeoutu - obsolete; subsumed in io_timeout
43#prftest1	- obsolete; subsumed by prftest
44#prftest2	- obsolete; subsumed by prftest
45#prselect	- obsolete; PR_Select is obsolete
46#select2	- obsolete; PR_Select is obsolete
47#sem		- obsolete; PRSemaphore is obsolete
48#stat		- for OS2?
49#suspend	- private interfaces PR_SuspendAll, PR_ResumeAll, etc..
50#thruput	- needs to be run manually as client/server
51#time		- used to measure time with native calls and nspr calls
52#tmoacc		- should be run with tmocon
53#tmocon		- should be run with tmoacc
54#op_noacc	- limited use
55#yield		- limited use for PR_Yield
56
57#
58# Tests not run (but should)
59#
60
61#forktest (failed on IRIX)
62#nbconn - fails on some platforms
63#poll_er - fails on some platforms? limited use?
64#prpoll -  the bad-FD test needs to be moved to a different test
65#sleep	-  specific to OS/2
66
67LOGFILE=${NSPR_TEST_LOGFILE:-$NULL_DEVICE}
68
69#
70# Tests run on all platforms
71#
72
73TESTS="
74accept
75acceptread
76acceptreademu
77affinity
78alarm
79anonfm
80atomic
81attach
82bigfile
83cleanup
84cltsrv
85concur
86cvar
87cvar2
88dlltest
89dtoa
90errcodes
91exit
92fdcach
93fileio
94foreign
95formattm
96fsync
97gethost
98getproto
99i2l
100initclk
101inrval
102instrumt
103intrio
104intrupt
105io_timeout
106ioconthr
107join
108joinkk
109joinku
110joinuk
111joinuu
112layer
113lazyinit
114libfilename
115lltest
116lock
117lockfile
118logfile
119logger
120many_cv
121multiwait
122nameshm1
123nblayer
124nonblock
125ntioto
126ntoh
127op_2long
128op_excl
129op_filnf
130op_filok
131op_nofil
132parent
133parsetm
134peek
135perf
136pipeping
137pipeping2
138pipeself
139poll_nm
140poll_to
141pollable
142prftest
143prfz
144primblok
145provider
146prpollml
147pushtop
148ranfile
149randseed
150reinit
151rwlocktest
152sel_spd
153selct_er
154selct_nm
155selct_to
156selintr
157sema
158semaerr
159semaping
160sendzlf
161server_test
162servr_kk
163servr_uk
164servr_ku
165servr_uu
166short_thread
167sigpipe
168socket
169sockopt
170sockping
171sprintf
172stack
173stdio
174str2addr
175strod
176switch
177system
178testbit
179testfile
180threads
181timemac
182timetest
183tpd
184udpsrv
185vercheck
186version
187writev
188xnotify
189zerolen"
190
191rval=0
192
193
194#
195# When set, value of the environment variable TEST_TIMEOUT is the maximum
196# time (secs) allowed for a test program beyond which it is terminated.
197# If TEST_TIMEOUT is not set or if it's value is 0, then test programs
198# don't timeout.
199#
200# Running runtests.ksh under MKS toolkit on NT, 95, 98 does not cause
201# timeout detection correctly. For these platforms, do not attempt timeout
202# test. (lth).
203#
204#
205
206OS_PLATFORM=`uname`
207OBJDIR=`basename $PWD`
208printf "\nNSPR Test Results - $OBJDIR\n\n"
209printf "BEGIN\t\t\t`date`\n"
210printf "NSPR_TEST_LOGFILE\t${LOGFILE}\n\n"
211printf "Test\t\t\tResult\n\n"
212if [ $OS_PLATFORM = "Windows_95" ] || [ $OS_PLATFORM = "Windows_98" ] || [ $OS_PLATFORM = "Windows_NT" ] || [ $OS_PLATFORM = "OS/2" ] ; then
213	for prog in $TESTS
214	do
215		printf "$prog"
216		printf "\nBEGIN TEST: $prog\n\n" >> ${LOGFILE} 2>&1
217		./$prog >> ${LOGFILE} 2>&1
218		if [ 0 = $? ] ; then
219			printf "\t\t\tPassed\n";
220		else
221			printf "\t\t\tFAILED\n";
222			rval=1
223		fi;
224		printf "\nEND TEST: $prog\n\n" >> ${LOGFILE} 2>&1
225	done
226else
227	for prog in $TESTS
228	do
229		printf "$prog"
230		printf "\nBEGIN TEST: $prog\n\n" >> ${LOGFILE} 2>&1
231		export test_rval
232		./$prog >> ${LOGFILE} 2>&1 &
233		test_pid=$!
234		sleep_pid=0
235		if test -n "$TEST_TIMEOUT" && test "$TEST_TIMEOUT" -gt 0
236		then
237		(sleep  $TEST_TIMEOUT; kill $test_pid >/dev/null 2>&1 ) &
238		sleep_pid=$!
239		fi
240		wait $test_pid
241		test_rval=$?
242		[ $sleep_pid -eq 0 ] || kill $sleep_pid >/dev/null 2>&1
243		if [ 0 = $test_rval ] ; then
244			printf "\t\t\tPassed\n";
245		else
246			printf "\t\t\tFAILED\n";
247			rval=1
248		fi;
249		printf "\nEND TEST: $prog\n\n" >> ${LOGFILE} 2>&1
250	done
251fi;
252
253printf "END\t\t\t`date`\n"
254exit $rval
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272