summaryrefslogtreecommitdiff
path: root/lib/libc_r
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1998-12-10 00:31:40 +0000
committerDavid Leonard <d@cvs.openbsd.org>1998-12-10 00:31:40 +0000
commitac86a0e364b3332ce6c007a699a31f788a636999 (patch)
tree7e4e20ee04a291c564db251c6171e8cbbd690667 /lib/libc_r
parent2e6badc009b001de5b4fd90a425f6e40b669f855 (diff)
tests are now useful
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/TEST/Makefile13
-rw-r--r--lib/libc_r/TEST/test.h38
-rw-r--r--lib/libc_r/TEST/test_create.c14
-rw-r--r--lib/libc_r/TEST/test_fork.c3
-rw-r--r--lib/libc_r/TEST/test_preemption.c17
-rw-r--r--lib/libc_r/TEST/test_pthread_join.c2
-rw-r--r--lib/libc_r/TEST/test_pthread_mutex.c14
-rw-r--r--lib/libc_r/TEST/test_sleep.c14
-rw-r--r--lib/libc_r/TEST/test_sock_1.c165
-rw-r--r--lib/libc_r/TEST/test_sock_2.c61
-rw-r--r--lib/libc_r/TEST/test_switch.c9
11 files changed, 176 insertions, 174 deletions
diff --git a/lib/libc_r/TEST/Makefile b/lib/libc_r/TEST/Makefile
index d03d1c4ec61..89772bed08a 100644
--- a/lib/libc_r/TEST/Makefile
+++ b/lib/libc_r/TEST/Makefile
@@ -20,7 +20,8 @@ DPADD += ${LIBC_R}
TESTS = test_create test_pthread_join test_switch test_sleep test_readdir \
test_fork test_execve test_preemption test_preemption_float \
test_sock_1 test_sock_2 test_stdio_1 test_pthread_mutex \
- test_pthread_cond_timedwait test_netdb test_pw test_cwd
+ test_pthread_cond_timedwait test_netdb test_pw test_cwd \
+ test_sock_2a
# This list used to include p_bench_semaphore, but the semaphore support isn't
# defined for all targets (or used for any).
@@ -29,17 +30,23 @@ BENCHMARKS = p_bench_read p_bench_mutex p_bench_yield \
CLEANFILES += ${TESTS} ${BENCHMARKS}
+SKIP_TESTS = test_sock_2a
+
all : tests # benchmarks
tests : ${TESTS}
@for i in ${.ALLSRC} ; do \
echo ; echo "*** $$i ***"; \
+ case " ${SKIP_TESTS} " in *" $$i "*) \
+ echo "-- $$i skipped";; \
+ *) \
if ${.OBJDIR}/$$i; then \
echo "-- $$i passed"; \
else \
echo "-- $$i FAILED (exit code $$?)"; \
- exit 1; \
- fi; \
+ : exit 1; \
+ fi;; \
+ esac; \
done; exit 0
benchmarks: ${BENCHMARKS}
diff --git a/lib/libc_r/TEST/test.h b/lib/libc_r/TEST/test.h
index 1dd97986caf..625be5793a7 100644
--- a/lib/libc_r/TEST/test.h
+++ b/lib/libc_r/TEST/test.h
@@ -2,26 +2,50 @@
#ifndef _h_test_
#define _h_test_
-static __dead void __panic __P((char *filenm, int lineno))
+#include <signal.h>
+
+extern int _thread_sys_write __P((int, const char*, size_t));
+
+static __dead void __panic __P((const char *, int, const char*))
__attribute__((noreturn));
-static void __panic(char *filenm, int lineno) {
- extern int _thread_sys_write __P((int, char*, size_t));
+static void __panic(const char *filenm, int lineno, const char*panicstr) {
extern __dead void _thread_sys__exit __P((int))
__attribute__((noreturn));
extern size_t strlen __P((const char*));
extern int sprintf __P((char *, const char *, ...));
char buf[1024];
- char *panicstr = "\npanic at ";
- _thread_sys_write(2, panicstr, sizeof panicstr - 1);
+ _thread_sys_write(2, panicstr, strlen(panicstr));
sprintf(buf, "%s:%d\n", filenm, lineno);
_thread_sys_write(2, buf, strlen(buf));
+ kill(0, SIGINFO);
_thread_sys__exit(1);
- __panic(NULL, 0);
+ while(1);
}
-#define PANIC() __panic(__FILE__, __LINE__)
+#include <stdarg.h>
+#include <string.h>
+
+static __dead void __die __P((int err, const char *, int, const char *, ...));
+static void __die(int err, const char *file, int line, const char *fmt, ...)
+
+{
+ char buf[1024];
+ va_list ap;
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof buf, fmt, ap);
+ va_end(ap);
+ strlcat(buf, ": ", sizeof buf);
+ strlcat(buf, strerror(err), sizeof buf);
+ _thread_sys_write(2, buf, strlen(buf));
+ __panic(file, line, "\ndied at: ");
+ __die(0,0,0,0);
+}
+
+#define DIE(e, m, args...) __die(e, __FILE__, __LINE__, m , ## args)
+
+#define PANIC() __panic(__FILE__, __LINE__, "\npanic at ")
#define OK (0)
#define NOTOK (-1)
diff --git a/lib/libc_r/TEST/test_create.c b/lib/libc_r/TEST/test_create.c
index e984fe110fe..73c95140b15 100644
--- a/lib/libc_r/TEST/test_create.c
+++ b/lib/libc_r/TEST/test_create.c
@@ -26,13 +26,13 @@ main()
{
pthread_t thread;
int i;
+ int ret;
printf("Original thread stack at %p\n", &i);
- if (pthread_create(&thread, NULL, new_thread, (void *)0xdeadbeef)) {
- printf("Error: creating new thread\n");
- }
- pthread_exit(NULL);
- PANIC();
- return(1);
- PANIC();
+ if ((ret = pthread_create(&thread, NULL, new_thread,
+ (void *)0xdeadbeef)))
+ DIE(ret, "pthread_create");
+ if ((ret = pthread_join(thread, NULL)))
+ DIE(ret, "pthread_join");
+ return(0);
}
diff --git a/lib/libc_r/TEST/test_fork.c b/lib/libc_r/TEST/test_fork.c
index 29309ba7c37..8d44b38c345 100644
--- a/lib/libc_r/TEST/test_fork.c
+++ b/lib/libc_r/TEST/test_fork.c
@@ -39,5 +39,6 @@ main()
}
printf("test_fork PASSED\n");
- pthread_exit(NULL);
+
+ return 0;
}
diff --git a/lib/libc_r/TEST/test_preemption.c b/lib/libc_r/TEST/test_preemption.c
index 1793f022292..9acac1e7986 100644
--- a/lib/libc_r/TEST/test_preemption.c
+++ b/lib/libc_r/TEST/test_preemption.c
@@ -9,15 +9,19 @@
#include <pthread.h>
#include <stdio.h>
+#include "test.h"
void* new_thread(void * new_buf)
{
int i;
+ printf("new_thread\n");
for (i = 0; i < 10; i++) {
+ printf("yielding ");
+ fflush(stdout);
pthread_yield();
}
- printf("test_preemption PASSED\n");
+ printf("yielded 10 times ok\n");
exit(0);
}
@@ -25,14 +29,15 @@ int
main()
{
pthread_t thread;
+ int ret;
printf("test_preemption START\n");
- if (pthread_create(&thread, NULL, new_thread, NULL)) {
- printf("pthread_create failed\n");
- exit(2);
- }
+ if ((ret = pthread_create(&thread, NULL, new_thread, NULL)))
+ DIE(ret, "pthread_create");
while(1);
- exit(1);
+ /* NOTREACHED */
+
+ return (1);
}
diff --git a/lib/libc_r/TEST/test_pthread_join.c b/lib/libc_r/TEST/test_pthread_join.c
index c5f612c58eb..0d5f29a916c 100644
--- a/lib/libc_r/TEST/test_pthread_join.c
+++ b/lib/libc_r/TEST/test_pthread_join.c
@@ -72,6 +72,6 @@ main()
exit(2);
}
printf("test_pthread_join PASSED\n");
- pthread_exit(NULL);
+ return(0);
}
diff --git a/lib/libc_r/TEST/test_pthread_mutex.c b/lib/libc_r/TEST/test_pthread_mutex.c
index 96027de5c03..251ba90f75f 100644
--- a/lib/libc_r/TEST/test_pthread_mutex.c
+++ b/lib/libc_r/TEST/test_pthread_mutex.c
@@ -97,12 +97,15 @@ int test_nocontention_lock(pthread_mutex_t * mutex)
int test_debug_double_lock(pthread_mutex_t * mutex)
{
+ int ret;
+
printf("test_debug_double_lock()\n");
if (pthread_mutex_lock(mutex)) {
printf("pthread_mutex_lock() ERROR\n");
return(NOTOK);
}
- if (pthread_mutex_lock(mutex) != EDEADLK) {
+ if ((ret = pthread_mutex_lock(mutex)) != EDEADLK) {
+ DIE(ret, "test_debug_double_lock: pthread_mutex_lock");
printf("double lock error not detected ERROR\n");
return(NOTOK);
}
@@ -115,6 +118,8 @@ int test_debug_double_lock(pthread_mutex_t * mutex)
int test_debug_double_unlock(pthread_mutex_t * mutex)
{
+ int ret;
+
printf("test_debug_double_unlock()\n");
if (pthread_mutex_lock(mutex)) {
printf("pthread_mutex_lock() ERROR\n");
@@ -124,7 +129,8 @@ int test_debug_double_unlock(pthread_mutex_t * mutex)
printf("pthread_mutex_unlock() ERROR\n");
return(NOTOK);
}
- if (pthread_mutex_unlock(mutex) != EPERM) {
+ if ((ret = pthread_mutex_unlock(mutex)) != EPERM) {
+ DIE(ret, "test_debug_double_unlock: mutex_unlock2");
printf("double unlock error not detected ERROR\n");
return(NOTOK);
}
@@ -184,9 +190,7 @@ int test_mutex_debug()
printf("test_mutex_debug()\n");
pthread_mutexattr_init(&mutex_debug_attr);
-#if 0
- pthread_mutexattr_settype(&mutex_debug_attr, PTHREAD_MUTEXTYPE_DEBUG);
-#endif
+ pthread_mutexattr_settype(&mutex_debug_attr, PTHREAD_MUTEX_ERRORCHECK);
if (pthread_mutex_init(&mutex_debug, &mutex_debug_attr)) {
printf("pthread_mutex_init() ERROR\n");
return(NOTOK);
diff --git a/lib/libc_r/TEST/test_sleep.c b/lib/libc_r/TEST/test_sleep.c
index d13e44123bc..47b476219f7 100644
--- a/lib/libc_r/TEST/test_sleep.c
+++ b/lib/libc_r/TEST/test_sleep.c
@@ -28,8 +28,8 @@ void* new_thread(void* arg)
int
main()
{
- pthread_t thread;
- int count = 2;
+ pthread_t thread[2];
+ int count = sizeof thread/sizeof thread[0];
long i;
printf("Going to sleep\n");
@@ -37,11 +37,13 @@ main()
printf("Done sleeping\n");
for(i = 0; i < count; i++) {
- if (pthread_create(&thread, NULL, new_thread, (void *) i)) {
+ if (pthread_create(&thread[i], NULL, new_thread, (void *) i)) {
printf("error creating new thread %ld\n", i);
}
}
- pthread_exit(NULL);
- fprintf(stderr, "pthread_exit returned\n");
- exit(1);
+
+ for (i = 0; i < count; i++)
+ pthread_join(thread[i], NULL);
+
+ return(0);
}
diff --git a/lib/libc_r/TEST/test_sock_1.c b/lib/libc_r/TEST/test_sock_1.c
index 8b4e594e912..87eec5a8aae 100644
--- a/lib/libc_r/TEST/test_sock_1.c
+++ b/lib/libc_r/TEST/test_sock_1.c
@@ -16,8 +16,10 @@
#include <unistd.h>
#include "test.h"
#include <sched.h>
+#include <string.h>
struct sockaddr_in a_sout;
+int success = 0;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_attr_t attr;
@@ -28,61 +30,53 @@ void * sock_connect(void* arg)
{
char buf[1024];
int fd, tmp;
+ int ret;
/* Ensure sock_read runs first */
- if (pthread_mutex_lock(&mutex)) {
- printf("Error: sock_connect:pthread_mutex_lock()\n");
- exit(1);
- }
+ if ((ret = pthread_mutex_lock(&mutex)))
+ DIE(ret, "sock_connect:pthread_mutex_lock()");
a_sout.sin_addr.s_addr = htonl(0x7f000001); /* loopback */
- if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- printf("Error: sock_connect:socket()\n");
- exit(1);
- }
+ if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+ DIE(errno, "sock_connect:socket()");
printf("This should be message #2\n");
- if (connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) {
- printf("Error: sock_connect:connect()\n");
- exit(1);
- }
+ if (connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0)
+ DIE(errno, "sock_connect:connect()");
+
close(fd);
- if (pthread_mutex_unlock(&mutex)) {
- printf("Error: sock_connect:pthread_mutex_lock()\n");
- exit(1);
- }
+ if ((ret = pthread_mutex_unlock(&mutex)))
+ DIE(ret, "sock_connect:pthread_mutex_lock()");
- if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- printf("Error: sock_connect:socket()\n");
- exit(1);
- }
+ if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+ DIE(ret, "sock_connect:socket()");
printf("This should be message #3\n");
- if (connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) {
- printf("Error: sock_connect:connect()\n");
- exit(1);
- }
+ if (connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0)
+ DIE(errno, "sock_connect:connect()");
/* Ensure sock_read runs again */
pthread_yield();
pthread_yield();
pthread_yield();
pthread_yield();
- if (pthread_mutex_lock(&mutex)) {
- printf("Error: sock_connect:pthread_mutex_lock()\n");
- exit(1);
- }
+ if ((ret = pthread_mutex_lock(&mutex)))
+ DIE(ret, "sock_connect:pthread_mutex_lock()");
+
+ if ((tmp = read(fd, buf, 1024)) <= 0)
+ DIE(errno, "sock_connect:read() == %d", tmp);
- if ((tmp = read(fd, buf, 1024)) <= 0) {
- printf("Error: sock_connect:read() == %d\n", tmp);
- exit(1);
- }
write(fd, MESSAGE6, sizeof(MESSAGE6));
printf("%s\n", buf);
close(fd);
+ success++;
+
+ if ((ret = pthread_mutex_unlock(&mutex)))
+ DIE(ret, "sock_connect:pthread_mutex_unlock()");
+
return(NULL);
}
@@ -102,72 +96,64 @@ void * sock_accept(void* arg)
int a_sin_size, a_fd, fd, tmp;
short port;
char buf[1024];
-
- if (pthread_mutex_unlock(&mutex)) {
- printf("Error: sock_accept:pthread_mutex_lock()\n");
- exit(1);
- }
+ int ret;
port = 3276;
a_sout.sin_family = AF_INET;
a_sout.sin_port = htons(port);
a_sout.sin_addr.s_addr = INADDR_ANY;
- if ((a_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- printf("Error: sock_accept:socket()\n");
- exit(1);
- }
+ if ((a_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+ DIE(errno, "sock_accept:socket()");
while (bind(a_fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) {
if (errno == EADDRINUSE) {
a_sout.sin_port = htons((++port));
continue;
}
- printf("Error: sock_accept:bind()\n");
- exit(1);
+ DIE(errno, "sock_accept:bind()");
}
- if (listen(a_fd, 2)) {
- printf("Error: sock_accept:listen()\n");
- exit(1);
- }
+ if (listen(a_fd, 2))
+ DIE(errno, "sock_accept:listen()");
a_sin_size = sizeof(a_sin);
printf("This should be message #1\n");
- if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) {
- perror("Error: sock_accept:accept()");
- exit(1);
- }
+
+ if ((ret = pthread_create(&thread, &attr, sock_connect,
+ (void *)0xdeadbeaf)))
+ DIE(ret, "sock_accept:pthread_create(sock_connect)");
+
+ if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0)
+ DIE(errno, "sock_accept:accept()");
- if (pthread_mutex_lock(&mutex)) {
- printf("Error: sock_accept:pthread_mutex_lock()\n");
- exit(1);
- }
+ if ((ret = pthread_mutex_lock(&mutex)))
+ DIE(ret, "sock_accept:pthread_mutex_lock()");
+
close(fd);
a_sin_size = sizeof(a_sin);
printf("This should be message #4\n");
- if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) {
- printf("Error: sock_accept:accept()\n");
- exit(1);
- }
+ if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0)
+ DIE(errno, "sock_accept:accept()");
- if (pthread_mutex_unlock(&mutex)) {
- printf("Error: sock_accept:pthread_mutex_lock()\n");
- exit(1);
- }
+ if ((ret = pthread_mutex_unlock(&mutex)))
+ DIE(ret, "sock_accept:pthread_mutex_unlock()");
/* Setup a write thread */
- if (pthread_create(&thread, &attr, sock_write, &fd)) {
- printf("Error: sock_accept:pthread_create(sock_write)\n");
- exit(1);
- }
- if ((tmp = read(fd, buf, 1024)) <= 0) {
- printf("Error: sock_accept:read() == %d\n", tmp);
- exit(1);
- }
+ if ((ret = pthread_create(&thread, &attr, sock_write, &fd)))
+ DIE(ret, "sock_accept:pthread_create(sock_write)");
+ if ((tmp = read(fd, buf, 1024)) <= 0)
+ DIE(errno, "sock_accept:read() == %d\n", tmp);
+
printf("%s\n", buf);
close(fd);
+
+ if ((ret = pthread_mutex_lock(&mutex)))
+ DIE(ret, "sock_accept:pthread_mutex_lock()");
+ success++;
+ if ((ret = pthread_mutex_unlock(&mutex)))
+ DIE(ret, "sock_accept:pthread_mutex_unlock()");
return(NULL);
}
@@ -175,36 +161,23 @@ int
main()
{
pthread_t thread;
+ int ret;
setbuf(stdout, NULL);
setbuf(stderr, NULL);
- /* Ensure sock_read runs first */
- if (pthread_mutex_lock(&mutex)) {
- printf("Error: main:pthread_mutex_lock()\n");
- exit(1);
- }
-
- if (pthread_attr_init(&attr)) {
- printf("Error: main:pthread_attr_init()\n");
- exit(1);
- }
+ if ((ret = pthread_attr_init(&attr)))
+ DIE(ret, "main:pthread_attr_init()");
#if 0
- if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO)) {
- printf("Error: main:pthread_attr_setschedpolicy()\n");
- exit(1);
- }
+ if ((ret = pthread_attr_setschedpolicy(&attr, SCHED_FIFO)))
+ DIE(ret, "main:pthread_attr_setschedpolicy()");
#endif
- if (pthread_create(&thread, &attr, sock_accept, (void *)0xdeadbeaf)) {
- printf("Error: main:pthread_create(sock_accept)\n");
- exit(1);
- }
- if (pthread_create(&thread, &attr, sock_connect, (void *)0xdeadbeaf)) {
- printf("Error: main:pthread_create(sock_connect)\n");
- exit(1);
- }
+ if ((ret = pthread_create(&thread, &attr, sock_accept,
+ (void *)0xdeadbeaf)))
+ DIE(ret, "main:pthread_create(sock_accept)");
+
printf("initial thread %p going to sleep\n", pthread_self());
- sleep(3);
- printf("done sleeping\n");
- return 0;
+ sleep(2);
+ printf("done sleeping. success = %d\n", success);
+ exit(success == 2?0:1);
}
diff --git a/lib/libc_r/TEST/test_sock_2.c b/lib/libc_r/TEST/test_sock_2.c
index 1788d0bbb17..a81fd0a3f69 100644
--- a/lib/libc_r/TEST/test_sock_2.c
+++ b/lib/libc_r/TEST/test_sock_2.c
@@ -15,6 +15,7 @@
#include <netinet/in.h>
#include <unistd.h>
#include <string.h>
+#include "test.h"
struct sockaddr_in a_sout;
@@ -42,52 +43,39 @@ void * sock_accept(void* arg)
a_sout.sin_port = htons(port);
a_sout.sin_addr.s_addr = INADDR_ANY;
- if ((a_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- perror("Error: sock_accept:socket()");
- exit(1);
- }
+ if ((a_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+ DIE(errno, "sock_accept:socket()");
while (bind(a_fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) {
if (errno == EADDRINUSE) {
a_sout.sin_port = htons((++port));
continue;
}
- perror("Error: sock_accept:bind()");
- exit(1);
+ DIE(errno, "sock_accept:bind()");
}
- if (listen(a_fd, 2)) {
- perror("Error: sock_accept:listen()");
- exit(1);
- }
+ if (listen(a_fd, 2))
+ DIE(errno, "sock_accept:listen()");
a_sin_size = sizeof(a_sin);
printf("This should be message #1\n");
- if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) {
- perror("Error: sock_accept:accept()");
- exit(1);
- }
+ if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0)
+ DIE(errno, "Error: sock_accept:accept()");
close(fd);
sleep(1);
a_sin_size = sizeof(a_sin);
memset(&a_sin, 0, sizeof(a_sin));
printf("This should be message #4\n");
- if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) {
- perror("Error: sock_accept:accept()");
- exit(1);
- }
+ if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0)
+ DIE(errno, "sock_accept:accept()");
/* Setup a write thread */
- if (pthread_create(&thread, NULL, sock_write, &fd)) {
- perror("Error: sock_accept:pthread_create(sock_write)");
- exit(1);
- }
- if ((tmp = read(fd, buf, 1024)) <= 0) {
- tmp = read(fd, buf, 1024);
- printf("Error: sock_accept:read() == %d %s\n", tmp, strerror(errno));
- exit(1);
- }
+ if (pthread_create(&thread, NULL, sock_write, &fd))
+ DIE(errno, "sock_accept:pthread_create(sock_write)");
+ if ((tmp = read(fd, buf, 1024)) <= 0)
+ DIE(errno, "Error: sock_accept:read() == %d", tmp);
+
printf("%s\n", buf);
close(fd);
return(NULL);
@@ -97,13 +85,15 @@ int
main()
{
pthread_t thread;
+ int ret;
switch(fork()) {
case -1:
- perror("Error: main:fork()");
- break;
+ DIE(errno, "main:fork()");
+
case 0:
execl("test_sock_2a", "test_sock_2a", "fork okay", NULL);
+ DIE(errno, "execl");
default:
break;
}
@@ -111,9 +101,12 @@ main()
setbuf(stdout, NULL);
setbuf(stderr, NULL);
- if (pthread_create(&thread, NULL, sock_accept, (void *)0xdeadbeaf)) {
- perror("Error: main:pthread_create(sock_accept)");
- exit(1);
- }
- pthread_exit(NULL);
+ if ((ret = pthread_create(&thread, NULL, sock_accept,
+ (void *)0xdeadbeaf)))
+ DIE(ret, "main:pthread_create(sock_accept)");
+
+ if ((ret = pthread_join(thread, NULL)))
+ DIE(ret, "main:pthread_join()");
+
+ return (0);
}
diff --git a/lib/libc_r/TEST/test_switch.c b/lib/libc_r/TEST/test_switch.c
index eedc98c8123..992b1e6c5a1 100644
--- a/lib/libc_r/TEST/test_switch.c
+++ b/lib/libc_r/TEST/test_switch.c
@@ -80,13 +80,7 @@ main(int argc, char **argv)
exit (1);
}
}
-#if 0 /* This would cause the program to loop forever, and "make
- check" would never complete. */
- pthread_exit (NULL);
- fprintf(stderr, "pthread_exit returned\n");
- exit(1);
-#else
- sleep (3);
+ sleep (2);
for (i = 0; i < count; i++)
if (x[i] == 0) {
fprintf (stderr, "thread %ld never ran\n", i);
@@ -94,5 +88,4 @@ main(int argc, char **argv)
}
printf ("\n%s PASSED\n", argv[0]);
return 0;
-#endif
}