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