1
0
mirror of https://github.com/signalwire/freeswitch.git synced 2025-08-13 17:38:59 +00:00
Files
build
conf
debian
docs
dtd
freeswitch.xcodeproj
htdocs
libs
apr
apr-iconv-1.1.1
apr-util
codec
curl
iax
iksemel
js
nsprpub
admin
build
config
lib
pkg
pr
include
src
tests
dll
w16gui
.cvsignore
Makefile.in
README.TXT
accept.c
acceptread.c
acceptreademu.c
addrstr.c
affinity.c
alarm.c
anonfm.c
append.c
atomic.c
attach.c
bigfile.c
bigfile2.c
bigfile3.c
bug1test.c
cleanup.c
cltsrv.c
concur.c
cvar.c
cvar2.c
dbmalloc.c
dbmalloc1.c
dceemu.c
depend.c
dlltest.c
dtoa.c
env.c
errcodes.c
errset.c
exit.c
fdcach.c
fileio.c
foreign.c
forktest.c
formattm.c
freeif.c
fsync.c
getai.c
gethost.c
getproto.c
i2l.c
initclk.c
inrval.c
instrumt.c
intrio.c
intrupt.c
io_timeout.c
io_timeoutk.c
io_timeoutu.c
ioconthr.c
ipv6.c
join.c
joinkk.c
joinku.c
joinuk.c
joinuu.c
layer.c
lazyinit.c
libfilename.c
lltest.c
lock.c
lockfile.c
logger.c
makedir.c
many_cv.c
mbcs.c
multiacc.c
multiwait.c
nameshm1.c
nbconn.c
nblayer.c
nonblock.c
ntioto.c
ntoh.c
obsints.c
op_2long.c
op_excl.c
op_filnf.c
op_filok.c
op_noacc.c
op_nofil.c
openfile.c
parent.c
peek.c
perf.c
pipeping.c
pipeping2.c
pipepong.c
pipepong2.c
pipeself.c
poll_er.c
poll_nm.c
poll_to.c
pollable.c
prftest.c
prftest1.c
prftest2.c
primblok.c
priotest.c
provider.c
prpoll.c
prpollml.c
prselect.c
prttools.h
randseed.c
ranfile.c
rmdir.c
runtests.ksh
runtests.sh
runy2ktests.ksh
rwlocktest.c
sel_spd.c
selct_er.c
selct_nm.c
selct_to.c
select2.c
selintr.c
sem.c
sema.c
semaerr.c
semaerr1.c
semaping.c
semapong.c
sendzlf.c
server_test.c
servr_kk.c
servr_ku.c
servr_uk.c
servr_uu.c
short_thread.c
sigpipe.c
sleep.c
socket.c
sockopt.c
sockping.c
sockpong.c
sprintf.c
sproc_ch.c
sproc_p.c
stack.c
stat.c
stdio.c
str2addr.c
strod.c
suspend.c
switch.c
system.c
testbit.c
testfile.c
threads.c
thrpool_client.c
thrpool_server.c
thruput.c
time.c
timemac.c
timetest.c
tmoacc.c
tmocon.c
tpd.c
udpsrv.c
ut_ttools.h
vercheck.c
version.c
writev.c
xnotify.c
y2k.c
y2ktmo.c
yield.c
zerolen.c
.cvsignore
Makefile.in
tools
.cvsignore
.update
Makefile.in
configure.gnu
configure.in
src
.update
AUTHORS
ChangeLog
LINKS
Makefile.in
README
THANKS
TODO
VERSION
acsite.m4
config.hw
configure.ac
configure.gnu
js-config.1
js-config.sh.in
js.1
js.3
js.pc.in
jslint.js
libtool.m4
shtool
libdingaling
libedit
libresample
libsndfile
libteletone
pcre
portaudio
sofia-sip
speex
sqlite
srtp
stfu
udns
win32
xmlrpc-c
scripts
src
ssh_keys
support
w32
Freeswitch.sln
INSTALL
Makefile.am
acinclude.m4
bootstrap.sh
configure.in
freeswitch.spec
freeswitch/libs/js/nsprpub/pr/tests/initclk.c

110 lines
3.7 KiB
C
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* This is a regression test for the bug that the interval timer
* is not initialized when _PR_CreateCPU calls PR_IntervalNow.
* The bug would make this test program finish prematurely,
* when the SHORT_TIMEOUT period expires. The correct behavior
* is for the test to finish when the LONG_TIMEOUT period expires.
*/
#include "prlock.h"
#include "prcvar.h"
#include "prthread.h"
#include "prinrval.h"
#include "prlog.h"
#include <stdio.h>
#include <stdlib.h>
/* The timeouts, in milliseconds */
#define SHORT_TIMEOUT 1000
#define LONG_TIMEOUT 3000
PRLock *lock1, *lock2;
PRCondVar *cv1, *cv2;
void ThreadFunc(void *arg)
{
PR_Lock(lock1);
PR_WaitCondVar(cv1, PR_MillisecondsToInterval(SHORT_TIMEOUT));
PR_Unlock(lock1);
}
int main()
{
PRThread *thread;
PRIntervalTime start, end;
PRUint32 elapsed_ms;
lock1 = PR_NewLock();
PR_ASSERT(NULL != lock1);
cv1 = PR_NewCondVar(lock1);
PR_ASSERT(NULL != cv1);
lock2 = PR_NewLock();
PR_ASSERT(NULL != lock2);
cv2 = PR_NewCondVar(lock2);
PR_ASSERT(NULL != cv2);
start = PR_IntervalNow();
thread = PR_CreateThread(
PR_USER_THREAD,
ThreadFunc,
NULL,
PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD,
PR_JOINABLE_THREAD,
0);
PR_ASSERT(NULL != thread);
PR_Lock(lock2);
PR_WaitCondVar(cv2, PR_MillisecondsToInterval(LONG_TIMEOUT));
PR_Unlock(lock2);
PR_JoinThread(thread);
end = PR_IntervalNow();
elapsed_ms = PR_IntervalToMilliseconds((PRIntervalTime)(end - start));
/* Allow 100ms imprecision */
if (elapsed_ms < LONG_TIMEOUT - 100 || elapsed_ms > LONG_TIMEOUT + 100) {
printf("Elapsed time should be %u ms but is %u ms\n",
LONG_TIMEOUT, elapsed_ms);
printf("FAIL\n");
exit(1);
}
printf("Elapsed time: %u ms, expected time: %u ms\n",
LONG_TIMEOUT, elapsed_ms);
printf("PASS\n");
return 0;
}