summaryrefslogtreecommitdiff
path: root/regress/lib/libpthread
diff options
context:
space:
mode:
authorMarco S Hyman <marc@cvs.openbsd.org>2003-07-14 22:01:43 +0000
committerMarco S Hyman <marc@cvs.openbsd.org>2003-07-14 22:01:43 +0000
commita7466eea413b871dcb5fef013b875d995a692b8e (patch)
tree182ceeb95a854c1776d3094631f8dcb7c6abfb5b /regress/lib/libpthread
parent1fd5a3124b13eeff8e147e21445cd5f97389a707 (diff)
improve test. fails with current code
Diffstat (limited to 'regress/lib/libpthread')
-rw-r--r--regress/lib/libpthread/sigmask/sigmask.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/regress/lib/libpthread/sigmask/sigmask.c b/regress/lib/libpthread/sigmask/sigmask.c
index 51b93486842..b3ccc0fa2a4 100644
--- a/regress/lib/libpthread/sigmask/sigmask.c
+++ b/regress/lib/libpthread/sigmask/sigmask.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigmask.c,v 1.1 2003/07/10 21:02:12 marc Exp $ */
+/* $OpenBSD: sigmask.c,v 1.2 2003/07/14 22:01:42 marc Exp $ */
/* PUBLIC DOMAIN July 2003 Marco S Hyman <marc@snafu.org> */
#include <sys/time.h>
@@ -16,17 +16,46 @@
int main (int argc, char *argv[])
{
sigset_t mask;
+ int sig;
+
+ /* any two (or more) command line args should cause the program
+ to die */
+ if (argc > 2) {
+ printf("trigger sigalrm[1] [test should die]\n");
+ ualarm(100000, 0);
+ CHECKe(sleep(1));
+ }
/* mask sigalrm */
CHECKe(sigemptyset(&mask));
CHECKe(sigaddset(&mask, SIGALRM));
CHECKe(pthread_sigmask(SIG_BLOCK, &mask, NULL));
- /* now trigger sigalrm */
+ /* now trigger sigalrm and wait for it */
+ printf("trigger sigalrm[2] [masked, test should not die]\n");
ualarm(100000, 0);
+ CHECKe(sleep(1));
- /* wait for it -- we shouldn't see it. */
+ /* sigwait for sigalrm, it should be pending. If it is not
+ the test will hang. */
+ CHECKe(sigwait(&mask, &sig));
+ ASSERT(sig == SIGALRM);
+
+ /* make sure sigwait didn't muck with the mask by triggering
+ sigalrm, again */
+ printf("trigger sigalrm[3] after sigwait [masked, test should not die]\n");
+ ualarm(100000, 0);
CHECKe(sleep(1));
+ /* any single command line arg will run this code wich unmasks the
+ signal and then makes sure the program terminates when sigalrm
+ is triggered. */
+ if (argc > 1) {
+ printf("trigger sigalrm[4] [unmasked, test should die]\n");
+ CHECKe(pthread_sigmask(SIG_UNBLOCK, &mask, NULL));
+ ualarm(100000, 0);
+ CHECKe(sleep(1));
+ }
+
SUCCEED;
}