summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Miller <kurt@cvs.openbsd.org>2012-04-13 19:05:01 +0000
committerKurt Miller <kurt@cvs.openbsd.org>2012-04-13 19:05:01 +0000
commit12c2ddbd2239348957b55e28e45e334f08be12a4 (patch)
treeec73cd74b2e9efdce1be76c5f8880f9b279ea531
parent3678b7be3fe889fe27d2fd26a1a240588599c13e (diff)
Remove suspend_np1 test from regress
-rw-r--r--regress/lib/libpthread/suspend_np1/Makefile5
-rw-r--r--regress/lib/libpthread/suspend_np1/suspend_np1.c110
2 files changed, 0 insertions, 115 deletions
diff --git a/regress/lib/libpthread/suspend_np1/Makefile b/regress/lib/libpthread/suspend_np1/Makefile
deleted file mode 100644
index af404aa7f7d..00000000000
--- a/regress/lib/libpthread/suspend_np1/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $OpenBSD: Makefile,v 1.1 2012/02/21 13:02:28 kurt Exp $
-
-PROG= suspend_np1
-
-.include <bsd.regress.mk>
diff --git a/regress/lib/libpthread/suspend_np1/suspend_np1.c b/regress/lib/libpthread/suspend_np1/suspend_np1.c
deleted file mode 100644
index 2b5e1704d95..00000000000
--- a/regress/lib/libpthread/suspend_np1/suspend_np1.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* $OpenBSD: suspend_np1.c,v 1.1 2012/02/21 13:02:28 kurt Exp $ */
-/*
- * Copyright (c) 2012 Kurt Miller <kurt@intricatesoftware.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Test pthread_suspend_np().
- */
-
-#include <pthread.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include "test.h"
-
-#define BUSY_THREADS 5
-
-volatile int done = 0;
-volatile int counter[BUSY_THREADS] = { 0, 0, 0, 0, 0 };
-
-static void *
-deadlock_detector(void *arg)
-{
- struct timespec rqtp;
- rqtp.tv_sec = 15;
- rqtp.tv_nsec = 0;
-
- while (nanosleep(&rqtp, &rqtp) == -1 && errno == EINTR);
- PANIC("deadlock detected");
-}
-
-static void *
-busy_thread(void *arg)
-{
- int i = (int)arg;
- struct timespec rqtp;
- rqtp.tv_sec = 0;
- rqtp.tv_nsec = 1000000;
-
- while (!done) {
- counter[i]++;
- nanosleep(&rqtp, NULL);
- }
-
- return NULL;
-}
-
-int
-main(int argc, char *argv[])
-{
- pthread_t busy_threads[BUSY_THREADS];
- int saved_counter[BUSY_THREADS];
- pthread_t deadlock_thread;
- int i;
- void *value_ptr;
- struct timespec rqtp;
-
- rqtp.tv_sec = 0;
- rqtp.tv_nsec = 100 * 1000000;
-
- CHECKr(pthread_create(&deadlock_thread, NULL,
- deadlock_detector, NULL));
-
- for (i = 0; i < BUSY_THREADS; i++)
- CHECKr(pthread_create(&busy_threads[i], NULL,
- busy_thread, (void *)i));
-
- /* sleep to ensure threads have time to start and run */
- nanosleep(&rqtp, NULL);
-
- /* stop and save counters */
- pthread_suspend_all_np();
- for (i = 0; i < BUSY_THREADS; i++)
- saved_counter[i] = counter[i];
-
- /* sleep and check counters have not moved */
- nanosleep(&rqtp, NULL);
- for (i = 0; i < BUSY_THREADS; i++)
- ASSERT(saved_counter[i] == counter[i]);
-
- /* resume all and check counters are moving again */
- pthread_resume_all_np();
- nanosleep(&rqtp, NULL);
- for (i = 0; i < BUSY_THREADS; i++)
- ASSERT(saved_counter[i] != counter[i]);
-
- done = 1;
-
- for (i = 0; i < BUSY_THREADS; i++) {
- CHECKr(pthread_join(busy_threads[i], &value_ptr));
- ASSERT(value_ptr == NULL);
- }
-
- SUCCEED;
-}