summaryrefslogtreecommitdiff
path: root/test/nptl/tst-sem3.c
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2014-08-28 12:31:30 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2014-08-28 13:15:55 +0200
commit512fd3804b963a6738ce59d25dd44a7d9143b8b7 (patch)
tree9b2f4677792ed6df33c6b5d7dcc8f1d7d6b8e711 /test/nptl/tst-sem3.c
parent697dbb016e4bc63d20a7c871a9580e7dce32d1b0 (diff)
test: sync with glibc, use do_test
This breaks out of a deadlock, which occurs when testing for powerpc. (qemu) Otherwise the test suite does not finish. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'test/nptl/tst-sem3.c')
-rw-r--r--test/nptl/tst-sem3.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/test/nptl/tst-sem3.c b/test/nptl/tst-sem3.c
index d14f6f633..7b75e29e2 100644
--- a/test/nptl/tst-sem3.c
+++ b/test/nptl/tst-sem3.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -28,7 +28,7 @@
int
-main (void)
+do_test (void)
{
size_t ps = sysconf (_SC_PAGESIZE);
char tmpfname[] = "/tmp/tst-sem3.XXXXXX";
@@ -43,7 +43,7 @@ main (void)
if (fd == -1)
{
printf ("cannot open temporary file: %m\n");
- exit (1);
+ return 1;
}
/* Make sure it is always removed. */
@@ -56,14 +56,14 @@ main (void)
if (write (fd, data, ps) != (ssize_t) 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 = (sem_t *) (((uintptr_t) mem + __alignof (sem_t))
@@ -73,25 +73,25 @@ main (void)
if (sem_init (s, 1, 1) == -1)
{
puts ("init failed");
- exit (1);
+ return 1;
}
if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1)
{
puts ("1st wait failed");
- exit (1);
+ return 1;
}
errno = 0;
if (TEMP_FAILURE_RETRY (sem_trywait (s)) != -1)
{
puts ("trywait succeeded");
- exit (1);
+ return 1;
}
else if (errno != EAGAIN)
{
puts ("trywait didn't return EAGAIN");
- exit (1);
+ return 1;
}
*p = 0;
@@ -101,7 +101,7 @@ main (void)
if (pid == -1)
{
puts ("fork failed");
- exit (1);
+ return 1;
}
else if (pid == 0)
{
@@ -109,13 +109,13 @@ main (void)
if ((*p)++ != 0)
{
puts ("child: *p != 0");
- exit (1);
+ return 1;
}
if (sem_post (s) == -1)
{
puts ("child: 1st post failed");
- exit (1);
+ return 1;
}
puts ("child done");
@@ -125,17 +125,20 @@ main (void)
if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1)
{
printf ("parent: 2nd wait failed: %m\n");
- exit (1);
+ return 1;
}
if (*p != 1)
{
puts ("*p != 1");
- exit (1);
+ return 1;
}
puts ("parent done");
}
- exit (0);
+ return 0;
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"