summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2003-03-23 10:01:48 +0000
committerRoland McGrath <roland@gnu.org>2003-03-23 10:01:48 +0000
commitb910f7887bdc3c07e460c8ee25ba552c6a2249a5 (patch)
tree06271b5c9ed70bf9c3dd2a08c551a2a54c1ed302
parent24eaaef61dffee283b6d32328f3e5126063d9d2a (diff)
downloadglibc-b910f7887bdc3c07e460c8ee25ba552c6a2249a5.tar.gz
* tst-join5.c (tf1, tf2): Add a cast.
* Makeconfig (includes): Append -I$(..)nptl to this variable. * tst-barrier2.c (do_test) [! _POSIX_THREAD_PROCESS_SHARED]: Don't test anything. * tst-cond4.c: Likewise. * tst-cond6.c: Likewise. * tst-flock2.c: Likewise. * tst-mutex4.c: Likewise. * tst-rwlock4.c: Likewise. * tst-signal1.c: Likewise. * tst-spin2.c: Likewise. * tst-cond11.c [! _POSIX_CLOCK_SELECTION]: Likewise. * tst-mutex4.c: Use test-skeleton.c. * tst-spin2.c: Likewise. * tst-sysconf.c: Likewise. * tst-barrier2.c: Likewise. * tst-cond4.c: Likewise. * tst-cond6.c: Likewise. * tst-rwlock4.c: Likewise. * tst-unload.c: Likewise. * tst-flock2.c (do_test): Use return instead of exit.
-rw-r--r--nptl/ChangeLog27
-rw-r--r--nptl/Makeconfig6
-rw-r--r--nptl/tst-barrier2.c44
-rw-r--r--nptl/tst-cond11.c20
-rw-r--r--nptl/tst-cond4.c72
-rw-r--r--nptl/tst-cond6.c18
-rw-r--r--nptl/tst-flock2.c50
-rw-r--r--nptl/tst-join5.c4
-rw-r--r--nptl/tst-mutex4.c58
-rw-r--r--nptl/tst-rwlock4.c57
-rw-r--r--nptl/tst-signal1.c10
-rw-r--r--nptl/tst-spin2.c44
-rw-r--r--nptl/tst-unload.c15
13 files changed, 274 insertions, 151 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 1665c2b865..fa76272795 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,30 @@
+2003-03-23 Roland McGrath <roland@redhat.com>
+
+ * tst-join5.c (tf1, tf2): Add a cast.
+
+ * Makeconfig (includes): Append -I$(..)nptl to this variable.
+
+ * tst-barrier2.c (do_test) [! _POSIX_THREAD_PROCESS_SHARED]:
+ Don't test anything.
+ * tst-cond4.c: Likewise.
+ * tst-cond6.c: Likewise.
+ * tst-flock2.c: Likewise.
+ * tst-mutex4.c: Likewise.
+ * tst-rwlock4.c: Likewise.
+ * tst-signal1.c: Likewise.
+ * tst-spin2.c: Likewise.
+ * tst-cond11.c [! _POSIX_CLOCK_SELECTION]: Likewise.
+
+ * tst-mutex4.c: Use test-skeleton.c.
+ * tst-spin2.c: Likewise.
+ * tst-sysconf.c: Likewise.
+ * tst-barrier2.c: Likewise.
+ * tst-cond4.c: Likewise.
+ * tst-cond6.c: Likewise.
+ * tst-rwlock4.c: Likewise.
+ * tst-unload.c: Likewise.
+ * tst-flock2.c (do_test): Use return instead of exit.
+
2003-03-22 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/fork.c (__fork): Add libc_hidden_def.
diff --git a/nptl/Makeconfig b/nptl/Makeconfig
index 61015d27f3..381385a948 100644
--- a/nptl/Makeconfig
+++ b/nptl/Makeconfig
@@ -1,4 +1,4 @@
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -28,3 +28,7 @@ static-thread-library = $(common-objpfx)nptl/libpthread.a
bounded-thread-library = $(common-objpfx)nptl/libpthread_b.a
rpath-dirs += nptl
+
+ifneq ($(subdir),nptl)
+includes += -I$(..)nptl
+endif
diff --git a/nptl/tst-barrier2.c b/nptl/tst-barrier2.c
index 5b620b7407..7b9b5cd939 100644
--- a/nptl/tst-barrier2.c
+++ b/nptl/tst-barrier2.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -28,9 +28,15 @@
#include <sys/wait.h>
-int
-main (void)
+static int
+do_test (void)
{
+#if ! _POSIX_THREAD_PROCESS_SHARED
+
+ puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
+
+#else
+
size_t ps = sysconf (_SC_PAGESIZE);
char tmpfname[] = "/tmp/tst-barrier2.XXXXXX";
char data[ps];
@@ -48,7 +54,7 @@ main (void)
if (fd == -1)
{
printf ("cannot open temporary file: %m\n");
- exit (1);
+ return 1;
}
/* Make sure it is always removed. */
@@ -61,14 +67,14 @@ main (void)
if (write (fd, data, ps) != ps)
{
puts ("short write");
- exit (1);
+ return 1;
}
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (mem == MAP_FAILED)
{
printf ("mmap failed: %m\n");
- exit (1);
+ return 1;
}
b = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t))
@@ -77,49 +83,49 @@ main (void)
if (pthread_barrierattr_init (&a) != 0)
{
puts ("barrierattr_init failed");
- exit (1);
+ return 1;
}
if (pthread_barrierattr_getpshared (&a, &p) != 0)
{
puts ("1st barrierattr_getpshared failed");
- exit (1);
+ return 1;
}
if (p != PTHREAD_PROCESS_PRIVATE)
{
puts ("default pshared value wrong");
- exit (1);
+ return 1;
}
if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
{
puts ("barrierattr_setpshared failed");
- exit (1);
+ return 1;
}
if (pthread_barrierattr_getpshared (&a, &p) != 0)
{
puts ("2nd barrierattr_getpshared failed");
- exit (1);
+ return 1;
}
if (p != PTHREAD_PROCESS_SHARED)
{
puts ("pshared value after setpshared call wrong");
- exit (1);
+ return 1;
}
if (pthread_barrier_init (b, &a, 2) != 0)
{
puts ("barrier_init failed");
- exit (1);
+ return 1;
}
if (pthread_barrierattr_destroy (&a) != 0)
{
puts ("barrierattr_destroy failed");
- exit (1);
+ return 1;
}
puts ("going to fork now");
@@ -127,7 +133,7 @@ main (void)
if (pid == -1)
{
puts ("fork failed");
- exit (1);
+ return 1;
}
/* Just to be sure we don't hang forever. */
@@ -145,7 +151,7 @@ main (void)
{
printf ("%s: barrier_wait returned value %d != 0 and PTHREAD_BARRIER_SERIAL_THREAD\n",
pid == 0 ? "child" : "parent", e);
- exit (1);
+ return 1;
}
}
@@ -177,6 +183,10 @@ main (void)
WEXITSTATUS (status) + serials, N);
return 1;
}
+#endif
- exit (0);
+ return 0;
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-cond11.c b/nptl/tst-cond11.c
index 6c7758bf68..079dec5afc 100644
--- a/nptl/tst-cond11.c
+++ b/nptl/tst-cond11.c
@@ -24,6 +24,7 @@
#include <unistd.h>
+#if _POSIX_CLOCK_SELECTION
static int
run_test (clockid_t cl)
{
@@ -149,15 +150,23 @@ run_test (clockid_t cl)
return 0;
}
+#endif
static int
do_test (void)
{
+#if ! _POSIX_CLOCK_SELECTION
+
+ puts ("_POSIX_CLOCK_SELECTION not supported, test skipped");
+ return 0;
+
+#else
+
int res = run_test (CLOCK_REALTIME);
-#if defined _POSIX_MONOTONIC_CLOCK
-# if _POSIX_MONOTONIC_CLOCK == 0
+# if defined _POSIX_MONOTONIC_CLOCK
+# if _POSIX_MONOTONIC_CLOCK == 0
int e = sysconf (_SC_MONOTONIC_CLOCK);
if (e < 0)
puts ("CLOCK_MONOTONIC not supported");
@@ -167,13 +176,14 @@ do_test (void)
res = 1;
}
else
-# endif
+# endif
res |= run_test (CLOCK_MONOTONIC);
-#else
+# else
puts ("_POSIX_MONOTONIC_CLOCK not defined");
-#endif
+# endif
return res;
+#endif
}
#define TIMEOUT 3
diff --git a/nptl/tst-cond4.c b/nptl/tst-cond4.c
index 6b57fbc7ee..cc888e0ce4 100644
--- a/nptl/tst-cond4.c
+++ b/nptl/tst-cond4.c
@@ -29,10 +29,16 @@
int *condition;
-
-int
-main (void)
+static int
+do_test (void)
{
+#if ! _POSIX_THREAD_PROCESS_SHARED
+
+ puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
+ return 0;
+
+#else
+
size_t ps = sysconf (_SC_PAGESIZE);
char tmpfname[] = "/tmp/tst-cond4.XXXXXX";
char data[ps];
@@ -51,7 +57,7 @@ main (void)
if (fd == -1)
{
printf ("cannot open temporary file: %m\n");
- exit (1);
+ return 1;
}
/* Make sure it is always removed. */
@@ -64,14 +70,14 @@ main (void)
if (write (fd, data, ps) != ps)
{
puts ("short write");
- exit (1);
+ return 1;
}
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (mem == MAP_FAILED)
{
printf ("mmap failed: %m\n");
- exit (1);
+ return 1;
}
mut1 = (pthread_mutex_t *) (((uintptr_t) mem
@@ -89,97 +95,97 @@ main (void)
if (pthread_mutexattr_init (&ma) != 0)
{
puts ("mutexattr_init failed");
- exit (1);
+ return 1;
}
if (pthread_mutexattr_getpshared (&ma, &p) != 0)
{
puts ("1st mutexattr_getpshared failed");
- exit (1);
+ return 1;
}
if (p != PTHREAD_PROCESS_PRIVATE)
{
puts ("default pshared value wrong");
- exit (1);
+ return 1;
}
if (pthread_mutexattr_setpshared (&ma, PTHREAD_PROCESS_SHARED) != 0)
{
puts ("mutexattr_setpshared failed");
- exit (1);
+ return 1;
}
if (pthread_mutexattr_getpshared (&ma, &p) != 0)
{
puts ("2nd mutexattr_getpshared failed");
- exit (1);
+ return 1;
}
if (p != PTHREAD_PROCESS_SHARED)
{
puts ("pshared value after setpshared call wrong");
- exit (1);
+ return 1;
}
if (pthread_mutex_init (mut1, &ma) != 0)
{
puts ("1st mutex_init failed");
- exit (1);
+ return 1;
}
if (pthread_mutex_init (mut2, &ma) != 0)
{
puts ("2nd mutex_init failed");
- exit (1);
+ return 1;
}
if (pthread_condattr_init (&ca) != 0)
{
puts ("condattr_init failed");
- exit (1);
+ return 1;
}
if (pthread_condattr_getpshared (&ca, &p) != 0)
{
puts ("1st condattr_getpshared failed");
- exit (1);
+ return 1;
}
if (p != PTHREAD_PROCESS_PRIVATE)
{
puts ("default value for pshared in condattr wrong");
- exit (1);
+ return 1;
}
if (pthread_condattr_setpshared (&ca, PTHREAD_PROCESS_SHARED) != 0)
{
puts ("condattr_setpshared failed");
- exit (1);
+ return 1;
}
if (pthread_condattr_getpshared (&ca, &p) != 0)
{
puts ("2nd condattr_getpshared failed");
- exit (1);
+ return 1;
}
if (p != PTHREAD_PROCESS_SHARED)
{
puts ("pshared condattr still not set");
- exit (1);
+ return 1;
}
if (pthread_cond_init (cond, &ca) != 0)
{
puts ("cond_init failed");
- exit (1);
+ return 1;
}
if (pthread_mutex_lock (mut1) != 0)
{
puts ("parent: 1st mutex_lock failed");
- exit (1);
+ return 1;
}
puts ("going to fork now");
@@ -187,34 +193,34 @@ main (void)
if (pid == -1)
{
puts ("fork failed");
- exit (1);
+ return 1;
}
else if (pid == 0)
{
if (pthread_mutex_lock (mut2) != 0)
{
puts ("child: mutex_lock failed");
- exit (1);
+ return 1;
}
if (pthread_mutex_unlock (mut1) != 0)
{
puts ("child: 1st mutex_unlock failed");
- exit (1);
+ return 1;
}
do
if (pthread_cond_wait (cond, mut2) != 0)
{
puts ("child: cond_wait failed");
- exit (1);
+ return 1;
}
while (*condition == 0);
if (pthread_mutex_unlock (mut2) != 0)
{
puts ("child: 2nd mutex_unlock failed");
- exit (1);
+ return 1;
}
puts ("child done");
@@ -226,19 +232,19 @@ main (void)
if (pthread_mutex_lock (mut1) != 0)
{
puts ("parent: 2nd mutex_lock failed");
- exit (1);
+ return 1;
}
if (pthread_mutex_lock (mut2) != 0)
{
puts ("parent: 3rd mutex_lock failed");
- exit (1);
+ return 1;
}
if (pthread_cond_signal (cond) != 0)
{
puts ("parent: cond_signal failed");
- exit (1);
+ return 1;
}
*condition = 1;
@@ -246,7 +252,7 @@ main (void)
if (pthread_mutex_unlock (mut2) != 0)
{
puts ("parent: mutex_unlock failed");
- exit (1);
+ return 1;
}
puts ("waiting for child");
@@ -258,4 +264,8 @@ main (void)
}
return result;
+#endif
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-cond6.c b/nptl/tst-cond6.c
index 63c54705db..21821442ac 100644
--- a/nptl/tst-cond6.c
+++ b/nptl/tst-cond6.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -31,10 +31,16 @@
int *condition;
-
-int
-main (void)
+static int
+do_test (void)
{
+#if ! _POSIX_THREAD_PROCESS_SHARED
+
+ puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
+ return 0;
+
+#else
+
size_t ps = sysconf (_SC_PAGESIZE);
char tmpfname[] = "/tmp/tst-cond6.XXXXXX";
char data[ps];
@@ -230,4 +236,8 @@ main (void)
}
return result;
+#endif
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-flock2.c b/nptl/tst-flock2.c
index 52d02dc9bb..fdbffbb272 100644
--- a/nptl/tst-flock2.c
+++ b/nptl/tst-flock2.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -59,13 +59,20 @@ tf (void *arg)
static int
do_test (void)
{
+#if ! _POSIX_THREAD_PROCESS_SHARED
+
+ puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
+ return 0;
+
+#else
+
char tmp[] = "/tmp/tst-flock2-XXXXXX";
fd = mkstemp (tmp);
if (fd == -1)
{
puts ("mkstemp failed");
- exit (1);
+ return 1;
}
unlink (tmp);
@@ -80,32 +87,32 @@ do_test (void)
if (b == MAP_FAILED)
{
puts ("mmap failed");
- exit (1);
+ return 1;
}
pthread_barrierattr_t ba;
if (pthread_barrierattr_init (&ba) != 0)
{
puts ("barrierattr_init failed");
- exit (1);
+ return 1;
}
if (pthread_barrierattr_setpshared (&ba, PTHREAD_PROCESS_SHARED) != 0)
{
puts ("barrierattr_setpshared failed");
- exit (1);
+ return 1;
}
if (pthread_barrier_init (b, &ba, 2) != 0)
{
puts ("barrier_init failed");
- exit (1);
+ return 1;
}
if (pthread_barrierattr_destroy (&ba) != 0)
{
puts ("barrierattr_destroy failed");
- exit (1);
+ return 1;
}
struct flock fl =
@@ -118,14 +125,14 @@ do_test (void)
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
{
puts ("first fcntl failed");
- exit (1);
+ return 1;
}
pid_t pid = fork ();
if (pid == -1)
{
puts ("fork failed");
- exit (1);
+ return 1;
}
if (pid == 0)
@@ -137,7 +144,7 @@ do_test (void)
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
{
puts ("child: second flock succeeded");
- exit (1);
+ return 1;
}
}
@@ -149,7 +156,7 @@ do_test (void)
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
{
puts ("third fcntl failed");
- exit (1);
+ return 1;
}
}
@@ -161,25 +168,25 @@ do_test (void)
if (pthread_mutex_lock (&lock) != 0)
{
puts ("1st locking of lock failed");
- exit (1);
+ return 1;
}
if (pthread_mutex_lock (&lock2) != 0)
{
puts ("1st locking of lock2 failed");
- exit (1);
+ return 1;
}
if (pthread_create (&th, NULL, tf, NULL) != 0)
{
puts ("pthread_create failed");
- exit (1);
+ return 1;
}
if (pthread_mutex_lock (&lock) != 0)
{
puts ("2nd locking of lock failed");
- exit (1);
+ return 1;
}
puts ("child locked file");
@@ -193,7 +200,7 @@ do_test (void)
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
{
puts ("fifth fcntl succeeded");
- exit (1);
+ return 1;
}
puts ("file locked by child");
@@ -206,13 +213,13 @@ do_test (void)
if (pthread_mutex_unlock (&lock2) != 0)
{
puts ("unlock of lock2 failed");
- exit (1);
+ return 1;
}
if (pthread_join (th, NULL) != 0)
{
puts ("join failed");
- exit (1);
+ return 1;
}
puts ("child's thread terminated");
@@ -226,7 +233,7 @@ do_test (void)
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
{
puts ("fifth fcntl succeeded");
- exit (1);
+ return 1;
}
puts ("file still locked");
@@ -243,17 +250,18 @@ do_test (void)
if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
{
puts ("waitpid failed");
- exit (1);
+ return 1;
}
puts ("child terminated");
if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
{
puts ("sixth fcntl failed");
- exit (1);
+ return 1;
}
return status;
+#endif
}
#define TEST_FUNCTION do_test ()
diff --git a/nptl/tst-join5.c b/nptl/tst-join5.c
index 68c4ac6fc6..589fac6b5f 100644
--- a/nptl/tst-join5.c
+++ b/nptl/tst-join5.c
@@ -26,7 +26,7 @@
static void *
tf1 (void *arg)
{
- pthread_join (arg, NULL);
+ pthread_join ((pthread_t) arg, NULL);
puts ("1st join returned");
@@ -37,7 +37,7 @@ tf1 (void *arg)
static void *
tf2 (void *arg)
{
- pthread_join (arg, NULL);
+ pthread_join ((pthread_t) arg, NULL);
puts ("2nd join returned");
diff --git a/nptl/tst-mutex4.c b/nptl/tst-mutex4.c
index 5e71d9fbf6..89995b15b7 100644
--- a/nptl/tst-mutex4.c
+++ b/nptl/tst-mutex4.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -28,9 +28,16 @@
#include <sys/wait.h>
-int
-main (void)
+static int
+do_test (void)
{
+#if ! _POSIX_THREAD_PROCESS_SHARED
+
+ puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
+ return 0;
+
+#else
+
size_t ps = sysconf (_SC_PAGESIZE);
char tmpfname[] = "/tmp/tst-mutex4.XXXXXX";
char data[ps];
@@ -47,7 +54,7 @@ main (void)
if (fd == -1)
{
printf ("cannot open temporary file: %m\n");
- exit (1);
+ return 1;
}
/* Make sure it is always removed. */
@@ -60,14 +67,14 @@ main (void)
if (write (fd, data, ps) != ps)
{
puts ("short write");
- exit (1);
+ return 1;
}
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (mem == MAP_FAILED)
{
printf ("mmap failed: %m\n");
- exit (1);
+ return 1;
}
m = (pthread_mutex_t *) (((uintptr_t) mem + __alignof (pthread_mutex_t))
@@ -77,67 +84,67 @@ main (void)
if (pthread_mutexattr_init (&a) != 0)
{
puts ("mutexattr_init failed");
- exit (1);
+ return 1;
}
if (pthread_mutexattr_getpshared (&a, &s) != 0)
{
puts ("1st mutexattr_getpshared failed");
- exit (1);
+ return 1;
}
if (s != PTHREAD_PROCESS_PRIVATE)
{
puts ("default pshared value wrong");
- exit (1);
+ return 1;
}
if (pthread_mutexattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
{
puts ("mutexattr_setpshared failed");
- exit (1);
+ return 1;
}
if (pthread_mutexattr_getpshared (&a, &s) != 0)
{
puts ("2nd mutexattr_getpshared failed");
- exit (1);
+ return 1;
}
if (s != PTHREAD_PROCESS_SHARED)
{
puts ("pshared value after setpshared call wrong");
- exit (1);
+ return 1;
}
if (pthread_mutex_init (m, &a) != 0)
{
puts ("mutex_init failed");
- exit (1);
+ return 1;
}
if (pthread_mutex_lock (m) != 0)
{
puts ("mutex_lock failed");
- exit (1);
+ return 1;
}
if (pthread_mutexattr_destroy (&a) != 0)
{
puts ("mutexattr_destroy failed");
- exit (1);
+ return 1;
}
err = pthread_mutex_trylock (m);
if (err == 0)
{
puts ("mutex_trylock succeeded");
- exit (1);
+ return 1;
}
else if (err != EBUSY)
{
puts ("mutex_trylock didn't return EBUSY");
- exit (1);
+ return 1;
}
*p = 0;
@@ -147,7 +154,7 @@ main (void)
if (pid == -1)
{
puts ("fork failed");
- exit (1);
+ return 1;
}
else if (pid == 0)
{
@@ -155,13 +162,13 @@ main (void)
if ((*p)++ != 0)
{
puts ("child: *p != 0");
- exit (1);
+ return 1;
}
if (pthread_mutex_unlock (m) != 0)
{
puts ("child: 1st mutex_unlock failed");
- exit (1);
+ return 1;
}
puts ("child done");
@@ -171,17 +178,22 @@ main (void)
if (pthread_mutex_lock (m) != 0)
{
puts ("parent: 2nd mutex_lock failed");
- exit (1);
+ return 1;
}
if (*p != 1)
{
puts ("*p != 1");
- exit (1);
+ return 1;
}
puts ("parent done");
}
- exit (0);
+ return 0;
+#endif
}
+
+#define TIMEOUT 4
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-rwlock4.c b/nptl/tst-rwlock4.c
index 2bf54167b6..b3dddd9d33 100644
--- a/nptl/tst-rwlock4.c
+++ b/nptl/tst-rwlock4.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -28,9 +28,16 @@
#include <sys/wait.h>
-int
-main (void)
+static int
+do_test (void)
{
+#if ! _POSIX_THREAD_PROCESS_SHARED
+
+ puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
+ return 0;
+
+#else
+
size_t ps = sysconf (_SC_PAGESIZE);
char tmpfname[] = "/tmp/tst-rwlock4.XXXXXX";
char data[ps];
@@ -47,7 +54,7 @@ main (void)
if (fd == -1)
{
printf ("cannot open temporary file: %m\n");
- exit (1);
+ return 1;
}
/* Make sure it is always removed. */
@@ -60,14 +67,14 @@ main (void)
if (write (fd, data, ps) != ps)
{
puts ("short write");
- exit (1);
+ return 1;
}
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (mem == MAP_FAILED)
{
printf ("mmap failed: %m\n");
- exit (1);
+ return 1;
}
r = (pthread_rwlock_t *) (((uintptr_t) mem + __alignof (pthread_rwlock_t))
@@ -77,67 +84,67 @@ main (void)
if (pthread_rwlockattr_init (&a) != 0)
{
puts ("rwlockattr_init failed");
- exit (1);
+ return 1;
}
if (pthread_rwlockattr_getpshared (&a, &s) != 0)
{
puts ("1st rwlockattr_getpshared failed");
- exit (1);
+ return 1;
}
if (s != PTHREAD_PROCESS_PRIVATE)
{
puts ("default pshared value wrong");
- exit (1);
+ return 1;
}
if (pthread_rwlockattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
{
puts ("rwlockattr_setpshared failed");
- exit (1);
+ return 1;
}
if (pthread_rwlockattr_getpshared (&a, &s) != 0)
{
puts ("2nd rwlockattr_getpshared failed");
- exit (1);
+ return 1;
}
if (s != PTHREAD_PROCESS_SHARED)
{
puts ("pshared value after setpshared call wrong");
- exit (1);
+ return 1;
}
if (pthread_rwlock_init (r, &a) != 0)
{
puts ("rwlock_init failed");
- exit (1);
+ return 1;
}
if (pthread_rwlock_rdlock (r) != 0)
{
puts ("rwlock_rdlock failed");
- exit (1);
+ return 1;
}
if (pthread_rwlockattr_destroy (&a) != 0)
{
puts ("rwlockattr_destroy failed");
- exit (1);
+ return 1;
}
err = pthread_rwlock_trywrlock (r);
if (err == 0)
{
puts ("rwlock_trywrlock succeeded");
- exit (1);
+ return 1;
}
else if (err != EBUSY)
{
puts ("rwlock_trywrlock didn't return EBUSY");
- exit (1);
+ return 1;
}
*p = 0;
@@ -147,7 +154,7 @@ main (void)
if (pid == -1)
{
puts ("fork failed");
- exit (1);
+ return 1;
}
else if (pid == 0)
{
@@ -155,13 +162,13 @@ main (void)
if ((*p)++ != 0)
{
puts ("child: *p != 0");
- exit (1);
+ return 1;
}
if (pthread_rwlock_unlock (r) != 0)
{
puts ("child: 1st rwlock_unlock failed");
- exit (1);
+ return 1;
}
puts ("child done");
@@ -171,17 +178,21 @@ main (void)
if (pthread_rwlock_wrlock (r) != 0)
{
puts ("parent: rwlock_wrlock failed");
- exit (1);
+ return 1;
}
if (*p != 1)
{
puts ("*p != 1");
- exit (1);
+ return 1;
}
puts ("parent done");
}
- exit (0);
+ return 0;
+#endif
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-signal1.c b/nptl/tst-signal1.c
index e7480f547a..ad4b7870cf 100644
--- a/nptl/tst-signal1.c
+++ b/nptl/tst-signal1.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -94,6 +94,13 @@ receiver (void)
static int
do_test (void)
{
+#if ! _POSIX_THREAD_PROCESS_SHARED
+
+ puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
+ return 0;
+
+#else
+
char tmp[] = "/tmp/tst-signal1-XXXXXX";
int fd = mkstemp (tmp);
@@ -183,6 +190,7 @@ do_test (void)
}
return 0;
+#endif
}
#define TEST_FUNCTION do_test ()
diff --git a/nptl/tst-spin2.c b/nptl/tst-spin2.c
index c55bc65779..84f0064c17 100644
--- a/nptl/tst-spin2.c
+++ b/nptl/tst-spin2.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -28,9 +28,15 @@
#include <sys/wait.h>
-int
-main (void)
+static int
+do_test (void)
{
+#if ! _POSIX_THREAD_PROCESS_SHARED
+
+ puts ("_POSIX_THREAD_PROCESS_SHARED not supported, test skipped");
+
+#else
+
size_t ps = sysconf (_SC_PAGESIZE);
char tmpfname[] = "/tmp/tst-spin2.XXXXXX";
char data[ps];
@@ -45,7 +51,7 @@ main (void)
if (fd == -1)
{
printf ("cannot open temporary file: %m\n");
- exit (1);
+ return 1;
}
/* Make sure it is always removed. */
@@ -58,14 +64,14 @@ main (void)
if (write (fd, data, ps) != ps)
{
puts ("short write");
- exit (1);
+ return 1;
}
mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (mem == MAP_FAILED)
{
printf ("mmap failed: %m\n");
- exit (1);
+ return 1;
}
s = (pthread_spinlock_t *) (((uintptr_t) mem
@@ -76,39 +82,39 @@ main (void)
if (pthread_spin_init (s, PTHREAD_PROCESS_SHARED) != 0)
{
puts ("spin_init failed");
- exit (1);
+ return 1;
}
if (pthread_spin_lock (s) != 0)
{
puts ("spin_lock failed");
- exit (1);
+ return 1;
}
err = pthread_spin_trylock (s);
if (err == 0)
{
puts ("1st spin_trylock succeeded");
- exit (1);
+ return 1;
}
else if (err != EBUSY)
{
puts ("1st spin_trylock didn't return EBUSY");
- exit (1);
+ return 1;
}
err = pthread_spin_unlock (s);
if (err != 0)
{
puts ("parent: spin_unlock failed");
- exit (1);
+ return 1;
}
err = pthread_spin_trylock (s);
if (err != 0)
{
puts ("2nd spin_trylock failed");
- exit (1);
+ return 1;
}
*p = 0;
@@ -118,7 +124,7 @@ main (void)
if (pid == -1)
{
puts ("fork failed");
- exit (1);
+ return 1;
}
else if (pid == 0)
{
@@ -126,13 +132,13 @@ main (void)
if ((*p)++ != 0)
{
puts ("child: *p != 0");
- exit (1);
+ return 1;
}
if (pthread_spin_unlock (s) != 0)
{
puts ("child: 1st spin_unlock failed");
- exit (1);
+ return 1;
}
puts ("child done");
@@ -142,7 +148,7 @@ main (void)
if (pthread_spin_lock (s) != 0)
{
puts ("parent: 2nd spin_lock failed");
- exit (1);
+ return 1;
}
puts ("waiting for child");
@@ -151,6 +157,10 @@ main (void)
puts ("parent done");
}
+#endif
- exit (0);
+ return 0;
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-unload.c b/nptl/tst-unload.c
index 4494ce88c7..ca779fe1b5 100644
--- a/nptl/tst-unload.c
+++ b/nptl/tst-unload.c
@@ -1,5 +1,5 @@
/* Tests for non-unloading of libpthread.
- Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,24 +22,27 @@
#include <stdlib.h>
#include <gnu/lib-names.h>
-int
-main (void)
+static int
+do_test (void)
{
void *p = dlopen (PREFIX LIBPTHREAD_SO, RTLD_LAZY);
if (p == NULL)
{
puts ("failed to load " LIBPTHREAD_SO);
- exit (1);
+ return 1;
}
if (dlclose (p) != 0)
{
puts ("dlclose (" LIBPTHREAD_SO ") failed");
- exit (1);
+ return 1;
}
puts ("seems to work");
- exit (0);
+ return 0;
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"