summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog28
-rw-r--r--tests/GNUmakefile19
-rw-r--r--tests/Makefile26
-rw-r--r--tests/exception3.c45
-rw-r--r--tests/rwlock1.c4
-rw-r--r--tests/rwlock6.c20
6 files changed, 111 insertions, 31 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index afd2cbb..663db9b 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,33 @@
+2002-02-28 Ross Johnson <rpj@special.ise.canberra.edu.au>
+
+ * exception3.c (terminateFunction): For MSVC++, call
+ exit() rather than pthread_exit(). Add comments to explain
+ why.
+ * Notes from the MSVC++ manual:
+ * 1) A term_func() should call exit(), otherwise
+ * abort() will be called on return to the caller.
+ * abort() raises SIGABRT. The default signal handler
+ * for all signals terminates the calling program with
+ * exit code 3.
+ * 2) A term_func() must not throw an exception. Therefore
+ * term_func() should not call pthread_exit() if an
+ * an exception-using version of pthreads-win32 library
+ * is being used (i.e. either pthreadVCE or pthreadVSE).
+
+
2002-02-23 Ross Johnson <rpj@special.ise.canberra.edu.au>
+ * rwlock2_t.c: New test.
+ * rwlock3_t.c: New test.
+ * rwlock4_t.c: New test.
+ * rwlock5_t.c: New test.
+ * rwlock6_t.c: New test.
+ * rwlock6_t2.c: New test.
+ * rwlock6.c (main): Swap thread and result variables
+ to correspond to actual thread functions.
+ * rwlock1.c: Change test description comment to correspond
+ to the actual test.
+
* condvar1_2.c: Loop over the test many times in the hope
of detecting any intermittent deadlocks. This is to
test a fixed problem in pthread_cond_destroy.c.
diff --git a/tests/GNUmakefile b/tests/GNUmakefile
index 9e6cf89..800d33a 100644
--- a/tests/GNUmakefile
+++ b/tests/GNUmakefile
@@ -77,6 +77,7 @@ TESTS = loadfree \
condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \
errno1 \
rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 rwlock7 \
+ rwlock2_t rwlock3_t rwlock4_t rwlock5_t rwlock6_t rwlock6_t2 \
context1 cancel3 cancel4 cancel5 cancel6a cancel6d \
cleanup0 cleanup1 cleanup2 cleanup3 \
priority1 priority2 inherit1 \
@@ -91,17 +92,18 @@ BENCHTESTS = \
PASSES = $(TESTS:%=%.pass)
BENCHRESULTS = $(BENCHTESTS:%=%.bench)
-default:
+help:
@ $(ECHO) Run one of the following command lines:
- @ $(ECHO) nmake clean GCE (to test using GCE dll with C++ (EH) applications)
@ $(ECHO) nmake clean GC (to test using GC dll with C (no EH) applications)
@ $(ECHO) nmake clean GCX (to test using GC dll with C++ (EH) applications)
- @ $(ECHO) nmake clean GCE-bench (to benchtest using GNU C dll with C++ exception handling)
+ @ $(ECHO) nmake clean GCE (to test using GCE dll with C++ (EH) applications)
@ $(ECHO) nmake clean GC-bench (to benchtest using GNU C dll with C cleanup code)
+ @ $(ECHO) nmake clean GCE-bench (to benchtest using GNU C dll with C++ exception handling)
-auto:
- @ $(MAKE) clean GCE
+all:
@ $(MAKE) clean GC
+ @ $(MAKE) clean GCX
+ @ $(MAKE) clean GCE
GC:
$(MAKE) GCX=GC XXCFLAGS="-x c -D__CLEANUP_C" all-pass
@@ -212,6 +214,12 @@ rwlock4.pass: rwlock3.pass
rwlock5.pass: rwlock4.pass
rwlock6.pass: rwlock5.pass
rwlock7.pass: rwlock6.pass
+rwlock2_t.pass: rwlock2.pass
+rwlock3_t.pass: rwlock2_t.pass
+rwlock4_t.pass: rwlock3_t.pass
+rwlock5_t.pass: rwlock4_t.pass
+rwlock6_t.pass: rwlock5_t.pass
+rwlock6_t2.pass: rwlock6_t.pass
self1.pass:
self2.pass: create1.pass
spin1.pass:
@@ -264,3 +272,4 @@ clean:
- $(RM) *.exe
- $(RM) *.pass
- $(RM) *.bench
+ - $(RM) *.log
diff --git a/tests/Makefile b/tests/Makefile
index 9532b41..00e886f 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -40,7 +40,7 @@ ECHO = @echo
CPHDR = pthread.h semaphore.h sched.h
-OPTIM = /O2
+OPTIM = /O2 /Ob0
# C++ Exceptions
VCEFLAGS = /GX /TP /DPtW32NoCatchWarn /D__CLEANUP_CXX
@@ -89,6 +89,7 @@ PASSES= loadfree.pass \
condvar7.pass condvar8.pass condvar9.pass \
errno1.pass \
rwlock1.pass rwlock2.pass rwlock3.pass rwlock4.pass rwlock5.pass rwlock6.pass rwlock7.pass \
+ rwlock2_t.pass rwlock3_t.pass rwlock4_t.pass rwlock5_t.pass rwlock6_t.pass rwlock6_t2.pass \
context1.pass \
cancel3.pass cancel4.pass cancel5.pass cancel6a.pass cancel6d.pass \
cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \
@@ -101,22 +102,22 @@ PASSES= loadfree.pass \
BENCHRESULTS = \
benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench
-all:
+help:
@ $(ECHO) Run one of the following command lines:
- @ $(ECHO) nmake clean VCE (to test using the VCE dll with VC++ EH applications)
- @ $(ECHO) nmake clean VSE (to test using VSE dll with VC (SEH) applications)
@ $(ECHO) nmake clean VC (to test using VC dll with VC (no EH) applications)
@ $(ECHO) nmake clean VCX (to test using VC dll with VC++ (EH) applications)
- @ $(ECHO) nmake clean VCE-bench (to benchtest using VCE dll with C++ bench app)
- @ $(ECHO) nmake clean VSE-bench (to benchtest using VSE dll with SEH bench app)
+ @ $(ECHO) nmake clean VCE (to test using the VCE dll with VC++ EH applications)
+ @ $(ECHO) nmake clean VSE (to test using VSE dll with VC (SEH) applications)
@ $(ECHO) nmake clean VC-bench (to benchtest using VC dll with C bench app)
@ $(ECHO) nmake clean VCX-bench (to benchtest using VC dll with C++ bench app)
+ @ $(ECHO) nmake clean VCE-bench (to benchtest using VCE dll with C++ bench app)
+ @ $(ECHO) nmake clean VSE-bench (to benchtest using VSE dll with SEH bench app)
-auto:
- @ nmake clean VCE
- @ nmake clean VSE
+all:
@ nmake clean VC
@ nmake clean VCX
+ @ nmake clean VCE
+ @ nmake clean VSE
@ nmake clean VC-bench
tests: $(CPLIB) $(CPDLL) $(CPHDR) $(PASSES)
@@ -190,6 +191,7 @@ clean:
- $(RM) *.exe
- $(RM) *.pass
- $(RM) *.bench
+ - $(RM) *.log
benchtest1.bench:
benchtest2.bench:
@@ -277,6 +279,12 @@ rwlock4.pass: rwlock3.pass
rwlock5.pass: rwlock4.pass
rwlock6.pass: rwlock5.pass
rwlock7.pass: rwlock6.pass
+rwlock2_t.pass: rwlock2.pass
+rwlock3_t.pass: rwlock2_t.pass
+rwlock4_t.pass: rwlock3_t.pass
+rwlock5_t.pass: rwlock4_t.pass
+rwlock6_t.pass: rwlock5_t.pass
+rwlock6_t2.pass: rwlock6_t.pass
self1.pass:
self2.pass: create1.pass
spin1.pass:
diff --git a/tests/exception3.c b/tests/exception3.c
index 5faa3e1..3d9ea86 100644
--- a/tests/exception3.c
+++ b/tests/exception3.c
@@ -87,16 +87,16 @@
* Create NUMTHREADS threads in addition to the Main thread.
*/
enum {
- NUMTHREADS = 20
+ NUMTHREADS = 1
};
int caught = 0;
-pthread_mutex_t caughtLock = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t caughtLock;
void
terminateFunction ()
{
- pthread_mutex_lock(&caughtLock);
+ assert(pthread_mutex_lock(&caughtLock) == 0);
caught++;
#if 1
{
@@ -105,8 +105,34 @@ terminateFunction ()
fclose(fp);
}
#endif
- pthread_mutex_unlock(&caughtLock);
- pthread_exit((void *) 0);
+ assert(pthread_mutex_unlock(&caughtLock) == 0);
+
+#if defined(__MINGW32__)
+ /*
+ * Seems to work. That is, threads exit and the process
+ * continues. Note: need to check correct POSIX behaviour.
+ * My guess is: this is because of the
+ * eh incompatibility between g++ and MSVC++. That is,
+ * an exception thrown in g++ code doesn't propogate
+ * through or to MSVC++ code, and vice versa.
+ * Applications should probably not depend on this.
+ */
+ pthread_exit((void *) 0));
+#else
+ /*
+ * Notes from the MSVC++ manual:
+ * 1) A term_func() should call exit(), otherwise
+ * abort() will be called on return to the caller.
+ * abort() raises SIGABRT. The default signal handler
+ * for all signals terminates the calling program with
+ * exit code 3.
+ * 2) A term_func() must not throw an exception. Therefore
+ * term_func() should not call pthread_exit() if an
+ * an exception-using version of pthreads-win32 library
+ * is being used (i.e. either pthreadVCE or pthreadVSE).
+ */
+ exit(0);
+#endif
}
void *
@@ -115,6 +141,7 @@ exceptionedThread(void * arg)
int dummy = 0x1;
(void) set_terminate(&terminateFunction);
+
throw dummy;
return (void *) 0;
@@ -126,9 +153,17 @@ main()
int i;
pthread_t mt;
pthread_t et[NUMTHREADS];
+ pthread_mutexattr_t ma;
assert((mt = pthread_self()) != NULL);
+ printf("See the notes inside of exception3.c re term_funcs.\n");
+
+ assert(pthread_mutexattr_init(&ma) == 0);
+ assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK) == 0);
+ assert(pthread_mutex_init(&caughtLock, &ma) == 0);
+ assert(pthread_mutexattr_destroy(&ma) == 0);
+
for (i = 0; i < NUMTHREADS; i++)
{
assert(pthread_create(&et[i], NULL, exceptionedThread, NULL) == 0);
diff --git a/tests/rwlock1.c b/tests/rwlock1.c
index 72bce85..cebb485 100644
--- a/tests/rwlock1.c
+++ b/tests/rwlock1.c
@@ -35,12 +35,10 @@
*
* --------------------------------------------------------------------------
*
- * Create a simple rwlock object, lock it, and then unlock it again.
+ * Create a simple rwlock object and then destroy it.
*
* Depends on API functions:
* pthread_rwlock_init()
- * pthread_rwlock_lock()
- * pthread_rwlock_unlock()
* pthread_rwlock_destroy()
*/
diff --git a/tests/rwlock6.c b/tests/rwlock6.c
index 78fd7b3..86bedff 100644
--- a/tests/rwlock6.c
+++ b/tests/rwlock6.c
@@ -35,9 +35,9 @@
*
* --------------------------------------------------------------------------
*
- * Check that writer locks have priority.
+ * Check writer and reader locking
*
- * Depends on API functions:
+ * Depends on API functions:
* pthread_rwlock_rdlock()
* pthread_rwlock_wrlock()
* pthread_rwlock_unlock()
@@ -51,23 +51,25 @@ static int bankAccount = 0;
void * wrfunc(void * arg)
{
+ int ba;
+
assert(pthread_rwlock_wrlock(&rwlock1) == 0);
Sleep(2000);
bankAccount += 10;
+ ba = bankAccount;
assert(pthread_rwlock_unlock(&rwlock1) == 0);
- return ((void *) bankAccount);
+ return ((void *) ba);
}
void * rdfunc(void * arg)
{
- int ba = 0;
+ int ba;
assert(pthread_rwlock_rdlock(&rwlock1) == 0);
ba = bankAccount;
assert(pthread_rwlock_unlock(&rwlock1) == 0);
- ba += 10;
return ((void *) ba);
}
@@ -85,17 +87,17 @@ main()
assert(pthread_create(&wrt1, NULL, wrfunc, NULL) == 0);
Sleep(500);
- assert(pthread_create(&wrt2, NULL, rdfunc, NULL) == 0);
+ assert(pthread_create(&rdt, NULL, rdfunc, NULL) == 0);
Sleep(500);
- assert(pthread_create(&rdt, NULL, wrfunc, NULL) == 0);
+ assert(pthread_create(&wrt2, NULL, wrfunc, NULL) == 0);
assert(pthread_join(wrt1, (void **) &wr1Result) == 0);
- assert(pthread_join(wrt2, (void **) &wr2Result) == 0);
assert(pthread_join(rdt, (void **) &rdResult) == 0);
+ assert(pthread_join(wrt2, (void **) &wr2Result) == 0);
assert(wr1Result == 10);
+ assert(rdResult == 10);
assert(wr2Result == 20);
- assert(rdResult == 20);
return 0;
}