summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorMarco S Hyman <marc@cvs.openbsd.org>2002-06-23 20:21:23 +0000
committerMarco S Hyman <marc@cvs.openbsd.org>2002-06-23 20:21:23 +0000
commitdd75434f73416a9e953043ff6da7367e9d550831 (patch)
treec9d8559065d21361040b3d574562782f1450b17f /regress
parentdf76e10a5850dbc56d189fd0ac3eec402d0939d9 (diff)
Fix pthread floatting point preemption test and enable it. Next
step is to figure out why it fails on i386, yet works on sparc
Diffstat (limited to 'regress')
-rw-r--r--regress/lib/libc_r/Makefile4
-rw-r--r--regress/lib/libc_r/preemption_float/preemption_float.c52
-rw-r--r--regress/lib/libpthread/Makefile4
-rw-r--r--regress/lib/libpthread/preemption_float/preemption_float.c52
4 files changed, 44 insertions, 68 deletions
diff --git a/regress/lib/libc_r/Makefile b/regress/lib/libc_r/Makefile
index e94355b9d6d..e360782f22c 100644
--- a/regress/lib/libc_r/Makefile
+++ b/regress/lib/libc_r/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.9 2002/05/03 10:12:02 wcobb Exp $
+# $OpenBSD: Makefile,v 1.10 2002/06/23 20:21:22 marc Exp $
SUBDIR= cancel close cwd execve fork group netdb pcap poll \
- preemption pthread_cond_timedwait pthread_create \
+ preemption preemption_float pthread_cond_timedwait pthread_create \
pthread_join pthread_mutex pthread_specific readdir select \
setjmp signal sigsuspend sigwait sleep socket stdarg stdio \
switch system
diff --git a/regress/lib/libc_r/preemption_float/preemption_float.c b/regress/lib/libc_r/preemption_float/preemption_float.c
index 3aa810689fd..b91ca4b8c71 100644
--- a/regress/lib/libc_r/preemption_float/preemption_float.c
+++ b/regress/lib/libc_r/preemption_float/preemption_float.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: preemption_float.c,v 1.1 2001/08/15 14:37:12 fgsch Exp $ */
+/* $OpenBSD: preemption_float.c,v 1.2 2002/06/23 20:21:22 marc Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996 by Chris Provenzano and contributors,
* proven@mit.edu All rights reserved.
@@ -94,13 +94,13 @@ void *trig_loop (void *x) {
}
int
-floatloop(pthread_attr_t *attrp)
+floatloop(void)
{
pthread_t thread[2];
int *x, *y;
- CHECKr(pthread_create (&thread[0], attrp, trig_loop, 0));
- CHECKr(pthread_create (&thread[1], attrp, log_loop, 0));
+ CHECKr(pthread_create (&thread[0], NULL, trig_loop, NULL));
+ CHECKr(pthread_create (&thread[1], NULL, log_loop, NULL));
CHECKr(pthread_join(thread[0], (void **) &x));
CHECKr(pthread_join(thread[1], (void **) &y));
@@ -109,40 +109,28 @@ floatloop(pthread_attr_t *attrp)
((*x == float_failed)?1:0);
}
-#define N 10
int
main()
{
- pthread_attr_t attr;
- int i;
-
- /* Try with float point state not preserved */
-
- CHECKr(pthread_attr_init(&attr));
- CHECKr(pthread_attr_setfloatstate(&attr, PTHREAD_NOFLOAT));
-
- for(limit = 2; limit < 100000; limit *=4)
- if (floatloop(&attr) != 0)
- break;
-
- if (limit >= 100000) {
- printf("results are INDETERMINATE\n");
- SUCCEED; /* XXX */
+ pthread_t thread;
+ int *result;
+
+ /* single active thread, trig test */
+ for(limit = 2; limit < 100000; limit *=4) {
+ CHECKr(pthread_create (&thread, NULL, trig_loop, NULL));
+ CHECKr(pthread_join(thread, (void **) &result));
+ ASSERT(*result == 0);
}
- limit *= 4; /* just to make sure */
-
- printf("using limit = %d\n", limit);
-
- for (i = 0; i < 32; i++) {
- /* Try the failure mode one more time. */
- if (floatloop(&attr) == 0) {
- printf("%d ", i);
- fflush(stdout);
- }
- /* Now see if saving float state will get rid of failure. */
- ASSERT(floatloop(NULL) == 0);
+ /* single active thread, log test */
+ for(limit = 2; limit < 100000; limit *=4) {
+ CHECKr(pthread_create (&thread, NULL, log_loop, NULL));
+ CHECKr(pthread_join(thread, (void **) &result));
+ ASSERT(*result == 0);
}
+ /* run both threads concurrently using a higher limit */
+ limit *= 4;
+ ASSERT(floatloop() == 0);
SUCCEED;
}
diff --git a/regress/lib/libpthread/Makefile b/regress/lib/libpthread/Makefile
index e94355b9d6d..e360782f22c 100644
--- a/regress/lib/libpthread/Makefile
+++ b/regress/lib/libpthread/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.9 2002/05/03 10:12:02 wcobb Exp $
+# $OpenBSD: Makefile,v 1.10 2002/06/23 20:21:22 marc Exp $
SUBDIR= cancel close cwd execve fork group netdb pcap poll \
- preemption pthread_cond_timedwait pthread_create \
+ preemption preemption_float pthread_cond_timedwait pthread_create \
pthread_join pthread_mutex pthread_specific readdir select \
setjmp signal sigsuspend sigwait sleep socket stdarg stdio \
switch system
diff --git a/regress/lib/libpthread/preemption_float/preemption_float.c b/regress/lib/libpthread/preemption_float/preemption_float.c
index 3aa810689fd..b91ca4b8c71 100644
--- a/regress/lib/libpthread/preemption_float/preemption_float.c
+++ b/regress/lib/libpthread/preemption_float/preemption_float.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: preemption_float.c,v 1.1 2001/08/15 14:37:12 fgsch Exp $ */
+/* $OpenBSD: preemption_float.c,v 1.2 2002/06/23 20:21:22 marc Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996 by Chris Provenzano and contributors,
* proven@mit.edu All rights reserved.
@@ -94,13 +94,13 @@ void *trig_loop (void *x) {
}
int
-floatloop(pthread_attr_t *attrp)
+floatloop(void)
{
pthread_t thread[2];
int *x, *y;
- CHECKr(pthread_create (&thread[0], attrp, trig_loop, 0));
- CHECKr(pthread_create (&thread[1], attrp, log_loop, 0));
+ CHECKr(pthread_create (&thread[0], NULL, trig_loop, NULL));
+ CHECKr(pthread_create (&thread[1], NULL, log_loop, NULL));
CHECKr(pthread_join(thread[0], (void **) &x));
CHECKr(pthread_join(thread[1], (void **) &y));
@@ -109,40 +109,28 @@ floatloop(pthread_attr_t *attrp)
((*x == float_failed)?1:0);
}
-#define N 10
int
main()
{
- pthread_attr_t attr;
- int i;
-
- /* Try with float point state not preserved */
-
- CHECKr(pthread_attr_init(&attr));
- CHECKr(pthread_attr_setfloatstate(&attr, PTHREAD_NOFLOAT));
-
- for(limit = 2; limit < 100000; limit *=4)
- if (floatloop(&attr) != 0)
- break;
-
- if (limit >= 100000) {
- printf("results are INDETERMINATE\n");
- SUCCEED; /* XXX */
+ pthread_t thread;
+ int *result;
+
+ /* single active thread, trig test */
+ for(limit = 2; limit < 100000; limit *=4) {
+ CHECKr(pthread_create (&thread, NULL, trig_loop, NULL));
+ CHECKr(pthread_join(thread, (void **) &result));
+ ASSERT(*result == 0);
}
- limit *= 4; /* just to make sure */
-
- printf("using limit = %d\n", limit);
-
- for (i = 0; i < 32; i++) {
- /* Try the failure mode one more time. */
- if (floatloop(&attr) == 0) {
- printf("%d ", i);
- fflush(stdout);
- }
- /* Now see if saving float state will get rid of failure. */
- ASSERT(floatloop(NULL) == 0);
+ /* single active thread, log test */
+ for(limit = 2; limit < 100000; limit *=4) {
+ CHECKr(pthread_create (&thread, NULL, log_loop, NULL));
+ CHECKr(pthread_join(thread, (void **) &result));
+ ASSERT(*result == 0);
}
+ /* run both threads concurrently using a higher limit */
+ limit *= 4;
+ ASSERT(floatloop() == 0);
SUCCEED;
}