summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorrpj <rpj>2000-12-29 07:08:44 +0000
committerrpj <rpj>2000-12-29 07:08:44 +0000
commit0c2cb3fb140fb0d12586587001cb1ca238cf8c25 (patch)
tree72caf359f0e3d2aea2c833c8061b65f971f91381 /tests
parentbab1896412f2d292ebd8d44bc9d6ddb58a8702b0 (diff)
./ChangeLog:
2000-12-29 Ross Johnson <rpj@special.ise.canberra.edu.au> * Makefile: Back-out "for" loops which don't work. * GNUmakefile: Remove the fake.a target; add the "realclean" target; don't remove built libs under the "clean" target. * config.h: Add a guard against multiple inclusion. * semaphore.h: Add some defines from config.h to make semaphore.h independent of config.h when building apps. * pthread.h (_errno): Back-out previous fix until we know how to fix it properly. * implement.h (lockCount): Add missing element to pthread_mutex_t_. * sync.c (pthread_join): Spelling fix in comment. * private.c (ptw32_threadStart): Reset original termination function (C++). (ptw32_threadStart): Cleanup detached threads early in case the library is statically linked. (ptw32_callUserDestroyRoutines): Remove [SEH] __try block from destructor call so that unhandled exceptions will be passed through to the system; call terminate() from [C++] try block for the same reason. * tsd.c (pthread_getspecific): Add comment. * mutex.c (pthread_mutex_init): Initialise new elements in pthread_mutex_t. (pthread_mutex_unlock): Invert "pthread_equal()" test. 2000-12-28 Ross Johnson <rpj@special.ise.canberra.edu.au> * semaphore.c (mode_t): Use ifndef HAVE_MODE_T to include definition. * config.h.in (HAVE_MODE_T): Added. (_UWIN): Start adding defines for the UWIN package. ./tests/ChangeLog: 2000-12-29 Ross Johnson <rpj@special.ise.canberra.edu.au> * GNUmakefile: Add mutex4 test; ensure libpthreadw32.a is removed for "clean" target. * Makefile: Add mutex4 test. * exception3.c: Remove SEH code; automatically pass the test under SEH (which is an N/A environment). * mutex4.c: New test. * eyal1.c (do_work_unit): Add a dummy "if" to force the optimiser to retain code; reduce thread work loads. * condvar8.c (main): Add an additional "assert" for debugging; increase pthread_cond_signal timeout.
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog17
-rw-r--r--tests/GNUmakefile5
-rw-r--r--tests/Makefile3
-rw-r--r--tests/condvar8.c8
-rw-r--r--tests/exception3.c72
-rw-r--r--tests/eyal1.c12
-rw-r--r--tests/mutex4.c34
7 files changed, 62 insertions, 89 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index db66602..92fca1b 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,20 @@
+2000-12-29 Ross Johnson <rpj@special.ise.canberra.edu.au>
+
+ * GNUmakefile: Add mutex4 test; ensure libpthreadw32.a is
+ removed for "clean" target.
+ * Makefile: Add mutex4 test.
+
+ * exception3.c: Remove SEH code; automatically pass the test
+ under SEH (which is an N/A environment).
+
+ * mutex4.c: New test.
+
+ * eyal1.c (do_work_unit): Add a dummy "if" to force the
+ optimiser to retain code; reduce thread work loads.
+
+ * condvar8.c (main): Add an additional "assert" for debugging;
+ increase pthread_cond_signal timeout.
+
2000-12-28 Ross Johnson <rpj@special.ise.canberra.edu.au>
* eyal1.c: Increase thread work loads.
diff --git a/tests/GNUmakefile b/tests/GNUmakefile
index 7b4fd64..33de3ac 100644
--- a/tests/GNUmakefile
+++ b/tests/GNUmakefile
@@ -32,7 +32,7 @@ COPYFILES = $(HDR) $(LIB) $(DLL)
TESTS = loadfree \
mutex1 condvar1 condvar2 exit1 create1 equal1 \
exit2 exit3 \
- join0 join1 join2 mutex2 mutex3 \
+ join0 join1 join2 mutex2 mutex3 mutex4 \
count1 once1 tsd1 self1 self2 cancel1 cancel2 eyal1 \
condvar3 condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \
errno1 \
@@ -57,6 +57,7 @@ create1.pass: mutex2.pass
cancel1.pass: create1.pass
cancel2.pass: cancel1.pass
mutex3.pass: create1.pass
+mutex4.pass: mutex3.pass
equal1.pass: create1.pass
exit2.pass: create1.pass
exit3.pass: create1.pass
@@ -122,7 +123,7 @@ clean:
- $(RM) pthread.h
- $(RM) semaphore.h
- $(RM) sched.h
- - $(RM) *.a
+ - $(RM) libpthreadw32.a
- $(RM) *.e
- $(RM) *.obj
- $(RM) *.pdb
diff --git a/tests/Makefile b/tests/Makefile
index 208b438..281cd50 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -33,7 +33,7 @@ EHFLAGS =
# stop.
PASSES= loadfree.pass \
- mutex1.pass mutex2.pass mutex3.pass \
+ mutex1.pass mutex2.pass mutex3.pass mutex4.pass \
condvar1.pass condvar2.pass \
exit1.pass create1.pass equal1.pass \
exit2.pass exit3.pass \
@@ -112,6 +112,7 @@ create1.pass: mutex2.pass
cancel1.pass: create1.pass
cancel2.pass: cancel1.pass
mutex3.pass: create1.pass
+mutex4.pass: mutex3.pass
equal1.pass: create1.pass
exit2.pass: create1.pass
exit3.pass: create1.pass
diff --git a/tests/condvar8.c b/tests/condvar8.c
index 9e63b79..ff893c7 100644
--- a/tests/condvar8.c
+++ b/tests/condvar8.c
@@ -93,10 +93,6 @@ mythread(void * arg)
assert(pthread_mutex_lock(&cvthing.lock) == 0);
- /*
- * pthread_cond_timedwait is a cancelation point and we
- * going to cancel one deliberately.
- */
pthread_cleanup_push(pthread_mutex_unlock, (void *) &cvthing.lock);
while (! (cvthing.shared > 0))
@@ -135,7 +131,7 @@ main()
abstime.tv_sec = currSysTime.time;
abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
- abstime.tv_sec += 5;
+ abstime.tv_sec += 10;
assert((t[0] = pthread_self()) != NULL);
@@ -179,6 +175,8 @@ main()
* Give threads time to complete.
*/
Sleep(1000);
+
+ assert(awoken == (i - 1));
}
diff --git a/tests/exception3.c b/tests/exception3.c
index b820b4b..66f4173 100644
--- a/tests/exception3.c
+++ b/tests/exception3.c
@@ -39,17 +39,16 @@
* - Process returns non-zero exit status.
*/
+#include "test.h"
+
+#if defined(__cplusplus)
-#if defined(_MSC_VER) && defined(__cplusplus)
+#if defined(_MSC_VER)
#include <eh.h>
#else
#include <new.h>
#endif
-#if defined(_MSC_VER) || defined(__cplusplus)
-
-#include "test.h"
-
/*
* Create NUMTHREADS threads in addition to the Main thread.
*/
@@ -60,28 +59,12 @@ enum {
int caught = 0;
pthread_mutex_t caughtLock = PTHREAD_MUTEX_INITIALIZER;
-#if defined(_MSC_VER) && !defined(__cplusplus)
-
-LONG unhandledExceptionFilter (EXCEPTION_POINTERS *ep)
-{
- if (ep->ExceptionRecord->ExceptionCode == 0x1)
- {
- pthread_mutex_lock(&caughtLock);
- caught++;
- pthread_mutex_unlock(&caughtLock);
- }
-
- return EXCEPTION_CONTINUE_EXECUTION;
-}
-
-#elif defined(__cplusplus)
-
void
terminateFunction ()
{
pthread_mutex_lock(&caughtLock);
caught++;
-#if 1
+#if 0
{
FILE * fp = fopen("pthread.log", "a");
fprintf(fp, "Caught = %d\n", caught);
@@ -92,28 +75,15 @@ terminateFunction ()
pthread_exit((void *) 0);
}
-#endif
-
void *
exceptionedThread(void * arg)
{
int dummy = 0x1;
- {
-#if defined(_MSC_VER) && !defined(__cplusplus)
+ (void) set_terminate(&terminateFunction);
+ throw dummy;
- RaiseException(dummy, 0, 0, NULL);
-
-#elif defined(__cplusplus)
-
- (void) set_terminate(&terminateFunction);
-
- throw dummy;
-
-#endif
- }
-
- return (void *) 100;
+ return (void *) 0;
}
int
@@ -125,25 +95,13 @@ main()
assert((mt = pthread_self()) != NULL);
- {
-#if defined(_MSC_VER) && !defined(__cplusplus)
- LPTOP_LEVEL_EXCEPTION_FILTER oldHandler;
- oldHandler = SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) unhandledExceptionFilter);
-#endif
-
- for (i = 0; i < NUMTHREADS; i++)
- {
- assert(pthread_create(&et[i], NULL, exceptionedThread, NULL) == 0);
- }
-
-#if defined(_MSC_VER) && !defined(__cplusplus)
- (void) SetUnhandledExceptionFilter(oldHandler);
-#endif
+ for (i = 0; i < NUMTHREADS; i++)
+ {
+ assert(pthread_create(&et[i], NULL, exceptionedThread, NULL) == 0);
+ }
- Sleep(30000);
- }
+ Sleep(10000);
- printf("Caught = %d\n", caught);
assert(caught == NUMTHREADS);
/*
@@ -152,7 +110,7 @@ main()
return 0;
}
-#else /* defined(_MSC_VER) || defined(__cplusplus) */
+#else /* defined(__cplusplus) */
int
main()
@@ -161,4 +119,4 @@ main()
return 0;
}
-#endif /* defined(_MSC_VER) || defined(__cplusplus) */
+#endif /* defined(__cplusplus) */
diff --git a/tests/eyal1.c b/tests/eyal1.c
index a9ba909..6954c3b 100644
--- a/tests/eyal1.c
+++ b/tests/eyal1.c
@@ -63,7 +63,7 @@ typedef struct thread_control TC;
static TC *tcs = NULL;
static int nthreads = 10;
-static int nwork = 1000;
+static int nwork = 100;
static int quiet = 0;
static int todo = -1;
@@ -86,7 +86,7 @@ die (int ret)
}
-static void
+static double
waste_time (int n)
{
int i;
@@ -98,6 +98,7 @@ waste_time (int n)
{
f = 2 * f * f / (f * f);
}
+ return f;
}
static int
@@ -105,6 +106,7 @@ do_work_unit (int who, int n)
{
int i;
static int nchars = 0;
+ double f = 0.0;
if (quiet)
i = 0;
@@ -131,7 +133,11 @@ do_work_unit (int who, int n)
}
n = rand () % 10000; /* ignore incoming 'n' */
- waste_time (n);
+ f = waste_time (n);
+
+ /* This prevents the statement above from being optimised out */
+ if (f > 0.0)
+ return(n);
return (n);
}
diff --git a/tests/mutex4.c b/tests/mutex4.c
index 5290f2a..7b989d0 100644
--- a/tests/mutex4.c
+++ b/tests/mutex4.c
@@ -10,35 +10,32 @@
*/
#include "test.h"
-
-pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t locker_done = PTHREAD_MUTEX_INITIALIZER;
-pthread_mutex_t unlocker_done = PTHREAD_MUTEX_INITIALIZER;
-static int washere = 0;
+static int wasHere = 0;
+
+static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
void * locker(void * arg)
{
- assert(pthread_mutex_lock(&locker_start) == 0);
+ wasHere++;
assert(pthread_mutex_lock(&mutex1) == 0);
- assert(pthread_mutex_unlock(&locker_start) == 0);
-
- /* Wait for unlocker to finish */
- assert(pthread_mutex_lock(&unlocker_end) == 0);
+ Sleep(1000);
assert(pthread_mutex_unlock(&mutex1) == 0);
+ wasHere++;
return 0;
}
void * unlocker(void * arg)
{
+ wasHere++;
+
/* Wait for locker to lock mutex1 */
- assert(pthread_mutex_lock(&unlocker_start) == 0);
+ Sleep(500);
assert(pthread_mutex_unlock(&mutex1) == EPERM);
- assert(pthread_mutex_unlock(&unlocker_start) == 0);
-
+ wasHere++;
return 0;
}
@@ -47,16 +44,11 @@ main()
{
pthread_t t;
- assert(pthread_mutex_lock(&locker_start) == 0);
- assert(pthread_mutex_lock(&unlocker_start) == 0);
-
assert(pthread_create(&t, NULL, locker, NULL) == 0);
- assert(pthread_mutex_unlock(&locker_start) == 0);
- Sleep(0);
-
assert(pthread_create(&t, NULL, unlocker, NULL) == 0);
- assert(pthread_mutex_unlock(&unlocker_start) == 0);
- Sleep(0);
+ Sleep(2000);
+
+ assert(wasHere == 4);
return 0;
}