summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorrpj <rpj>2005-05-16 15:42:44 +0000
committerrpj <rpj>2005-05-16 15:42:44 +0000
commita824c43d3f20fc5722c5fd8f0f942f632b961723 (patch)
treee33174f1e54bcb5dffa3fb16be69713f4cc497c0 /tests
parent08e2916eb07fb75b2907032e2418316bf980d945 (diff)
''
Diffstat (limited to 'tests')
-rw-r--r--tests/Bmakefile5
-rw-r--r--tests/ChangeLog10
-rw-r--r--tests/GNUmakefile8
-rw-r--r--tests/Makefile10
-rw-r--r--tests/Wmakefile9
-rw-r--r--tests/create3.c2
-rw-r--r--tests/detach1.c88
-rw-r--r--tests/join0.c5
-rw-r--r--tests/join1.c9
-rw-r--r--tests/join2.c4
-rw-r--r--tests/join3.c4
-rw-r--r--tests/reuse2.c14
12 files changed, 132 insertions, 36 deletions
diff --git a/tests/Bmakefile b/tests/Bmakefile
index 6141ffe..34ec8a6 100644
--- a/tests/Bmakefile
+++ b/tests/Bmakefile
@@ -86,7 +86,7 @@ PASSES= loadfree.pass \
exit1.pass create1.pass create2.pass reuse1.pass reuse2.pass equal1.pass \
kill1.pass valid1.pass valid2.pass \
exit2.pass exit3.pass exit4.pass exit5.pass \
- join0.pass join1.pass join2.pass join3.pass \
+ join0.pass join1.pass detach1.pass join2.pass join3.pass \
mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass \
mutex6s.pass mutex6es.pass mutex6rs.pass \
mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \
@@ -261,6 +261,7 @@ create2.pass: create1.pass
create3.pass:
delay1.pass:
delay2.pass: delay1.pass
+detach1.pass: join0.pass
equal1.pass: create1.pass
errno1.pass: mutex3.pass
exception1.pass: cancel4.pass
@@ -340,7 +341,7 @@ spin1.pass:
spin2.pass: spin1.pass
spin3.pass: spin2.pass
spin4.pass: spin3.pass
-stress1.pass: barrier5.pass
+stress1.pass:
tsd1.pass: barrier5.pass join1.pass
tsd2.pass: tsd1.pass
valid1.pass: join1.pass
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 1800c99..2677631 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,13 @@
+2005-05-15 Ross Johnson <rpj@callisto.canberra.edu.au>
+
+ * detach1.c: New test.
+ * join1.c: Reduce sleep times.
+ * join0.c: Remove MSVCRT conditional compile - join should always
+ return the thread exit code.
+ * join1.c: Likewise.
+ * join2.c: Likewise.
+ * join3.c: Likewise.
+
2005-04-12 Ross Johnson <rpj@callisto.canberra.edu.au>
* once4.c: New test; tries to test priority adjustments
diff --git a/tests/GNUmakefile b/tests/GNUmakefile
index e9df21a..9b16114 100644
--- a/tests/GNUmakefile
+++ b/tests/GNUmakefile
@@ -81,7 +81,7 @@ TESTS = sizes loadfree \
create1 create2 reuse1 reuse2 equal1 \
kill1 valid1 valid2 \
exit2 exit3 exit4 exit5 \
- join0 join1 join2 join3 \
+ join0 join1 detach1 join2 join3 \
mutex2 mutex2r mutex2e mutex3 mutex3r mutex3e \
mutex4 mutex6 mutex6n mutex6e mutex6r \
mutex6s mutex6es mutex6rs \
@@ -102,7 +102,7 @@ TESTS = sizes loadfree \
priority1 priority2 inherit1 \
spin1 spin2 spin3 spin4 \
exception1 exception2 exception3 \
- cancel9 create3
+ cancel9 create3 stress1
STRESSTESTS = \
stress1
@@ -184,8 +184,6 @@ benchtest3.bench:
benchtest4.bench:
benchtest5.bench:
-stress1.pass:
-
barrier1.pass: semaphore4.pass
barrier2.pass: barrier1.pass
barrier3.pass: barrier2.pass
@@ -228,6 +226,7 @@ create2.pass: create1.pass
create3.pass:
delay1.pass: cancel2.pass
delay2.pass: delay1.pass
+detach1.pass: join0.pass
equal1.pass: create1.pass
errno1.pass: mutex3.pass
exception1.pass: cancel4.pass
@@ -307,6 +306,7 @@ spin1.pass:
spin2.pass: spin1.pass
spin3.pass: spin2.pass
spin4.pass: spin3.pass
+stress1.pass:
tsd1.pass: barrier5.pass join1.pass
tsd2.pass: tsd1.pass
valid1.pass: join1.pass
diff --git a/tests/Makefile b/tests/Makefile
index d12a1f1..b00f52b 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -90,7 +90,7 @@ PASSES= sizes.pass loadfree.pass \
exit1.pass create1.pass create2.pass reuse1.pass reuse2.pass equal1.pass \
kill1.pass valid1.pass valid2.pass \
exit2.pass exit3.pass exit4.pass exit5.pass \
- join0.pass join1.pass join2.pass join3.pass \
+ join0.pass join1.pass detach1.pass join2.pass join3.pass \
mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass \
mutex6s.pass mutex6es.pass mutex6rs.pass \
mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \
@@ -115,13 +115,13 @@ PASSES= sizes.pass loadfree.pass \
priority1.pass priority2.pass inherit1.pass \
spin1.pass spin2.pass spin3.pass spin4.pass \
exception1.pass exception2.pass exception3.pass \
- cancel9.pass create3.pass
+ cancel9.pass create3.pass stress1.pass
BENCHRESULTS = \
benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench
STRESSRESULTS = \
- stress1.pass
+ stress1.stress
STATICRESULTS = \
self1.pass
@@ -274,8 +274,6 @@ benchtest3.bench:
benchtest4.bench:
benchtest5.bench:
-stress1.pass:
-
barrier1.pass: semaphore4.pass
barrier2.pass: barrier1.pass
barrier3.pass: barrier2.pass
@@ -317,6 +315,7 @@ create2.pass: create1.pass
create3.pass:
delay1.pass:
delay2.pass: delay1.pass
+detach1.pass: join0.pass
equal1.pass: create1.pass
errno1.pass: mutex3.pass
exception1.pass: cancel4.pass
@@ -396,6 +395,7 @@ spin1.pass:
spin2.pass: spin1.pass
spin3.pass: spin2.pass
spin4.pass: spin3.pass
+stress1.pass: condvar9.pass barrier5.pass
tsd1.pass: barrier5.pass join1.pass
tsd2.pass: tsd1.pass
valid1.pass: join1.pass
diff --git a/tests/Wmakefile b/tests/Wmakefile
index 4f003df..5f900e8 100644
--- a/tests/Wmakefile
+++ b/tests/Wmakefile
@@ -32,7 +32,7 @@
#
-DLL_VER = 2
+DLL_VER = 1
.EXTENSIONS:
@@ -86,7 +86,7 @@ PASSES = sizes.pass loadfree.pass &
exit1.pass create1.pass create2.pass reuse1.pass reuse2.pass equal1.pass &
kill1.pass valid1.pass valid2.pass &
exit2.pass exit3.pass exit4 exit5 &
- join0.pass join1.pass join2.pass join3.pass &
+ join0.pass join1.pass detach1.pass join2.pass join3.pass &
mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass &
mutex6s.pass mutex6es.pass mutex6rs.pass &
mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass &
@@ -111,7 +111,7 @@ PASSES = sizes.pass loadfree.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 &
- cancel9.pass
+ cancel9.pass create3.pass stress1.pass
BENCHRESULTS = &
benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench
@@ -255,8 +255,10 @@ context1.pass: cancel2.pass
count1.pass: join1.pass
create1.pass: mutex2.pass
create2.pass: create1.pass
+create3.pass:
delay1.pass:
delay2.pass: delay1.pass
+detach1.pass: join0.pass
equal1.pass: create1.pass
errno1.pass: mutex3.pass
exception1.pass: cancel4.pass
@@ -335,6 +337,7 @@ spin1.pass:
spin2.pass: spin1.pass
spin3.pass: spin2.pass
spin4.pass: spin3.pass
+stress1.pass:
tsd1.pass: join1.pass
valid1.pass: join1.pass
valid2.pass: valid1.pass
diff --git a/tests/create3.c b/tests/create3.c
index 530a2f1..98bd520 100644
--- a/tests/create3.c
+++ b/tests/create3.c
@@ -92,7 +92,7 @@ threadFunc(void * arg)
}
int
-main(int argc, char argv[])
+main(int argc, char * argv[])
{
int i;
pthread_t mt;
diff --git a/tests/detach1.c b/tests/detach1.c
new file mode 100644
index 0000000..b0835c5
--- /dev/null
+++ b/tests/detach1.c
@@ -0,0 +1,88 @@
+/*
+ * Test for pthread_detach().
+ *
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads-win32 - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999,2005 Pthreads-win32 contributors
+ *
+ * Contact Email: rpj@callisto.canberra.edu.au
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * http://sources.redhat.com/pthreads-win32/contributors.html
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Depends on API functions: pthread_create(), pthread_detach(), pthread_exit().
+ */
+
+#include "test.h"
+
+void *
+func(void * arg)
+{
+ int i = (int) arg;
+
+ Sleep(i * 100);
+
+ pthread_exit(arg);
+
+ /* Never reached. */
+ exit(1);
+}
+
+int
+main(int argc, char * argv[])
+{
+ pthread_t id[4];
+ int i;
+
+ /* Create a few threads and then exit. */
+ for (i = 0; i < 4; i++)
+ {
+ assert(pthread_create(&id[i], NULL, func, (void *) i) == 0);
+ }
+
+ /* Some threads will finish before they are detached, some after. */
+ Sleep(2 * 100 + 50);
+
+ for (i = 0; i < 4; i++)
+ {
+ assert(pthread_detach(id[i]) == 0);
+ }
+
+ Sleep(6 * 100);
+
+ /*
+ * Check that all threads are now invalid.
+ * This relies on unique thread IDs - e.g. works with
+ * pthreads-w32 or Solaris, but may not work for Linux, BSD etc.
+ */
+ for (i = 0; i < 4; i++)
+ {
+ assert(pthread_kill(id[i], 0) == ESRCH);
+ }
+
+ /* Success. */
+ return 0;
+}
diff --git a/tests/join0.c b/tests/join0.c
index bece19c..a6cb25d 100644
--- a/tests/join0.c
+++ b/tests/join0.c
@@ -60,12 +60,7 @@ main(int argc, char * argv[])
assert(pthread_join(id, (void **) &result) == 0);
-#if ! defined (__MINGW32__) || defined (__MSVCRT__)
assert(result == 123);
-#else
-# warning pthread_join not fully supported in this configuration.
- assert(result == 0);
-#endif
/* Success. */
return 0;
diff --git a/tests/join1.c b/tests/join1.c
index 8f52ae7..8b11e95 100644
--- a/tests/join1.c
+++ b/tests/join1.c
@@ -43,7 +43,7 @@ func(void * arg)
{
int i = (int) arg;
- Sleep(i * 500);
+ Sleep(i * 100);
pthread_exit(arg);
@@ -65,17 +65,12 @@ main(int argc, char * argv[])
}
/* Some threads will finish before they are joined, some after. */
- Sleep(1000);
+ Sleep(2 * 100 + 50);
for (i = 0; i < 4; i++)
{
assert(pthread_join(id[i], (void **) &result) == 0);
-#if ! defined (__MINGW32__) || defined (__MSVCRT__)
assert(result == i);
-#else
-# warning pthread_join not fully supported in this configuration.
- assert(result == 0);
-#endif
}
/* Success. */
diff --git a/tests/join2.c b/tests/join2.c
index 89a3633..4fa3012 100644
--- a/tests/join2.c
+++ b/tests/join2.c
@@ -61,11 +61,7 @@ main(int argc, char * argv[])
for (i = 0; i < 4; i++)
{
assert(pthread_join(id[i], (void **) &result) == 0);
-#if ! defined (__MINGW32__) || defined (__MSVCRT__)
- /* CRTDLL _beginthread doesn't support return value, so
- the assertion is guaranteed to fail. */
assert(result == i);
-#endif
}
/* Success. */
diff --git a/tests/join3.c b/tests/join3.c
index ccc13dd..70cf3e9 100644
--- a/tests/join3.c
+++ b/tests/join3.c
@@ -67,11 +67,7 @@ main(int argc, char * argv[])
for (i = 0; i < 4; i++)
{
assert(pthread_join(id[i], (void **) &result) == 0);
-#if ! defined (__MINGW32__) || defined (__MSVCRT__)
- /* CRTDLL _beginthread doesn't support return value, so
- the assertion is guaranteed to fail. */
assert(result == i);
-#endif
}
/* Success. */
diff --git a/tests/reuse2.c b/tests/reuse2.c
index 9851dde..e573a31 100644
--- a/tests/reuse2.c
+++ b/tests/reuse2.c
@@ -84,15 +84,27 @@ enum {
};
+static int dummy = 19;
static long done = 0;
void * func(void * arg)
{
+ int i;
+ int j;
+
sched_yield();
+ for (i = 1; i < 10000; i++)
+ {
+ if (i * dummy % dummy == 0)
+ {
+ j = dummy;
+ }
+ }
+
InterlockedIncrement(&done);
- return (void *) 0;
+ return (void *) j;
}
int