summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorrpj <rpj>2003-08-13 15:10:53 +0000
committerrpj <rpj>2003-08-13 15:10:53 +0000
commit414f4bd7e70d94025576d9264c86da63c506f6ca (patch)
treeed0d8de3bd5fbccd0191b3e6cc1e0d86ebe8ff97 /tests
parent614c09bf607cf77c70c7435cd615c9f8b684bc5e (diff)
Bug fixes plus adaptation to current MinGW/MsysDTK environment. Changes to tests/benchmarks.
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog14
-rw-r--r--tests/GNUmakefile40
-rw-r--r--tests/benchtest1.c22
-rw-r--r--tests/benchtest2.c22
-rw-r--r--tests/benchtest3.c20
-rw-r--r--tests/benchtest4.c20
-rw-r--r--tests/benchtest5.c10
-rw-r--r--tests/exception2.c2
-rw-r--r--tests/exception3.c9
-rw-r--r--tests/eyal1.c14
-rw-r--r--tests/semaphore1.c4
11 files changed, 100 insertions, 77 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index b3916d2..fb52cef 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,17 @@
+2003-07-19 Ross Johnson <ross@ise.canberra.edu.au>
+
+ * eyal1.c (waste_time): Make threads do more work to ensure that
+ all threads get to do some work.
+ * semaphore1.c: Make it clear that certain errors are expected.
+ * exception2.c (non_MSVC code sections): Change to include
+ C++ standard include file, i.e. change <new.h> to <exception>.
+ * exception3.c (non_MSVC code sections): Likewise; qualify std::
+ namespace entities where necessary.
+ * GNUmakefile: modified to work in the MsysDTK (newer MinGW)
+ environment; define CC as gcc or g++ as appropriate because
+ using gcc -x c++ doesn't link with required c++ libs by default,
+ but g++ does.
+
2002-12-11 Ross Johnson <ross@special.ise.canberra.edu.au>
* mutex7e.c: Assert EBUSY return instead of EDEADLK.
diff --git a/tests/GNUmakefile b/tests/GNUmakefile
index 15b77b6..132f84b 100644
--- a/tests/GNUmakefile
+++ b/tests/GNUmakefile
@@ -32,12 +32,12 @@
#
-#CP = cp
-#MV = mv
-#RM = rm
-CP = copy
-MV = rename
-RM = erase
+CP = cp -f
+MV = mv -f
+RM = rm -f
+#CP = copy
+#MV = rename
+#RM = erase
MKDIR = mkdir
TOUCH = echo Passed >
ECHO = @echo
@@ -46,8 +46,6 @@ MAKE = make
#
# Mingw32
#
-GLANG = c++
-CC = gcc
XXCFLAGS =
CFLAGS = -O3 -UNDEBUG -Wall $(XXCFLAGS)
#CFLAGS = -g -O0 -UNDEBUG -Wall $(XXCFLAGS)
@@ -92,12 +90,12 @@ PASSES = $(TESTS:%=%.pass)
BENCHRESULTS = $(BENCHTESTS:%=%.bench)
help:
- @ $(ECHO) Run one of the following command lines:
- @ $(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 (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)
+ @ $(ECHO) "Run one of the following command lines:"
+ @ $(ECHO) "make clean GC (to test using GC dll with C (no EH) applications)"
+ @ $(ECHO) "make clean GCX (to test using GC dll with C++ (EH) applications)"
+ @ $(ECHO) "make clean GCE (to test using GCE dll with C++ (EH) applications)"
+ @ $(ECHO) "make clean GC-bench (to benchtest using GNU C dll with C cleanup code)"
+ @ $(ECHO) "make clean GCE-bench (to benchtest using GNU C dll with C++ exception handling)"
all:
@ $(MAKE) clean GC
@@ -105,19 +103,19 @@ all:
@ $(MAKE) clean GCE
GC:
- $(MAKE) GCX=GC XXCFLAGS="-x c -D__CLEANUP_C" all-pass
+ $(MAKE) GCX=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" all-pass
GCE:
- $(MAKE) GCX=GCE XXCFLAGS="-mthreads -x c++ -D__CLEANUP_CXX" all-pass
+ $(MAKE) GCX=GCE CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" all-pass
GCX:
- $(MAKE) GCX=GC XXCFLAGS="-mthreads -x c++ -D__CLEANUP_C" all-pass
+ $(MAKE) GCX=GC CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_C" all-pass
GC-bench:
- $(MAKE) GCX=GC XXCFLAGS="-x c -D__CLEANUP_C" all-bench
+ $(MAKE) GCX=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" all-bench
GCE-bench:
- $(MAKE) GCX=GCE XXCFLAGS="-mthreads -x c++ -D__CLEANUP_CXX" all-bench
+ $(MAKE) GCX=GCE CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" all-bench
all-pass: $(PASSES)
@ $(ECHO) ALL TESTS PASSED! Congratulations!
@@ -244,7 +242,7 @@ tsd1.pass: join1.pass
%.exe: %.c
@ $(ECHO) Compiling $@
@ $(ECHO) $(CC) $(CFLAGS) -o $@ $^ $(INCLUDES) -L. -lpthread$(GCX)
- @ $(CC) $(CFLAGS) -o $@ $^ $(INCLUDES) -L. -lpthread$(GCX)
+ @ $(CC) $(CFLAGS) -o $@ $^ $(INCLUDES) -L. -lpthread$(GCX) -lsupc++
%.pre: %.c
@ $(CC) -E $(CFLAGS) -o $@ $^ $(INCLUDES)
@@ -254,7 +252,7 @@ tsd1.pass: join1.pass
$(COPYFILES):
@ $(ECHO) Copying $@
- @ $(CP) $(BUILD_DIR)\$@ .
+ @ $(CP) $(BUILD_DIR)/$@ .
pthread.dll:
@ $(CP) $(DLL) $@
diff --git a/tests/benchtest1.c b/tests/benchtest1.c
index b4dbdae..e9ecbb0 100644
--- a/tests/benchtest1.c
+++ b/tests/benchtest1.c
@@ -91,7 +91,7 @@ runTest (char * testNameString, int mType)
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
+ printf( "%-45s %15ld %15.3f\n",
testNameString,
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
@@ -106,14 +106,14 @@ main (int argc, char *argv[])
pthread_mutexattr_init(&ma);
- printf( "========================================================================\n");
+ printf( "=============================================================================\n");
printf( "\nLock plus unlock on an unlocked mutex.\n%ld iterations\n\n",
ITERATIONS);
- printf( "%-40s %15s %15s\n",
+ printf( "%-45s %15s %15s\n",
"Test",
"Total(msec)",
"average(usec)");
- printf( "------------------------------------------------------------------------\n");
+ printf( "-----------------------------------------------------------------------------\n");
/*
* Time the loop overhead so we can subtract it from the actual test times.
@@ -139,7 +139,7 @@ main (int argc, char *argv[])
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
+ printf( "%-45s %15ld %15.3f\n",
"Simple Critical Section",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
@@ -157,8 +157,8 @@ main (int argc, char *argv[])
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
- "PT Mutex using a Critical Section (WNT)",
+ printf( "%-45s %15ld %15.3f\n",
+ "Old PT Mutex using a Critical Section (WNT)",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
@@ -175,12 +175,12 @@ main (int argc, char *argv[])
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
- "PT Mutex using a Win32 Mutex (W9x)",
+ printf( "%-45s %15ld %15.3f\n",
+ "Old PT Mutex using a Win32 Mutex (W9x)",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
- printf( "........................................................................\n");
+ printf( ".............................................................................\n");
/*
* Now we can start the actual tests
@@ -197,7 +197,7 @@ main (int argc, char *argv[])
runTest("Non-blocking lock", 0);
#endif
- printf( "========================================================================\n");
+ printf( "=============================================================================\n");
/*
* End of tests.
diff --git a/tests/benchtest2.c b/tests/benchtest2.c
index e1362d1..9c614b5 100644
--- a/tests/benchtest2.c
+++ b/tests/benchtest2.c
@@ -168,7 +168,7 @@ runTest (char * testNameString, int mType)
assert(pthread_mutex_destroy(&gate2) == 0);
assert(pthread_mutex_destroy(&gate1) == 0);
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
+ printf( "%-45s %15ld %15.3f\n",
testNameString,
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS / 4 /* Four locks/unlocks per iteration */);
@@ -180,15 +180,15 @@ main (int argc, char *argv[])
{
assert(pthread_mutexattr_init(&ma) == 0);
- printf( "========================================================================\n");
+ printf( "=============================================================================\n");
printf( "\nLock plus unlock on an unlocked mutex.\n");
printf("%ld iterations, four locks/unlocks per iteration.\n\n", ITERATIONS);
- printf( "%-40s %15s %15s\n",
+ printf( "%-45s %15s %15s\n",
"Test",
"Total(msec)",
"average(usec)");
- printf( "------------------------------------------------------------------------\n");
+ printf( "-----------------------------------------------------------------------------\n");
/*
* Time the loop overhead so we can subtract it from the actual test times.
@@ -226,7 +226,7 @@ main (int argc, char *argv[])
DeleteCriticalSection(&cs2);
DeleteCriticalSection(&cs1);
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
+ printf( "%-45s %15ld %15.3f\n",
"Simple Critical Section",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS / 4 );
@@ -253,8 +253,8 @@ main (int argc, char *argv[])
assert(old_mutex_destroy(&ox2) == 0);
assert(old_mutex_destroy(&ox1) == 0);
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
- "PT Mutex using a Critical Section (WNT)",
+ printf( "%-45s %15ld %15.3f\n",
+ "Old PT Mutex using a Critical Section (WNT)",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS / 4);
@@ -280,12 +280,12 @@ main (int argc, char *argv[])
assert(old_mutex_destroy(&ox2) == 0);
assert(old_mutex_destroy(&ox1) == 0);
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
- "PT Mutex using a Win32 Mutex (W9x)",
+ printf( "%-45s %15ld %15.3f\n",
+ "Old PT Mutex using a Win32 Mutex (W9x)",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS / 4);
- printf( "........................................................................\n");
+ printf( ".............................................................................\n");
/*
* Now we can start the actual tests
@@ -302,7 +302,7 @@ main (int argc, char *argv[])
runTest("Blocking locks", 0);
#endif
- printf( "========================================================================\n");
+ printf( "=============================================================================\n");
/*
* End of tests.
*/
diff --git a/tests/benchtest3.c b/tests/benchtest3.c
index 4de6488..5e86957 100644
--- a/tests/benchtest3.c
+++ b/tests/benchtest3.c
@@ -114,7 +114,7 @@ runTest (char * testNameString, int mType)
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
+ printf( "%-45s %15ld %15.3f\n",
testNameString,
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
@@ -128,14 +128,14 @@ main (int argc, char *argv[])
assert(pthread_mutexattr_init(&ma) == 0);
- printf( "========================================================================\n");
+ printf( "=============================================================================\n");
printf( "\nTrylock on a locked mutex.\n");
printf( "%ld iterations.\n\n", ITERATIONS);
- printf( "%-40s %15s %15s\n",
+ printf( "%-45s %15s %15s\n",
"Test",
"Total(msec)",
"average(usec)");
- printf( "------------------------------------------------------------------------\n");
+ printf( "-----------------------------------------------------------------------------\n");
/*
* Time the loop overhead so we can subtract it from the actual test times.
@@ -156,8 +156,8 @@ main (int argc, char *argv[])
assert(old_mutex_unlock(&ox) == 0);
assert(old_mutex_destroy(&ox) == 0);
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
- "PT Mutex using a Critical Section (WNT)",
+ printf( "%-45s %15ld %15.3f\n",
+ "Old PT Mutex using a Critical Section (WNT)",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
@@ -169,12 +169,12 @@ main (int argc, char *argv[])
assert(old_mutex_unlock(&ox) == 0);
assert(old_mutex_destroy(&ox) == 0);
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
- "PT Mutex using a Win32 Mutex (W9x)",
+ printf( "%-45s %15ld %15.3f\n",
+ "Old PT Mutex using a Win32 Mutex (W9x)",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
- printf( "........................................................................\n");
+ printf( ".............................................................................\n");
/*
* Now we can start the actual tests
@@ -191,7 +191,7 @@ main (int argc, char *argv[])
runTest("Non-blocking lock", 0);
#endif
- printf( "========================================================================\n");
+ printf( "=============================================================================\n");
/*
* End of tests.
diff --git a/tests/benchtest4.c b/tests/benchtest4.c
index 653b0ed..f769afe 100644
--- a/tests/benchtest4.c
+++ b/tests/benchtest4.c
@@ -98,7 +98,7 @@ runTest (char * testNameString, int mType)
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
+ printf( "%-45s %15ld %15.3f\n",
testNameString,
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
@@ -110,14 +110,14 @@ main (int argc, char *argv[])
{
pthread_mutexattr_init(&ma);
- printf( "========================================================================\n");
+ printf( "=============================================================================\n");
printf( "Trylock plus unlock on an unlocked mutex.\n");
printf( "%ld iterations.\n\n", ITERATIONS);
- printf( "%-40s %15s %15s\n",
+ printf( "%-45s %15s %15s\n",
"Test",
"Total(msec)",
"average(usec)");
- printf( "------------------------------------------------------------------------\n");
+ printf( "-----------------------------------------------------------------------------\n");
/*
* Time the loop overhead so we can subtract it from the actual test times.
@@ -137,8 +137,8 @@ main (int argc, char *argv[])
TESTSTOP
assert(old_mutex_destroy(&ox) == 0);
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
- "PT Mutex using a Critical Section (WNT)",
+ printf( "%-45s %15ld %15.3f\n",
+ "Old PT Mutex using a Critical Section (WNT)",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
@@ -150,12 +150,12 @@ main (int argc, char *argv[])
TESTSTOP
assert(old_mutex_destroy(&ox) == 0);
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
- "PT Mutex using a Win32 Mutex (W9x)",
+ printf( "%-45s %15ld %15.3f\n",
+ "Old PT Mutex using a Win32 Mutex (W9x)",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
- printf( "........................................................................\n");
+ printf( ".............................................................................\n");
/*
* Now we can start the actual tests
@@ -172,7 +172,7 @@ main (int argc, char *argv[])
runTest("Non-blocking lock", 0);
#endif
- printf( "========================================================================\n");
+ printf( "=============================================================================\n");
/*
* End of tests.
diff --git a/tests/benchtest5.c b/tests/benchtest5.c
index b7d3225..0b48d9f 100644
--- a/tests/benchtest5.c
+++ b/tests/benchtest5.c
@@ -78,7 +78,7 @@ reportTest (char * testNameString)
{
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
- printf( "%-40s %15ld %15.3f\n",
+ printf( "%-45s %15ld %15.3f\n",
testNameString,
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);
@@ -88,14 +88,14 @@ reportTest (char * testNameString)
int
main (int argc, char *argv[])
{
- printf( "========================================================================\n");
+ printf( "=============================================================================\n");
printf( "\nOperations on a semaphore.\n%ld iterations\n\n",
ITERATIONS);
- printf( "%-40s %15s %15s\n",
+ printf( "%-45s %15s %15s\n",
"Test",
"Total(msec)",
"average(usec)");
- printf( "------------------------------------------------------------------------\n");
+ printf( "-----------------------------------------------------------------------------\n");
/*
* Time the loop overhead so we can subtract it from the actual test times.
@@ -165,7 +165,7 @@ main (int argc, char *argv[])
reportTest("Wait then Post without blocking");
- printf( "========================================================================\n");
+ printf( "=============================================================================\n");
/*
* End of tests.
diff --git a/tests/exception2.c b/tests/exception2.c
index 9c99dd3..36edd9c 100644
--- a/tests/exception2.c
+++ b/tests/exception2.c
@@ -79,7 +79,7 @@
#if defined(_MSC_VER) && defined(__cplusplus)
#include <eh.h>
#else
-#include <new.h>
+#include <exception>
#endif
#ifdef __GNUC__
diff --git a/tests/exception3.c b/tests/exception3.c
index d3eb364..915a0e9 100644
--- a/tests/exception3.c
+++ b/tests/exception3.c
@@ -78,9 +78,14 @@
#if defined(__cplusplus)
#if defined(_MSC_VER)
-#include <eh.h>
+# include <eh.h>
#else
-#include <new.h>
+# if defined(__GNUC__) && __GNUC__ < 3
+# include <new.h>
+# else
+# include <new>
+ using std::set_terminate;
+# endif
#endif
/*
diff --git a/tests/eyal1.c b/tests/eyal1.c
index 72a127f..2890207 100644
--- a/tests/eyal1.c
+++ b/tests/eyal1.c
@@ -124,15 +124,21 @@ static double
waste_time (int n)
{
int i;
- double f;
+ double f, g, h, s;
- f = rand ();
+ s = 0;
+ /*
+ * Useless work.
+ */
for (i = n*100; i > 0; --i)
{
- f = 2 * f * f / (f * f);
+ f = rand ();
+ g = rand ();
+ h = rand ();
+ s += 2 * f * g / (h != 0 ? (h * h) : 1);
}
- return f;
+ return s;
}
static int
diff --git a/tests/semaphore1.c b/tests/semaphore1.c
index c5911f9..1fc60d5 100644
--- a/tests/semaphore1.c
+++ b/tests/semaphore1.c
@@ -87,7 +87,7 @@ thr(void * arg)
if ( result == -1 )
{
- perror("thread: sem_trywait 1"); // No error
+ perror("thread: sem_trywait 1: expected error"); // No error
assert(errno == EAGAIN);
}
else
@@ -131,7 +131,7 @@ main()
if ( result == -1 )
{
- perror("main: sem_trywait 1"); // No error
+ perror("main: sem_trywait 1: expected error"); // No error
assert(errno == EAGAIN);
}
else