diff options
author | Marco S Hyman <marc@cvs.openbsd.org> | 2001-11-03 04:33:49 +0000 |
---|---|---|
committer | Marco S Hyman <marc@cvs.openbsd.org> | 2001-11-03 04:33:49 +0000 |
commit | fda395f82481595d0a1aac47e8dc70cabe17dd7e (patch) | |
tree | 7a7035aee71205602f92d1cdc4367eb51cb40417 /regress/lib | |
parent | 8053500a21eafa9902b1f97a6b98a4cd375818bc (diff) |
Fix pthread_mutex regression test... undefined behavior does not
mean != EPERM in one test, minor changes to recursive mutex test.
remove printf in signal test signal handler, run test long enough
to ensure signal hander is called at least twice, reduce output.
Note: running these tests over a remote console may indicate bogus
falures due to console output latency. Any test that takes longer
than 5 seconds to complete may be flagged as a failure.
Diffstat (limited to 'regress/lib')
-rw-r--r-- | regress/lib/libc_r/pthread_mutex/pthread_mutex.c | 10 | ||||
-rw-r--r-- | regress/lib/libc_r/signal/signal.c | 17 | ||||
-rw-r--r-- | regress/lib/libpthread/pthread_mutex/pthread_mutex.c | 10 | ||||
-rw-r--r-- | regress/lib/libpthread/signal/signal.c | 17 |
4 files changed, 34 insertions, 20 deletions
diff --git a/regress/lib/libc_r/pthread_mutex/pthread_mutex.c b/regress/lib/libc_r/pthread_mutex/pthread_mutex.c index 3dd62129035..311688d0259 100644 --- a/regress/lib/libc_r/pthread_mutex/pthread_mutex.c +++ b/regress/lib/libc_r/pthread_mutex/pthread_mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pthread_mutex.c,v 1.2 2001/09/20 16:43:15 todd Exp $ */ +/* $OpenBSD: pthread_mutex.c,v 1.3 2001/11/03 04:33:48 marc Exp $ */ /* * Copyright (c) 1993, 1994, 1995, 1996 by Chris Provenzano and contributors, * proven@mit.edu All rights reserved. @@ -109,7 +109,7 @@ test_debug_double_unlock(mutex) CHECKr(pthread_mutex_lock(mutex)); CHECKr(pthread_mutex_unlock(mutex)); /* Posix D10 says undefined behaviour? */ - ASSERTe(pthread_mutex_unlock(mutex), != EPERM); + ASSERTe(pthread_mutex_unlock(mutex), != 0); } void @@ -167,6 +167,7 @@ test_mutex_recursive() pthread_mutexattr_t mutex_recursive_attr; pthread_mutex_t mutex_recursive; int i; + int j = 9; printf("test_mutex_recursive()\n"); CHECKr(pthread_mutexattr_init(&mutex_recursive_attr)); @@ -175,13 +176,14 @@ test_mutex_recursive() CHECKr(pthread_mutex_init(&mutex_recursive, &mutex_recursive_attr)); CHECKr(pthread_mutex_lock(&mutex_recursive)); - for (i = 0; i < 9; i++) + for (i = 0; i < j; i++) CHECKr(pthread_mutex_lock(&mutex_recursive)); - for (i = 0; i < 9; i++) + for (i = 0; i < j; i++) CHECKr(pthread_mutex_unlock(&mutex_recursive)); CHECKr(pthread_mutex_unlock(&mutex_recursive)); /* Posix D10 says undefined behaviour? */ ASSERTe(pthread_mutex_unlock(&mutex_recursive), != 0); + CHECKr(pthread_mutex_destroy(&mutex_recursive)); } int diff --git a/regress/lib/libc_r/signal/signal.c b/regress/lib/libc_r/signal/signal.c index effc36b7087..4955dd86f83 100644 --- a/regress/lib/libc_r/signal/signal.c +++ b/regress/lib/libc_r/signal/signal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: signal.c,v 1.1 2001/08/15 14:37:13 fgsch Exp $ */ +/* $OpenBSD: signal.c,v 1.2 2001/11/03 04:33:48 marc Exp $ */ /* David Leonard <d@openbsd.org>, 2001. Public Domain. */ /* @@ -12,6 +12,8 @@ #include <signal.h> #include "test.h" +volatile int alarmed; + void * sleeper(arg) void *arg; @@ -21,8 +23,7 @@ sleeper(arg) /* Ignore all signals in this thread */ sigfillset(&mask); CHECKe(sigprocmask(SIG_SETMASK, &mask, NULL)); - - ASSERT(sleep(2) == 0); + ASSERT(sleep(3) == 0); SUCCEED; } @@ -30,7 +31,7 @@ void handler(sig) int sig; { - printf("signal handler %d\n", sig); + alarmed = 1; alarm(1); signal(SIGALRM, handler); } @@ -44,6 +45,10 @@ main() CHECKe(alarm(1)); CHECKr(pthread_create(&slpr, NULL, sleeper, NULL)); /* ASSERT(sleep(1) == 0); */ - for (;;) - CHECKe(write(STDOUT_FILENO, ".", 1)); + for (;;) { + if (alarmed) { + alarmed = 0; + CHECKe(write(STDOUT_FILENO, "!", 1)); + } + } } diff --git a/regress/lib/libpthread/pthread_mutex/pthread_mutex.c b/regress/lib/libpthread/pthread_mutex/pthread_mutex.c index 3dd62129035..311688d0259 100644 --- a/regress/lib/libpthread/pthread_mutex/pthread_mutex.c +++ b/regress/lib/libpthread/pthread_mutex/pthread_mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pthread_mutex.c,v 1.2 2001/09/20 16:43:15 todd Exp $ */ +/* $OpenBSD: pthread_mutex.c,v 1.3 2001/11/03 04:33:48 marc Exp $ */ /* * Copyright (c) 1993, 1994, 1995, 1996 by Chris Provenzano and contributors, * proven@mit.edu All rights reserved. @@ -109,7 +109,7 @@ test_debug_double_unlock(mutex) CHECKr(pthread_mutex_lock(mutex)); CHECKr(pthread_mutex_unlock(mutex)); /* Posix D10 says undefined behaviour? */ - ASSERTe(pthread_mutex_unlock(mutex), != EPERM); + ASSERTe(pthread_mutex_unlock(mutex), != 0); } void @@ -167,6 +167,7 @@ test_mutex_recursive() pthread_mutexattr_t mutex_recursive_attr; pthread_mutex_t mutex_recursive; int i; + int j = 9; printf("test_mutex_recursive()\n"); CHECKr(pthread_mutexattr_init(&mutex_recursive_attr)); @@ -175,13 +176,14 @@ test_mutex_recursive() CHECKr(pthread_mutex_init(&mutex_recursive, &mutex_recursive_attr)); CHECKr(pthread_mutex_lock(&mutex_recursive)); - for (i = 0; i < 9; i++) + for (i = 0; i < j; i++) CHECKr(pthread_mutex_lock(&mutex_recursive)); - for (i = 0; i < 9; i++) + for (i = 0; i < j; i++) CHECKr(pthread_mutex_unlock(&mutex_recursive)); CHECKr(pthread_mutex_unlock(&mutex_recursive)); /* Posix D10 says undefined behaviour? */ ASSERTe(pthread_mutex_unlock(&mutex_recursive), != 0); + CHECKr(pthread_mutex_destroy(&mutex_recursive)); } int diff --git a/regress/lib/libpthread/signal/signal.c b/regress/lib/libpthread/signal/signal.c index effc36b7087..4955dd86f83 100644 --- a/regress/lib/libpthread/signal/signal.c +++ b/regress/lib/libpthread/signal/signal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: signal.c,v 1.1 2001/08/15 14:37:13 fgsch Exp $ */ +/* $OpenBSD: signal.c,v 1.2 2001/11/03 04:33:48 marc Exp $ */ /* David Leonard <d@openbsd.org>, 2001. Public Domain. */ /* @@ -12,6 +12,8 @@ #include <signal.h> #include "test.h" +volatile int alarmed; + void * sleeper(arg) void *arg; @@ -21,8 +23,7 @@ sleeper(arg) /* Ignore all signals in this thread */ sigfillset(&mask); CHECKe(sigprocmask(SIG_SETMASK, &mask, NULL)); - - ASSERT(sleep(2) == 0); + ASSERT(sleep(3) == 0); SUCCEED; } @@ -30,7 +31,7 @@ void handler(sig) int sig; { - printf("signal handler %d\n", sig); + alarmed = 1; alarm(1); signal(SIGALRM, handler); } @@ -44,6 +45,10 @@ main() CHECKe(alarm(1)); CHECKr(pthread_create(&slpr, NULL, sleeper, NULL)); /* ASSERT(sleep(1) == 0); */ - for (;;) - CHECKe(write(STDOUT_FILENO, ".", 1)); + for (;;) { + if (alarmed) { + alarmed = 0; + CHECKe(write(STDOUT_FILENO, "!", 1)); + } + } } |