From e65912f8b2a6fa966b1ba45360070cf9f25568b4 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Fri, 28 Oct 2016 18:43:57 +0200 Subject: rework most tests to work as standalone package --- test/nptl/Makefile.in | 80 +++++++++-------------------------------------- test/nptl/tst-cancel25.c | 4 ++- test/nptl/tst-cancel4.c | 2 +- test/nptl/tst-getpid1.c | 7 ++++- test/nptl/tst-sem11.c | 36 +++++++++++++++------ test/nptl/tst-signal7.c | 7 +++-- test/nptl/tst-tls1.c | 14 ++------- test/nptl/tst-tls2.c | 14 ++------- test/nptl/tst-tls3.c | 2 -- test/nptl/tst-tls3mod.c | 2 -- test/nptl/tst-tls4.c | 1 - test/nptl/tst-tls4moda.c | 1 - test/nptl/tst-tls4modb.c | 1 - test/nptl/tst-tls5.h | 1 - test/nptl/tst-typesizes.c | 2 +- 15 files changed, 60 insertions(+), 114 deletions(-) (limited to 'test/nptl') diff --git a/test/nptl/Makefile.in b/test/nptl/Makefile.in index 9a3b104..341f909 100644 --- a/test/nptl/Makefile.in +++ b/test/nptl/Makefile.in @@ -1,4 +1,4 @@ -# uClibc NPTL tests +# uClibc-ng NPTL tests # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. TESTS := tst-align tst-align2 tst-atfork1 tst-attr1 tst-attr2 tst-attr3 \ @@ -41,7 +41,7 @@ TESTS := tst-align tst-align2 tst-atfork1 tst-attr1 tst-attr2 tst-attr3 \ tst-getpid1 tst-getpid2 tst-getpid3 tst-join6 tst-tsd6 \ tst-oddstacklimit tst-oncex3 tst-oncex4 tst-rwlock2a \ tst-basic7 tst-signal7 tst-vfork1x tst-vfork2x tst-sem10 tst-sem11 \ - tst-sem12 tst-typesizes tst-initializers1-c89 tst-initializers1-c99 \ + tst-sem12 tst-initializers1-c89 tst-initializers1-c99 \ tst-initializers1-gnu89 tst-initializers1-gnu99 \ tst-atfork2 @@ -54,33 +54,6 @@ TESTS += tst-clock tst-clock_nanosleep tst-cpuclock1 tst-cpuclock2 \ tst-mqueue7 tst-mqueue8 tst-mqueue9 tst-timer2 tst-timer3 \ tst-timer4 tst-timer5 -ifeq ($(UCLIBC_HAS_OBSOLETE_BSD_SIGNAL),) -TESTS_DISABLED += tst-exec2 tst-exec3 tst-exec4 -endif - -ifeq ($(UCLIBC_SUSV4_LEGACY),) -TESTS_DISABLED += tst-basic5 tst-cancel4 tst-cancel5 tst-cancelx4 -endif - -GLIBC_TESTS_DISABLED := tst-eintr1_glibc tst-eintr2_glibc \ - tst-eintr3_glibc tst-eintr4_glibc tst-eintr5_glibc \ - tst-tls1_glibc tst-tls2_glibc - - -ifeq ($(HAVE_SHARED),) -TESTS_DISABLED += tst-tls3 tst-tls4 tst-tls5 tst-dlsym1 tst-fini1 \ - tst-unload -else -GLIBC_TESTS_DISABLED += tst-tls3_glibc tst-tls4_glibc tst-tls5_glibc -endif - -EXTRA_CFLAGS := -DNOT_IN_libc=1 -D_LIBC -D__USE_GNU -std=gnu99 \ - $(PTINC) \ - -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) \ - -I$(top_srcdir)libc/sysdeps/linux \ - -I$(top_builddir)include \ - -include $(top_builddir)include/libc-symbols.h - ifeq ($(TARGET_ARCH),i386) CFLAGS_tst-align := -malign-double -mpreferred-stack-boundary=4 endif @@ -89,45 +62,21 @@ CFLAGS_tst-align := -malign-double -mpreferred-stack-boundary=4 -msse endif CFLAGS_tst-cleanup4aux.o := -W CFLAGS_tst-initializers1 := -W -Werror -CFLAGS_tst-tls3mod.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc -CFLAGS_tst-tls4moda.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc -CFLAGS_tst-tls4modb.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc -CFLAGS_tst-tls5mod.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc -CFLAGS_tst-tls5moda.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc -CFLAGS_tst-tls5modb.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc -CFLAGS_tst-tls5modc.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc -CFLAGS_tst-tls5modd.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc -CFLAGS_tst-tls5mode.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc -CFLAGS_tst-tls5modf.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc - -CFLAGS_tst-fini1mod.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc +CFLAGS_tst-tls3mod.so := -fPIC -DPIC -DSHARED -shared +CFLAGS_tst-tls4moda.so := -fPIC -DPIC -DSHARED -shared +CFLAGS_tst-tls4modb.so := -fPIC -DPIC -DSHARED -shared +CFLAGS_tst-tls5mod.so := -fPIC -DPIC -DSHARED -shared +CFLAGS_tst-tls5moda.so := -fPIC -DPIC -DSHARED -shared +CFLAGS_tst-tls5modb.so := -fPIC -DPIC -DSHARED -shared +CFLAGS_tst-tls5modc.so := -fPIC -DPIC -DSHARED -shared +CFLAGS_tst-tls5modd.so := -fPIC -DPIC -DSHARED -shared +CFLAGS_tst-tls5mode.so := -fPIC -DPIC -DSHARED -shared +CFLAGS_tst-tls5modf.so := -fPIC -DPIC -DSHARED -shared + +CFLAGS_tst-fini1mod.so := -fPIC -DPIC -DSHARED -shared LDFLAGS_tst-cond11 = -lrt LDFLAGS_tst-cond19 = -lrt -LDFLAGS_tst-cancelx2 = -lc -LDFLAGS_tst-cancelx3 = -lc -LDFLAGS_tst-cancelx4 = -lc -LDFLAGS_tst-cancelx6 = -lc -LDFLAGS_tst-cancelx6 = -lc -LDFLAGS_tst-cancelx7 = -lc -LDFLAGS_tst-cancelx8 = -lc -LDFLAGS_tst-cancelx9 = -lc -LDFLAGS_tst-cancelx10 = -lc -LDFLAGS_tst-cancelx11 = -lc -LDFLAGS_tst-cancelx12 = -lc -LDFLAGS_tst-cancelx13 = -lc -LDFLAGS_tst-cancelx14 = -lc -LDFLAGS_tst-cancelx15 = -lc -LDFLAGS_tst-cancelx16 = -lc -LDFLAGS_tst-cancelx18 = -lc -LDFLAGS_tst-cancelx20 = -lc -LDFLAGS_tst-cancelx21 = -lc -LDFLAGS_tst-cleanupx0 = -lc -LDFLAGS_tst-cleanupx1 = -lc -LDFLAGS_tst-cleanupx2 = -lc -LDFLAGS_tst-cleanupx3 = -lc -LDFLAGS_tst-oncex3 = -lc -LDFLAGS_tst-oncex4 = -lc LDFLAGS_tst-rwlock14 = -lrt LDFLAGS_tst-fini1 = -Wl,-rpath=./ tst-fini1mod.so LDFLAGS_tst-fini1mod.so = -Wl,-soname=tst-fini1mod.so @@ -233,7 +182,6 @@ tst-cleanupx4 : tst-cleanup4aux.o tst-fini1: tst-fini1mod.so tst-atfork2: tst-atfork2mod.so -tst-atfork2_glibc: tst-atfork2mod.so.glibc OPTS_tst-cancel7 = -c ./tst-cancel7 OPTS_tst-mqueue7 = -- ./tst-mqueue7 diff --git a/test/nptl/tst-cancel25.c b/test/nptl/tst-cancel25.c index 00b99ad..c724d8a 100644 --- a/test/nptl/tst-cancel25.c +++ b/test/nptl/tst-cancel25.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -11,6 +11,7 @@ static pthread_t th2; static void * tf2 (void *arg) { +#ifdef SIGCANCEL sigset_t mask; if (pthread_sigmask (SIG_SETMASK, NULL, &mask) != 0) { @@ -22,6 +23,7 @@ tf2 (void *arg) puts ("SIGCANCEL blocked in new thread"); exit (1); } +#endif /* Sync with the main thread so that we do not test anything else. */ int e = pthread_barrier_wait (&b); diff --git a/test/nptl/tst-cancel4.c b/test/nptl/tst-cancel4.c index ecaf297..696a527 100644 --- a/test/nptl/tst-cancel4.c +++ b/test/nptl/tst-cancel4.c @@ -38,7 +38,7 @@ #include #include -#include "pthreadP.h" +#define SIGCANCEL __SIGRTMIN /* Since STREAMS are not supported in the standard Linux kernel and diff --git a/test/nptl/tst-getpid1.c b/test/nptl/tst-getpid1.c index 4d25b0d..a4ab8ca 100644 --- a/test/nptl/tst-getpid1.c +++ b/test/nptl/tst-getpid1.c @@ -5,7 +5,12 @@ #include #include #include -#include + +#if defined(__hppa__) +#define _STACK_GROWS_UP 1 +#else +#define _STACK_GROWS_DOWN 1 +#endif #ifndef TEST_CLONE_FLAGS #define TEST_CLONE_FLAGS 0 diff --git a/test/nptl/tst-sem11.c b/test/nptl/tst-sem11.c index 6633ddd..a9c616c 100644 --- a/test/nptl/tst-sem11.c +++ b/test/nptl/tst-sem11.c @@ -2,7 +2,14 @@ #include #include #include -#include + +//from internaltypes.h +struct new_sem +{ + unsigned int value; + int private; + unsigned long int nwaiters; +}; #ifndef SEM_WAIT # define SEM_WAIT(s) sem_wait (s) @@ -23,23 +30,28 @@ main (void) { int tries = 5; pthread_t th; - sem_t s; + union + { + sem_t s; + struct new_sem ns; + } u; again: - if (sem_init (&s, 0, 0) != 0) + if (sem_init (&u.s, 0, 0) != 0) { puts ("sem_init failed"); return 1; } - - struct new_sem *is = (struct new_sem *) &s; - - if (is->nwaiters != 0) +#if __HAVE_64B_ATOMICS + if ((u.ns.data >> SEM_NWAITERS_SHIFT) != 0) +#else + if (u.ns.nwaiters != 0) +#endif { puts ("nwaiters not initialized"); return 1; } - if (pthread_create (&th, NULL, tf, &s) != 0) + if (pthread_create (&th, NULL, tf, &u.s) != 0) { puts ("pthread_create failed"); return 1; @@ -62,11 +74,15 @@ main (void) if (r != PTHREAD_CANCELED && --tries > 0) { /* Maybe we get the scheduling right the next time. */ - sem_destroy (&s); + sem_destroy (&u.s); goto again; } - if (is->nwaiters != 0) +#if __HAVE_64B_ATOMICS + if ((u.ns.data >> SEM_NWAITERS_SHIFT) != 0) +#else + if (u.ns.nwaiters != 0) +#endif { puts ("nwaiters not reset"); return 1; diff --git a/test/nptl/tst-signal7.c b/test/nptl/tst-signal7.c index 629f377..a635fcd 100644 --- a/test/nptl/tst-signal7.c +++ b/test/nptl/tst-signal7.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2005-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2005. @@ -17,7 +17,6 @@ . */ #include -#include #include #include @@ -27,6 +26,7 @@ do_test (void) { int result = 0; +#ifdef SIGCANCEL errno = 0; if (sigaction (SIGCANCEL, NULL, NULL) == 0) { @@ -38,7 +38,9 @@ do_test (void) puts ("sigaction(SIGCANCEL) did not set errno to EINVAL"); result = 1; } +#endif +#ifdef SIGSETXID errno = 0; if (sigaction (SIGSETXID, NULL, NULL) == 0) { @@ -50,6 +52,7 @@ do_test (void) puts ("sigaction(SIGSETXID) did not set errno to EINVAL"); result = 1; } +#endif return result; } diff --git a/test/nptl/tst-tls1.c b/test/nptl/tst-tls1.c index a7cf8f4..9eadf66 100644 --- a/test/nptl/tst-tls1.c +++ b/test/nptl/tst-tls1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2003. @@ -19,9 +19,8 @@ #include #include #include -#include -#if HAVE___THREAD + struct test_s { int a; @@ -51,19 +50,11 @@ tf (void *arg) return NULL; } -#endif int do_test (void) { -#if !HAVE___THREAD - - puts ("No __thread support in compiler, test skipped."); - - return 0; -#else - if (s.a != INIT_A || s.b != INIT_B) { puts ("initial value of s in main thread wrong"); @@ -113,7 +104,6 @@ do_test (void) } return 0; -#endif } diff --git a/test/nptl/tst-tls2.c b/test/nptl/tst-tls2.c index f60f4a5..eb6d8a3 100644 --- a/test/nptl/tst-tls2.c +++ b/test/nptl/tst-tls2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2003. @@ -23,9 +23,7 @@ #include #include #include -#include -#if HAVE___THREAD #define N 10 static pthread_t th[N]; @@ -106,18 +104,11 @@ tf (void *arg) return NULL; } -#endif + int do_test (void) { -#if !HAVE___THREAD - - puts ("No __thread support in compiler, test skipped."); - - return 0; -#else - if (pthread_barrier_init (&b, NULL, N + 1) != 0) { puts ("barrier_init failed"); @@ -207,7 +198,6 @@ do_test (void) } return 0; -#endif } diff --git a/test/nptl/tst-tls3.c b/test/nptl/tst-tls3.c index 0d4e514..3d92d91 100644 --- a/test/nptl/tst-tls3.c +++ b/test/nptl/tst-tls3.c @@ -25,8 +25,6 @@ #include #include #include -#include -#include #define THE_SIG SIGUSR1 diff --git a/test/nptl/tst-tls3mod.c b/test/nptl/tst-tls3mod.c index 0fd3261..c2cefdf 100644 --- a/test/nptl/tst-tls3mod.c +++ b/test/nptl/tst-tls3mod.c @@ -23,8 +23,6 @@ #include #include #include -#include -#include #if HAVE___THREAD diff --git a/test/nptl/tst-tls4.c b/test/nptl/tst-tls4.c index 378b13a..c8099ad 100644 --- a/test/nptl/tst-tls4.c +++ b/test/nptl/tst-tls4.c @@ -22,7 +22,6 @@ #include #include #include -#include #if HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE diff --git a/test/nptl/tst-tls4moda.c b/test/nptl/tst-tls4moda.c index 9a59cf7..ec8e868 100644 --- a/test/nptl/tst-tls4moda.c +++ b/test/nptl/tst-tls4moda.c @@ -19,7 +19,6 @@ #include #include #include -#include #if HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE diff --git a/test/nptl/tst-tls4modb.c b/test/nptl/tst-tls4modb.c index 66044b2..26056bc 100644 --- a/test/nptl/tst-tls4modb.c +++ b/test/nptl/tst-tls4modb.c @@ -19,7 +19,6 @@ #include #include #include -#include #if HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE diff --git a/test/nptl/tst-tls5.h b/test/nptl/tst-tls5.h index b7c14eb..83cc2fe 100644 --- a/test/nptl/tst-tls5.h +++ b/test/nptl/tst-tls5.h @@ -1,6 +1,5 @@ #include #include -#include #if USE_TLS && HAVE___THREAD diff --git a/test/nptl/tst-typesizes.c b/test/nptl/tst-typesizes.c index 59e9485..77506fd 100644 --- a/test/nptl/tst-typesizes.c +++ b/test/nptl/tst-typesizes.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #include static const struct -- cgit v1.2.3