From e2fd6e2de322cc12d9153da548ab76379049c11c Mon Sep 17 00:00:00 2001 From: rpj Date: Tue, 25 Jul 2000 16:14:23 +0000 Subject: 2000-07-25 Ross Johnson * sched.c (sched_get_priority_max): Handle different WinCE and Win32 priority values together. (sched_get_priority_min): Ditto. - Tristan Savatier * create.c (pthread_create): Force new threads to wait until pthread_create has the new thread's handle; we also retain a local copy of the handle for internal use until pthread_create returns. * private.c (_pthread_threadStart): Initialise ei[]. (_pthread_threadStart): When beginthread is used to start the thread, force waiting until the creator thread had the thread handle. * cancel.c (_pthread_cancel_thread): Include context switch code for defined(_X86_) environments in addition to _M_IX86. * rwlock.c (pthread_rwlock_destroy): Assignment changed to avoid compiler warning. * private.c (_pthread_get_exception_services_code): Cast NULL return value to avoid compiler warning. * cleanup.c (pthread_pop_cleanup): Initialise "cleanup" variable to avoid compiler warnings. * misc.c (_pthread_new): Change "new" variable to "t" to avoid confusion with the C++ keyword of the same name. * condvar.c (cond_wait_cleanup): Initialise lastWaiter variable. (cond_timedwait): Remove unused local variables. to avoid compiler warnings. * dll.c (dllMain): Remove 2000-07-21 change - problem appears to be in pthread_create(). 2000-07-22 Ross Johnson * tsd.c (pthread_key_create): If a destructor was given and the pthread_mutex_init failed, then would try to reference a NULL pointer (*key); eliminate this section of code by using a dynamically initialised mutex (PTHREAD_MUTEX_INITIALIZER). * tsd.c (pthread_setspecific): Return an error if unable to set the value; simplify cryptic conditional. * tsd.c (pthread_key_delete): Locking threadsLock relied on mutex_lock returning an error if the key has no destructor. ThreadsLock is only initialised if the key has a destructor. Making this mutex a static could reduce the number of mutexes used by an application since it is actually created only at first use and it's often destroyed soon after. 2000-07-22 Ross Johnson * FAQ: Added Q5 and Q6. tests/ChangeLog: 2000-07-25 Ross Johnson * runtest.bat: modified to work under W98. * runall.bat: Add new tests; modified to work under W98. It was ok under NT. * Makefile: Add new tests. * exception1.c: New; Test passing exceptions back to the application and retaining library internal exceptions. * join0.c: New; Test a single join. --- tests/ChangeLog | 14 +++++ tests/Makefile | 7 ++- tests/cancel2.c | 3 +- tests/cancel3.c | 4 +- tests/cancel4.c | 2 +- tests/ccl.bat | 18 +++---- tests/join1.c | 13 +++-- tests/loadfree.c | 2 +- tests/runall.bat | 130 +++++++++++++++++++++++----------------------- tests/runtest.bat | 150 +++++++++++++++++++++++++++++------------------------- 10 files changed, 189 insertions(+), 154 deletions(-) (limited to 'tests') diff --git a/tests/ChangeLog b/tests/ChangeLog index 8e65a35..902a809 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,17 @@ +2000-07-25 Ross Johnson + + * runtest.bat: modified to work under W98. + + * runall.bat: Add new tests; modified to work under W98. + It was ok under NT. + + * Makefile: Add new tests. + + * exception1.c: New; Test passing exceptions back to the + application and retaining library internal exceptions. + + * join0.c: New; Test a single join. + 2000-01-06 Ross Johnson * cleanup1.c: New; Test cleanup handler executes (when thread is diff --git a/tests/Makefile b/tests/Makefile index ef1d30f..5931855 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -39,12 +39,13 @@ COPYFILES = $(HDR) $(LIB) $(DLL) TESTS = loadfree \ mutex1 condvar1 condvar2 exit1 create1 equal1 \ exit2 exit3 \ - join1 join2 mutex2 mutex3 \ + join0 join1 join2 mutex2 mutex3 \ count1 once1 tsd1 self1 self2 cancel1 eyal1 \ condvar3 condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \ errno1 \ rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 \ - context1 cancel3 cancel4 cleanup1 cleanup2 cleanup3 + context1 cancel3 cancel4 cleanup1 cleanup2 cleanup3 \ + exception1 PASSES = $(TESTS:%=%.pass) @@ -63,6 +64,7 @@ mutex3.pass: create1.pass equal1.pass: create1.pass exit2.pass: create1.pass exit3.pass: create1.pass +join0.pass: create1.pass join1.pass: create1.pass join2.pass: create1.pass count1.pass: join1.pass @@ -90,6 +92,7 @@ cancel4.pass: cancel3.pass cleanup1.pass: cancel4.pass cleanup2.pass: cleanup1.pass cleanup3.pass: cleanup2.pass +exception1.pass: cancel4.pass %.pass: %.exe $(LIB) $(DLL) $(HDR) $* diff --git a/tests/cancel2.c b/tests/cancel2.c index 1a10c64..44d1b77 100644 --- a/tests/cancel2.c +++ b/tests/cancel2.c @@ -48,7 +48,7 @@ * Create NUMTHREADS threads in addition to the Main thread. */ enum { - NUMTHREADS = 4 + NUMTHREADS = 1 }; typedef struct bag_t_ bag_t; @@ -113,7 +113,6 @@ mythread(void * arg) /* * Should not get into here. */ - printf("SEH code=%x, MyCode=%x\n", GetExceptionCode(), _pthread_get_exception_services_code()); result += 100; } diff --git a/tests/cancel3.c b/tests/cancel3.c index ff1d286..cb6f3d2 100644 --- a/tests/cancel3.c +++ b/tests/cancel3.c @@ -65,7 +65,7 @@ static pthread_mutex_t waitLock = PTHREAD_MUTEX_INITIALIZER; void * mythread(void * arg) { - int result = 0; + int result = ((int)PTHREAD_CANCELED + 1); bag_t * bag = (bag_t *) arg; assert(bag == &threadbag[bag->threadnum]); @@ -85,7 +85,7 @@ mythread(void * arg) for (bag->count = 0; bag->count < 100; bag->count++) Sleep(100); - return result; + return (void *) result; } int diff --git a/tests/cancel4.c b/tests/cancel4.c index 9ce6880..59c2f8e 100644 --- a/tests/cancel4.c +++ b/tests/cancel4.c @@ -68,7 +68,7 @@ static bag_t threadbag[NUMTHREADS + 1]; void * mythread(void * arg) { - int result = 0; + int result = ((int)PTHREAD_CANCELED + 1); bag_t * bag = (bag_t *) arg; assert(bag == &threadbag[bag->threadnum]); diff --git a/tests/ccl.bat b/tests/ccl.bat index 473ff42..d80ea03 100644 --- a/tests/ccl.bat +++ b/tests/ccl.bat @@ -1,9 +1,9 @@ -REM Generate preprocessor output -REM cl /E /W3 /MT /nologo /Yd /Zi -I. -D_WIN32_WINNT=0x400 -DSTDCALL=_stdcall -c ..\%1.c > ..\%1.e - -REM Generate object file -cl /W3 /MT /nologo /Yd /Zi -I. -D_WIN32_WINNT=0x400 -DSTDCALL=_stdcall -c ..\%1.c - -REM Generate executable -cl /Feaout.exe /Zi %1.obj .\pthread.lib -del %1.obj > nul: +REM Generate preprocessor output +REM cl /E /W3 /MT /nologo /Yd /Zi -I. -D_WIN32_WINNT=0x400 -DSTDCALL=_stdcall -c ..\%1.c > ..\%1.e + +REM Generate object file +cl /W3 /MT /nologo /Yd /Zi -I. -D_WIN32_WINNT=0x400 -DSTDCALL=_stdcall -c ..\%1.c + +REM Generate executable +cl /Feaout.exe /Zi %1.obj .\pthread.lib +del %1.obj > nul: diff --git a/tests/join1.c b/tests/join1.c index f206c0b..c29e5e6 100644 --- a/tests/join1.c +++ b/tests/join1.c @@ -9,12 +9,14 @@ void * func(void * arg) { - Sleep(1000); + int i = (int) arg; + + Sleep(i * 500); - pthread_exit(arg); + pthread_exit(arg); - /* Never reached. */ - exit(1); + /* Never reached. */ + exit(1); } int @@ -30,6 +32,9 @@ main(int argc, char * argv[]) assert(pthread_create(&id[i], NULL, func, (void *) i) == 0); } + /* Some threads will finish before they are joined, some after. */ + Sleep(1000); + for (i = 0; i < 4; i++) { assert(pthread_join(id[i], (void *) &result) == 0); diff --git a/tests/loadfree.c b/tests/loadfree.c index 3aba61b..b9b14c3 100644 --- a/tests/loadfree.c +++ b/tests/loadfree.c @@ -28,7 +28,7 @@ int main() { HINSTANCE hinst; - assert((hinst = LoadLibrary("pthread")) != 0); + assert((hinst = LoadLibrary("pthread")) != (HINSTANCE) 0); Sleep(100); diff --git a/tests/runall.bat b/tests/runall.bat index ace1962..f2f492b 100644 --- a/tests/runall.bat +++ b/tests/runall.bat @@ -1,64 +1,66 @@ -@echo off - -if NOT x%1==x-f goto noforce -if EXIST *.pass echo y | erase *.pass > nul: -if EXIST *.fail echo y | erase *.fail > nul: -if EXIST *.notrun echo y | erase *.notrun > nul: - -:noforce -call runtest cl loadfree _ -call runtest cl mutex1 _ -call runtest cl mutex2 _ -call runtest cl exit1 _ -call runtest cl condvar1 _ -call runtest cl self1 _ -call runtest cl condvar2 condvar1 -call runtest cl create1 mutex2 -call runtest cl mutex3 create1 -call runtest cl equal1 create1 -call runtest cl exit2 create1 -call runtest cl exit3 create1 -call runtest cl join1 create1 -call runtest cl join2 create1 -call runtest cl count1 join1 -call runtest cl once1 create1 -call runtest cl tsd1 join1 -call runtest cl self2 create1 -call runtest cl cancel1 self2 -call runtest cl cancel2 cancel1 -call runtest cl eyal1 tsd1 -call runtest cl condvar3 create1 -call runtest cl condvar4 create1 -call runtest cl condvar5 condvar4 -call runtest cl condvar6 condvar5 -call runtest cl errno1 mutex3 -call runtest cl rwlock1 condvar6 -call runtest cl rwlock2 rwlock1 -call runtest cl rwlock3 rwlock2 -call runtest cl rwlock4 rwlock3 -call runtest cl rwlock5 rwlock4 -call runtest cl rwlock6 rwlock5 -call runtest cl context1 cancel2 -call runtest cl cancel3 context1 -call runtest cl cancel4 cancel3 -call runtest cl cleanup1 cancel4 -call runtest cl cleanup2 cleanup1 -call runtest cl cleanup3 cleanup2 -call runtest cl condvar7 cleanup1 -call runtest cl condvar8 condvar7 -call runtest cl condvar9 condvar8 - -if NOT EXIST *.notrun goto skip1 -echo The following tests did not run (because prerequisite didn't pass?): -for %%f in (*.notrun) do echo %%f -goto skip2 -:skip1 -echo All tests ran. -:skip2 -if NOT EXIST *.fail goto skip3 -echo The following tests failed: -for %%f in (*.fail) do echo %%f -goto skip4 -:skip3 -echo No tests failed. -:skip4 +@echo off + +if NOT x%1==x-f goto noforce +if EXIST *.pass echo y | erase *.pass > nul: +if EXIST *.fail echo y | erase *.fail > nul: +if EXIST *.notrun echo y | erase *.notrun > nul: + +:noforce +call runtest cl loadfree _ +call runtest cl mutex1 _ +call runtest cl mutex2 _ +call runtest cl exit1 _ +call runtest cl condvar1 _ +call runtest cl self1 _ +call runtest cl condvar2 condvar1 +call runtest cl create1 mutex2 +call runtest cl mutex3 create1 +call runtest cl equal1 create1 +call runtest cl exit2 create1 +call runtest cl exit3 create1 +call runtest cl join0 create1 +call runtest cl join1 create1 +call runtest cl join2 create1 +call runtest cl count1 join1 +call runtest cl once1 create1 +call runtest cl tsd1 join1 +call runtest cl self2 create1 +call runtest cl cancel1 self2 +call runtest cl cancel2 cancel1 +call runtest cl eyal1 tsd1 +call runtest cl condvar3 create1 +call runtest cl condvar4 create1 +call runtest cl condvar5 condvar4 +call runtest cl condvar6 condvar5 +call runtest cl errno1 mutex3 +call runtest cl rwlock1 condvar6 +call runtest cl rwlock2 rwlock1 +call runtest cl rwlock3 rwlock2 +call runtest cl rwlock4 rwlock3 +call runtest cl rwlock5 rwlock4 +call runtest cl rwlock6 rwlock5 +call runtest cl context1 cancel2 +call runtest cl cancel3 context1 +call runtest cl cancel4 cancel3 +call runtest cl cleanup1 cancel4 +call runtest cl cleanup2 cleanup1 +call runtest cl cleanup3 cleanup2 +call runtest cl condvar7 cleanup1 +call runtest cl condvar8 condvar7 +call runtest cl condvar9 condvar8 +call runtest cl exception1 cancel4 + +if NOT EXIST *.notrun goto skip1 +echo The following tests did not run (because prerequisite didn't pass?): +for %%f in (*.notrun) do echo %%f +goto skip2 +:skip1 +echo All tests ran. +:skip2 +if NOT EXIST *.fail goto skip3 +echo The following tests failed: +for %%f in (*.fail) do echo %%f +goto skip4 +:skip3 +echo No tests failed. +:skip4 diff --git a/tests/runtest.bat b/tests/runtest.bat index dc36666..1129b9b 100644 --- a/tests/runtest.bat +++ b/tests/runtest.bat @@ -1,69 +1,81 @@ -@echo off - -REM Usage: runtest cl|gcc testname prerequisit testarg ... - -if %3==_ goto noprereq -if NOT EXIST %3.pass goto needprereq - -:noprereq -if EXIST %2.fail goto forcetest -if EXIST %2.pass goto bypass - -:forcetest -if EXIST %2.fail erase %2.fail - -REM Make sure we start with only those files we expect to need -if exist tmp\*.* echo y | erase tmp\*.* > nul: -rmdir tmp -mkdir tmp - -copy ..\pthread.dll tmp > nul: -copy ..\pthread.h tmp > nul: -copy ..\semaphore.h tmp > nul: -copy ..\sched.h tmp > nul: -copy test.h tmp > nul: -copy ..\pthread.lib tmp > nul: -copy ..\libpthread32.a tmp > nul: - -cd tmp - -REM Compile the test case -REM produces aout.exe using the compiler given as %1 -call ..\c%1.bat %2 > ..\%2.%1log - -if ERRORLEVEL 1 goto cleanup - -REM erase ..\%2.%1log - -echo TEST: %2 [%1] - -REM Run the test case -if EXIST %2.pass erase %2.pass -if EXIST %2.fail erase %2.fail -if EXIST %2.notrun erase %2.notrun -aout.exe %4 %5 %6 %7 %8 %9 - -set RESULT=%ERRORLEVEL% - -if %RESULT% NEQ 0 echo Failed [%RESULT%] > ..\%2.fail -if %RESULT% EQU 0 echo Passed > ..\%2.pass - -:cleanup - -cd .. - -REM Clean up -if exist tmp\*.* echo y | erase tmp\*.* > nul: - -if EXIST %2.fail echo Failed [%RESULT%] -if EXIST %2.pass echo Passed [%RESULT%] - -:bypass -goto end - -:needprereq -echo Test %2 requires %3 to pass before it can run. -echo No Prereq > ..\%2.notrun -goto end - -:end +@echo off + +REM Usage: runtest cl testname prerequisit testarg ... +REM or: runtest gcc testname prerequisit testarg ... + +if %3==_ goto noprereq +if NOT EXIST %3.pass goto needprereq + +:noprereq +if EXIST %2.fail goto forcetest +if EXIST %2.pass goto bypass + +:forcetest +if EXIST %2.fail erase %2.fail + +REM Make sure we start with only those files we expect to need +if not exist tmp\*.* goto skip1 +echo y | erase tmp\*.* > nul: +rmdir tmp +mkdir tmp +:skip1 + +copy ..\pthread.dll tmp > nul: +copy ..\pthread.h tmp > nul: +copy ..\semaphore.h tmp > nul: +copy ..\sched.h tmp > nul: +copy test.h tmp > nul: +copy ..\pthread.lib tmp > nul: +REM copy ..\libpthread32.a tmp > nul: + +cd tmp + +REM Compile the test case +REM produces aout.exe using the compiler given as %1 +call ..\c%1.bat %2 > ..\%2.%1log + +if ERRORLEVEL 1 goto cleanup + +REM erase ..\%2.%1log + +echo TEST: %2 [%1] + +REM Run the test case +if EXIST %2.pass erase %2.pass +if EXIST %2.fail erase %2.fail +if EXIST %2.notrun erase %2.notrun +aout.exe %4 %5 %6 %7 %8 %9 + +set RESULT=1 +if ERRORLEVEL 0 set RESULT=0 + +REM set RESULT=%ERRORLEVEL% + +if %RESULT%==0 goto passed +echo Failed [%RESULT%] > ..\%2.fail +goto cleanup + +:passed +echo Passed > ..\%2.pass + +:cleanup + +cd .. + +REM Clean up +if not exist tmp\*.* goto skip2 +echo y | erase tmp\*.* > nul: +:skip2 + +if EXIST %2.fail echo Failed [%RESULT%] +if EXIST %2.pass echo Passed [%RESULT%] + +:bypass +goto end + +:needprereq +echo Test %2 requires %3 to pass before it can run. +echo No Prereq > ..\%2.notrun +goto end + +:end -- cgit v1.2.3