svn commit: branches/uClibc-nptl/test/nptl
sjhill at uclibc.org
sjhill at uclibc.org
Sun Feb 19 03:57:55 UTC 2006
Author: sjhill
Date: 2006-02-18 19:57:53 -0800 (Sat, 18 Feb 2006)
New Revision: 14124
Log:
Final 2 tests pass for NPTL. YEEEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.
Added:
branches/uClibc-nptl/test/nptl/tst-exit1.c
branches/uClibc-nptl/test/nptl/tst-join4.c
Modified:
branches/uClibc-nptl/test/nptl/Makefile
Changeset:
Modified: branches/uClibc-nptl/test/nptl/Makefile
===================================================================
--- branches/uClibc-nptl/test/nptl/Makefile 2006-02-18 21:29:08 UTC (rev 14123)
+++ branches/uClibc-nptl/test/nptl/Makefile 2006-02-19 03:57:53 UTC (rev 14124)
@@ -102,11 +102,11 @@
tst-detach1 \
tst-eintr1 tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \
tst-exec2 tst-exec3 tst-exec4 \
- tst-exit2 tst-exit3 \
+ tst-exit1 tst-exit2 tst-exit3 \
tst-flock1 tst-flock2 \
tst-fork1 tst-fork2 tst-fork3 tst-fork4 \
tst-initializers1 \
- tst-join1 tst-join2 tst-join3 tst-join5 \
+ tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 \
tst-key1 tst-key2 tst-key3 tst-key4 \
tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \
tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 tst-mutex5 \
Added: branches/uClibc-nptl/test/nptl/tst-exit1.c
===================================================================
--- branches/uClibc-nptl/test/nptl/tst-exit1.c 2006-02-18 21:29:08 UTC (rev 14123)
+++ branches/uClibc-nptl/test/nptl/tst-exit1.c 2006-02-19 03:57:53 UTC (rev 14124)
@@ -0,0 +1,79 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper at redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* NOTE: this tests functionality beyond POSIX. POSIX does not allow
+ exit to be called more than once. */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static pthread_barrier_t b;
+
+
+static void *
+tf (void *arg)
+{
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ exit (0);
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ /* Do nothing. */
+ if (pthread_join (th, NULL) == 0)
+ {
+ puts ("join succeeded!?");
+ exit (1);
+ }
+
+ puts ("join returned!?");
+ exit (1);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
Added: branches/uClibc-nptl/test/nptl/tst-join4.c
===================================================================
--- branches/uClibc-nptl/test/nptl/tst-join4.c 2006-02-18 21:29:08 UTC (rev 14123)
+++ branches/uClibc-nptl/test/nptl/tst-join4.c 2006-02-19 03:57:53 UTC (rev 14124)
@@ -0,0 +1,125 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper at redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_barrier_t bar;
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_barrier_wait (&bar) != 0)
+ {
+ puts ("tf: barrier_wait failed");
+ exit (1);
+ }
+
+ return (void *) 1l;
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&bar, NULL, 3) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_attr_t a;
+
+ if (pthread_attr_init (&a) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ pthread_t th[2];
+
+ if (pthread_create (&th[0], &a, tf, NULL) != 0)
+ {
+ puts ("1st create failed");
+ exit (1);
+ }
+
+ if (pthread_attr_setdetachstate (&a, PTHREAD_CREATE_DETACHED) != 0)
+ {
+ puts ("attr_setdetachstate failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th[1], &a, tf, NULL) != 0)
+ {
+ puts ("1st create failed");
+ exit (1);
+ }
+
+ if (pthread_attr_destroy (&a) != 0)
+ {
+ puts ("attr_destroy failed");
+ exit (1);
+ }
+
+ if (pthread_detach (th[0]) != 0)
+ {
+ puts ("could not detach 1st thread");
+ exit (1);
+ }
+
+ int err = pthread_detach (th[0]);
+ if (err == 0)
+ {
+ puts ("second detach of 1st thread succeeded");
+ exit (1);
+ }
+ if (err != EINVAL)
+ {
+ printf ("second detach of 1st thread returned %d, not EINVAL\n", err);
+ exit (1);
+ }
+
+ err = pthread_detach (th[1]);
+ if (err == 0)
+ {
+ puts ("detach of 2nd thread succeeded");
+ exit (1);
+ }
+ if (err != EINVAL)
+ {
+ printf ("detach of 2nd thread returned %d, not EINVAL\n", err);
+ exit (1);
+ }
+
+ exit (0);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
More information about the uClibc-cvs
mailing list