summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog40
-rw-r--r--tests/GNUmakefile46
-rw-r--r--tests/Makefile34
-rw-r--r--tests/cancel3.c71
-rw-r--r--tests/cancel4.c12
-rw-r--r--tests/cancel5.c62
-rw-r--r--tests/cancel6a.c12
-rw-r--r--tests/cancel6d.c12
8 files changed, 141 insertions, 148 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 667747f..e62c257 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,21 +1,35 @@
+2004-05-16 Ross Johnson <rpj@callisto.canberra.edu.au>
+
+ * cancel9.c: New test.
+ * cancel3.c: Remove inappropriate conditional compilation;
+ GNU C version of test suite no longer quietly skips this test.
+ * cancel5.c: Likewise.
+ * GNUmakefile: Can now build individual test app using default
+ C version of library using 'make clean testname.c'.
+ * Makefile: Likewise for VC using 'nmake clean test testname.c'.
+
+2003-10-14 Ross Johnson <rpj@callisto.canberra.edu.au>
+
+ * Wmakefile: New makefile for Watcom testing.
+
2003-09-18 Ross Johnson <rpj@callisto.canberra.edu.au>
- * benchtest.h: Move old mutex code into benchlib.c.
- * benchlib.c: New statically linked module to ensure that
- bench apps don't inline the code and therefore have an unfair
- advantage over the pthreads lib routines. Made little or no
- difference.
- * benchtest1.c: Minor change to avoid compiler warnings.
- * benchtest5.c: Likewise.
- * benchtest2.c: Fix misinformation in output report.
- * README.BENCH: Add comments on results.
+ * benchtest.h: Move old mutex code into benchlib.c.
+ * benchlib.c: New statically linked module to ensure that
+ bench apps don't inline the code and therefore have an unfair
+ advantage over the pthreads lib routines. Made little or no
+ difference.
+ * benchtest1.c: Minor change to avoid compiler warnings.
+ * benchtest5.c: Likewise.
+ * benchtest2.c: Fix misinformation in output report.
+ * README.BENCH: Add comments on results.
2003-09-14 Ross Johnson <rpj@callisto.canberra.edu.au>
- * priority1.c: Reworked to comply with modified priority
- management and provide additional output.
- * priority2.c: Likewise.
- * inherit1.c: Likewise.
+ * priority1.c: Reworked to comply with modified priority
+ management and provide additional output.
+ * priority2.c: Likewise.
+ * inherit1.c: Likewise.
2003-09-03 Ross Johnson <rpj@callisto.canberra.edu.au>
diff --git a/tests/GNUmakefile b/tests/GNUmakefile
index 7ed1c85..a7c8079 100644
--- a/tests/GNUmakefile
+++ b/tests/GNUmakefile
@@ -35,9 +35,11 @@
CP = cp -f
MV = mv -f
RM = rm -f
+CAT = cat
#CP = copy
#MV = rename
#RM = erase
+#CAT = type
MKDIR = mkdir
TOUCH = echo Passed >
ECHO = @echo
@@ -47,18 +49,22 @@ MAKE = make
# Mingw32
#
XXCFLAGS =
-XXLIBS =
+XXLIBS = -lws2_32
CFLAGS = -O3 -UNDEBUG -Wall $(XXCFLAGS)
#CFLAGS = -g -O0 -UNDEBUG -Wall $(XXCFLAGS)
BUILD_DIR = ..
INCLUDES = -I.
-GCX = DUMMY
+# Default lib version
+GCX = GC
+# Files we need to run the tests
+# - paths are relative to pthreads build dir.
HDR = pthread.h semaphore.h sched.h
LIB = libpthread$(GCX).a
DLL = pthread$(GCX).dll
+QAPC = ../QueueUserAPCEx/User/quserex.dll
-COPYFILES = $(HDR) $(LIB) $(DLL)
+COPYFILES = $(HDR) $(LIB) $(DLL) $(QAPC)
# If a test case returns a non-zero exit code to the shell, make will
# stop.
@@ -85,7 +91,8 @@ TESTS = sizes loadfree \
priority1 priority2 inherit1 \
spin1 spin2 spin3 spin4 \
barrier1 barrier2 barrier3 barrier4 barrier5 \
- exception1 exception2 exception3
+ exception1 exception2 exception3 \
+ cancel9
BENCHTESTS = \
benchtest1 benchtest2 benchtest3 benchtest4 benchtest5
@@ -240,30 +247,37 @@ spin4.pass: spin3.pass
tsd1.pass: join1.pass
valid1.pass: join1.pass
valid2.pass: valid1.pass
+cancel9.pass: cancel8.pass
-#%.pass: %.exe $(HDR)
-%.pass: %.exe $(LIB) $(DLL) $(HDR)
+sizes.pass: sizes.exe
+ @ $(ECHO) Running $*
+ $< > SIZES.$(GCX)
+ @ $(CAT) SIZES.$(GCX)
+ @ $(ECHO) Passed
+ @ $(TOUCH) $@
+
+%.pass: %.exe
@ $(ECHO) Running $*
$*
@ $(ECHO) Passed
@ $(TOUCH) $@
-%.bench: $(LIB) $(DLL) $(HDR) $(XXLIBS) %.exe
+%.bench: $(XXLIBS) %.exe
@ $(ECHO) Running $*
$*
@ $(ECHO) Done
@ $(TOUCH) $@
-%.exe: %.c
+%.exe: %.c $(LIB) $(DLL) $(HDR) $(QAPC)
@ $(ECHO) Compiling $@
- @ $(ECHO) $(CC) $(CFLAGS) -o $@ $^ $(INCLUDES) -L. -lpthread$(GCX) -lsupc++ $(XXLIBS)
- @ $(CC) $(CFLAGS) -o $@ $^ $(INCLUDES) -L. -lpthread$(GCX) -lsupc++ $(XXLIBS)
+ @ $(ECHO) $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L. -lpthread$(GCX) -lsupc++ $(XXLIBS)
+ @ $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L. -lpthread$(GCX) -lsupc++ $(XXLIBS)
-%.pre: %.c
- @ $(CC) -E $(CFLAGS) -o $@ $^ $(INCLUDES)
+%.pre: %.c $(HDR)
+ @ $(CC) -E $(CFLAGS) -o $@ $< $(INCLUDES)
-%.s: %.c
- @ $(CC) -S $(CFLAGS) -o $@ $^ $(INCLUDES)
+%.s: %.c $(HDR)
+ @ $(CC) -S $(CFLAGS) -o $@ $< $(INCLUDES)
$(COPYFILES):
@ $(ECHO) Copying $@
@@ -274,8 +288,8 @@ pthread.dll:
benchlib.o: benchlib.c
@ $(ECHO) Compiling $@
- @ $(ECHO) $(CC) -c $(CFLAGS) $^ $(INCLUDES)
- @ $(CC) -c $(CFLAGS) $^ $(INCLUDES)
+ @ $(ECHO) $(CC) -c $(CFLAGS) $< $(INCLUDES)
+ @ $(CC) -c $(CFLAGS) $< $(INCLUDES)
clean:
- $(RM) *.dll
diff --git a/tests/Makefile b/tests/Makefile
index 210b8a1..17cb0c8 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -34,15 +34,18 @@
CP = copy
RM = erase
+CAT = type
MKDIR = mkdir
TOUCH = echo Passed >
ECHO = @echo
+QAPC = ..\QueueUserAPCEx\User\quserex.dll
+
CPHDR = pthread.h semaphore.h sched.h
OPTIM = /O2 /Ob0
-XXLIBS =
+XXLIBS = ws2_32.lib
# C++ Exceptions
VCEFLAGS = /GX /TP /DPtW32NoCatchWarn /D__CLEANUP_CXX
@@ -59,12 +62,16 @@ VCDLL = pthreadVC.dll
# C++ Exceptions in application - using VC version of pthreads dll
VCXFLAGS = /GX /TP /D__CLEANUP_C
+# Defaults
+CPLIB = pthreadVC.lib
+CPDLL = pthreadVC.dll
+
CFLAGS= $(OPTIM) /W3 /WX /MD /nologo /Yd /Zi -D_WIN32_WINNT=0x400
LFLAGS= /INCREMENTAL:NO
INCLUDES=-I.
BUILD_DIR=..
-COPYFILES = $(CPHDR) $(CPLIB) $(CPDLL)
+COPYFILES = $(CPHDR) $(CPLIB) $(CPDLL) $(QAPC)
TEST =
EHFLAGS =
@@ -100,7 +107,8 @@ PASSES= sizes.pass loadfree.pass \
priority1.pass priority2.pass inherit1.pass \
spin1.pass spin2.pass spin3.pass spin4.pass \
barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass \
- exception1.pass exception2.pass exception3.pass
+ exception1.pass exception2.pass exception3.pass \
+ cancel9
BENCHRESULTS = \
benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench
@@ -123,12 +131,23 @@ all:
@ nmake clean VSE
@ nmake clean VC-bench
-tests: $(CPLIB) $(CPDLL) $(CPHDR) $(PASSES)
+# This allows an individual test application to be made using the default lib.
+# e.g. nmake clean test cancel3.exe
+test: $(CPLIB) $(CPDLL) $(CPHDR) $(QAPC)
+
+tests: $(CPLIB) $(CPDLL) $(CPHDR) $(QAPC) $(PASSES)
@ $(ECHO) ALL TESTS PASSED! Congratulations!
benchtests: $(CPLIB) $(CPDLL) $(CPHDR) $(XXLIBS) $(BENCHRESULTS)
@ $(ECHO) ALL BENCH TESTS DONE.
+sizes.pass: sizes.exe
+ @ $(ECHO) ... Running $(TEST) test: $*.exe
+ @ .\$*.exe > SIZES.$(TEST)
+ @ $(CAT) SIZES.$(TEST)
+ @ $(ECHO) ...... Passed
+ @ $(TOUCH) $*.pass
+
$(PASSES): $*.exe
@ $(ECHO) ... Running $(TEST) test: $*.exe
@ .\$*.exe
@@ -180,9 +199,9 @@ $(COPYFILES):
@ $(ECHO) Copying $@
@ $(CP) $(BUILD_DIR)\$@ .
-pthread.dll:
- @ $(CP) $(CPDLL) $*.dll
- @ $(CP) $(CPLIB) $*.lib
+pthread.dll: $(CPDLL)
+ @ $(CP) $(CPDLL) pthread.dll
+ @ $(CP) $(CPLIB) pthread.lib
clean:
- $(RM) *.dll
@@ -312,3 +331,4 @@ spin4.pass: spin3.pass
tsd1.pass: join1.pass
valid1.pass: join1.pass
valid2.pass: valid1.pass
+cancel9.pass: cancel8.pass
diff --git a/tests/cancel3.c b/tests/cancel3.c
index ed1df0f..c3657d6 100644
--- a/tests/cancel3.c
+++ b/tests/cancel3.c
@@ -33,13 +33,13 @@
*
* --------------------------------------------------------------------------
*
- * Test Synopsis: Test asynchronous cancelation.
+ * Test Synopsis: Test asynchronous cancelation (alertable or non-alertable).
*
* Test Method (Validation or Falsification):
* -
*
* Requirements Tested:
- * -
+ * - Async cancel if thread is not blocked (i.e. voluntarily resumes if blocked).
*
* Features Tested:
* -
@@ -62,7 +62,8 @@
*
* Assumptions:
* - have working pthread_create, pthread_self, pthread_mutex_lock/unlock
- * pthread_testcancel, pthread_cancel, pthread_join
+ * pthread_testcancel, pthread_cancel, pthread_join.
+ * - quserex.dll and alertdrv.sys are not available.
*
* Pass Criteria:
* - Process returns zero exit status.
@@ -71,19 +72,19 @@
* - Process returns non-zero exit status.
*/
-#if defined(_MSC_VER) || defined(__cplusplus)
-
#include "test.h"
/*
* Create NUMTHREADS threads in addition to the Main thread.
*/
-enum {
+enum
+{
NUMTHREADS = 4
};
typedef struct bag_t_ bag_t;
-struct bag_t_ {
+struct bag_t_
+{
int threadnum;
int started;
/* Add more per-thread state variables here */
@@ -93,75 +94,77 @@ struct bag_t_ {
static bag_t threadbag[NUMTHREADS + 1];
void *
-mythread(void * arg)
+mythread (void *arg)
{
- int result = ((int)PTHREAD_CANCELED + 1);
- bag_t * bag = (bag_t *) arg;
+ int result = ((int) PTHREAD_CANCELED + 1);
+ bag_t *bag = (bag_t *) arg;
- assert(bag == &threadbag[bag->threadnum]);
- assert(bag->started == 0);
+ assert (bag == &threadbag[bag->threadnum]);
+ assert (bag->started == 0);
bag->started = 1;
/* Set to known state and type */
- assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0);
+ assert (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) == 0);
- assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0);
+ assert (pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0);
/*
* We wait up to 10 seconds, waking every 0.1 seconds,
* for a cancelation to be applied to us.
*/
for (bag->count = 0; bag->count < 100; bag->count++)
- Sleep(100);
+ Sleep (100);
return (void *) result;
}
int
-main()
+main ()
{
int failed = 0;
int i;
pthread_t t[NUMTHREADS + 1];
- assert((t[0] = pthread_self()) != NULL);
+ assert ((t[0] = pthread_self ()) != NULL);
for (i = 1; i <= NUMTHREADS; i++)
{
threadbag[i].started = 0;
threadbag[i].threadnum = i;
- assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0);
+ assert (pthread_create (&t[i], NULL, mythread, (void *) &threadbag[i])
+ == 0);
}
/*
* Code to control or munipulate child threads should probably go here.
*/
- Sleep(500);
+ Sleep (500);
for (i = 1; i <= NUMTHREADS; i++)
{
- assert(pthread_cancel(t[i]) == 0);
+ assert (pthread_cancel (t[i]) == 0);
}
/*
* Give threads time to run.
*/
- Sleep(NUMTHREADS * 100);
+ Sleep (NUMTHREADS * 100);
/*
* Standard check that all threads started.
*/
for (i = 1; i <= NUMTHREADS; i++)
- {
+ {
if (!threadbag[i].started)
{
failed |= !threadbag[i].started;
- fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started);
+ fprintf (stderr, "Thread %d: started %d\n", i,
+ threadbag[i].started);
}
}
- assert(!failed);
+ assert (!failed);
/*
* Check any results here. Set "failed" and only print output on failure.
@@ -177,34 +180,22 @@ main()
* a return value of PTHREAD_CANCELED confirms that async
* cancelation succeeded.
*/
- assert(pthread_join(t[i], (void **) &result) == 0);
+ assert (pthread_join (t[i], (void **) &result) == 0);
fail = (result != (int) PTHREAD_CANCELED);
if (fail)
{
- fprintf(stderr, "Thread %d: started %d: count %d\n",
- i,
- threadbag[i].started,
- threadbag[i].count);
+ fprintf (stderr, "Thread %d: started %d: count %d\n",
+ i, threadbag[i].started, threadbag[i].count);
}
failed = (failed || fail);
}
- assert(!failed);
+ assert (!failed);
/*
* Success.
*/
return 0;
}
-
-#else /* defined(_MSC_VER) || defined(__cplusplus) */
-
-int
-main()
-{
- return 0;
-}
-
-#endif /* defined(_MSC_VER) || defined(__cplusplus) */
diff --git a/tests/cancel4.c b/tests/cancel4.c
index 3313ab4..b77f921 100644
--- a/tests/cancel4.c
+++ b/tests/cancel4.c
@@ -76,8 +76,6 @@
* - Process returns non-zero exit status.
*/
-#if defined(_MSC_VER) || defined(__cplusplus)
-
#include "test.h"
/*
@@ -203,13 +201,3 @@ main()
*/
return 0;
}
-
-#else /* defined(_MSC_VER) || defined(__cplusplus) */
-
-int
-main()
-{
- return 0;
-}
-
-#endif /* defined(_MSC_VER) || defined(__cplusplus) */
diff --git a/tests/cancel5.c b/tests/cancel5.c
index 808ab14..76d0a5a 100644
--- a/tests/cancel5.c
+++ b/tests/cancel5.c
@@ -72,19 +72,19 @@
* - Process returns non-zero exit status.
*/
-#if defined(_MSC_VER) || defined(__cplusplus)
-
#include "test.h"
/*
* Create NUMTHREADS threads in addition to the Main thread.
*/
-enum {
+enum
+{
NUMTHREADS = 4
};
typedef struct bag_t_ bag_t;
-struct bag_t_ {
+struct bag_t_
+{
int threadnum;
int started;
/* Add more per-thread state variables here */
@@ -94,33 +94,33 @@ struct bag_t_ {
static bag_t threadbag[NUMTHREADS + 1];
void *
-mythread(void * arg)
+mythread (void *arg)
{
- int result = ((int)PTHREAD_CANCELED + 1);
- bag_t * bag = (bag_t *) arg;
+ int result = ((int) PTHREAD_CANCELED + 1);
+ bag_t *bag = (bag_t *) arg;
- assert(bag == &threadbag[bag->threadnum]);
- assert(bag->started == 0);
+ assert (bag == &threadbag[bag->threadnum]);
+ assert (bag->started == 0);
bag->started = 1;
/* Set to known state and type */
- assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0);
+ assert (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) == 0);
- assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0);
+ assert (pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0);
/*
* We wait up to 10 seconds, waking every 0.1 seconds,
* for a cancelation to be applied to us.
*/
for (bag->count = 0; bag->count < 100; bag->count++)
- Sleep(100);
+ Sleep (100);
return (void *) result;
}
int
-main()
+main ()
{
int failed = 0;
int i;
@@ -130,37 +130,39 @@ main()
{
threadbag[i].started = 0;
threadbag[i].threadnum = i;
- assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0);
+ assert (pthread_create (&t[i], NULL, mythread, (void *) &threadbag[i])
+ == 0);
}
/*
* Code to control or munipulate child threads should probably go here.
*/
- Sleep(500);
+ Sleep (500);
for (i = 1; i <= NUMTHREADS; i++)
{
- assert(pthread_cancel(t[i]) == 0);
+ assert (pthread_cancel (t[i]) == 0);
}
/*
* Give threads time to run.
*/
- Sleep(NUMTHREADS * 100);
+ Sleep (NUMTHREADS * 100);
/*
* Standard check that all threads started.
*/
for (i = 1; i <= NUMTHREADS; i++)
- {
+ {
if (!threadbag[i].started)
{
failed |= !threadbag[i].started;
- fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started);
+ fprintf (stderr, "Thread %d: started %d\n", i,
+ threadbag[i].started);
}
}
- assert(!failed);
+ assert (!failed);
/*
* Check any results here. Set "failed" and only print output on failure.
@@ -176,34 +178,22 @@ main()
* a return value of PTHREAD_CANCELED confirms that async
* cancelation succeeded.
*/
- assert(pthread_join(t[i], (void **) &result) == 0);
+ assert (pthread_join (t[i], (void **) &result) == 0);
fail = (result != (int) PTHREAD_CANCELED);
if (fail)
{
- fprintf(stderr, "Thread %d: started %d: count %d\n",
- i,
- threadbag[i].started,
- threadbag[i].count);
+ fprintf (stderr, "Thread %d: started %d: count %d\n",
+ i, threadbag[i].started, threadbag[i].count);
}
failed = (failed || fail);
}
- assert(!failed);
+ assert (!failed);
/*
* Success.
*/
return 0;
}
-
-#else /* defined(_MSC_VER) || defined(__cplusplus) */
-
-int
-main()
-{
- return 0;
-}
-
-#endif /* defined(_MSC_VER) || defined(__cplusplus) */
diff --git a/tests/cancel6a.c b/tests/cancel6a.c
index 81f8d04..4aea81a 100644
--- a/tests/cancel6a.c
+++ b/tests/cancel6a.c
@@ -63,8 +63,6 @@
* - Process returns non-zero exit status.
*/
-#if defined(_MSC_VER) || defined(__cplusplus)
-
#include "test.h"
/*
@@ -191,13 +189,3 @@ main()
*/
return 0;
}
-
-#else /* defined(_MSC_VER) || defined(__cplusplus) */
-
-int
-main()
-{
- return 0;
-}
-
-#endif /* defined(_MSC_VER) || defined(__cplusplus) */
diff --git a/tests/cancel6d.c b/tests/cancel6d.c
index cdb09f5..9a69adb 100644
--- a/tests/cancel6d.c
+++ b/tests/cancel6d.c
@@ -64,8 +64,6 @@
* - Process returns non-zero exit status.
*/
-#if defined(_MSC_VER) || defined(__cplusplus)
-
#include "test.h"
/*
@@ -195,13 +193,3 @@ main()
*/
return 0;
}
-
-#else /* defined(_MSC_VER) || defined(__cplusplus) */
-
-int
-main()
-{
- return 0;
-}
-
-#endif /* defined(_MSC_VER) || defined(__cplusplus) */