From patchwork Fri Feb 6 20:57:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 437459 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 532F61401DA for ; Sat, 7 Feb 2015 07:57:37 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; q= dns; s=default; b=iCuFBbKrk3U/OQNKbZ6YvuRB0bT8EygnsU6oX5EVmYkqjc 8O0ILXyeab0M+uyPXIKS1Yyibc7CclEf/pIsok6rMSi7ZGbkTERQGGfuKUeYZQel ou+3wSepv/XDm6t+4jvDWveKOcHCWm1UNbkIxgCFMHkJOq0bHQHWRjjr86aI8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; s= default; bh=Fy75arfnfUK1XsAk/v1NyS8pMS8=; b=QahWFOTHXKpetml+Ntrf RFdAHWpPKGAUpQ3N1/jZKufHiDdlwaspKJ4nLQdypwJGa5XBJrANs5VWBrZRYv33 jw2FDdg1IBiQzkbUlOg+ZTTduYYI5XgNFDnaWtwXwrqzEWYtSwvZ8TvBz3NNFMLW unS4CvEz6hqjfvC/RmmEwnU= Received: (qmail 8474 invoked by alias); 6 Feb 2015 20:57:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 8461 invoked by uid 89); 6 Feb 2015 20:57:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH] miscellaneous test cleanups Message-Id: <20150206205701.92C1F2C3A9B@topped-with-meat.com> Date: Fri, 6 Feb 2015 12:57:01 -0800 (PST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=mDV3o1hIAAAA:8 a=7US4fbzIijwwQH2QOWIA:9 a=XLXhh6CpfFiPH-Ud:21 a=_ej6VTygT2a_xJjB:21 a=zZfrmKtxG9vASc2g:21 a=CjuIK1q_8ugA:10 This is actually 12 non-overlapping commits, each quite small. I'm posting it all as one big patch to streamline reading (and posting) it. It does various bits of cleanup in tests. Substantially it's just isolating Linuxisms or other overly-broad assumptions, such as existence of SA_SIGINFO. In many places there was no reason for those assumptions. Only three tests touched here were actually deeply Linux-specific (once that use clone directly to test something without also testing all of pthread_create et al), and those are just made Linux-only. Tested x86_64-linux-gnu. Thanks, Roland * nptl/tst-cancel25.c (tf2): Test for SIGCANCEL being blocked only if it's defined. * nptl/tst-signal7.c (do_test): Test SIGCANCEL only if it's defined. Test SIGSETXID only if it's defined. * nptl/tst-locale1.c (useless): Use SIGRTMIN only if it's defined. * rt/tst-timer2.c (do_test): Don't initialize SIGEV.sigev_signo, which will not be used. Use NULL rather than 0 for .sigev_notify_attributes. * nptl/tst-align2.c: Moved ... * sysdeps/unix/sysv/linux/tst-align-clone.c: ... here. * nptl/Makefile (tests): Remove tst-align2. * sysdeps/unix/sysv/linux/Makefile [$(subdir) = nptl] (tests): Add tst-align-clone. * nptl/tst-getpid1.c: Moved ... * sysdeps/unix/sysv/linux/tst-getpid1.c: ... here. * nptl/tst-getpid2.c: Moved ... * sysdeps/unix/sysv/linux/tst-getpid2.c: ... here. * nptl/Makefile (tests): Move tst-getpid1 and tst-getpid2 ... * sysdeps/unix/sysv/linux/Makefile [$(subdir) = nptl] (tests): ... here. * nptl/Makefile (tst-getpid2-ENV): Move variable ... * sysdeps/unix/sysv/linux/Makefile [$(subdir) = nptl] (tst-getpid2-ENV): ... here. * nptl/tst-cleanup2.c (do_test): Use signal rather than sigaction. Drop trailing \n from perror argument. Use return rather than exit. * nptl/tst-cancel20.c (do_test): Conditionalize SA_SIGINFO-using tests on [SA_SIGINFO]. * nptl/tst-cancel21.c (do_test): Likewise. * debug/tst-backtrace6.c: Include first thing. Conditionalize inclusion of tst-backtrace5.c on [SA_SIGINFO]. [!SA_SIGINFO]: Make it a stub test. * misc/tst-pselect.c (do_test): Don't set SA_NOCLDWAIT in sa_flags for SIGCHLD; it's redundant with SIG_IGN as sa_handler. * posix/tst-getlogin.c: Move to ... * login/tst-getlogin.c: ... here. * posix/Makefile (tests): Move tst-getlogin to ... * login/Makefile (tests): ... here. * libio/tst-atime.c (do_test): Move local variables SV and E inside [ST_NOATIME] conditional. * dirent/tst-fdopendir.c (O_NOATIME): If not defined, #define to 0. * nptl/tst-kill5.c (do_test): Use INT_MAX rather than SIGRTMAX + 10. * nptl/tst-join5.c: Drop #include . (wait_code): New function replaces macro. Call nanosleep rather than syscall. diff --git a/debug/tst-backtrace6.c b/debug/tst-backtrace6.c index eb5028e..9c1ed75 100644 --- a/debug/tst-backtrace6.c +++ b/debug/tst-backtrace6.c @@ -17,5 +17,12 @@ License along with the GNU C Library; if not, see . */ -#define SIGACTION_FLAGS SA_SIGINFO -#include +#include + +#ifdef SA_SIGINFO +# define SIGACTION_FLAGS SA_SIGINFO +# include +#else +# define TEST_FUNCTION 0 +# include "../test-skeleton.c" +#endif diff --git a/dirent/tst-fdopendir.c b/dirent/tst-fdopendir.c index 3cf315d..0780c19 100644 --- a/dirent/tst-fdopendir.c +++ b/dirent/tst-fdopendir.c @@ -6,6 +6,9 @@ #include #include +#ifndef O_NOATIME +# define O_NOATIME 0 +#endif static int do_test (void) diff --git a/libio/tst-atime.c b/libio/tst-atime.c index 0b0b4f0..31ca59f 100644 --- a/libio/tst-atime.c +++ b/libio/tst-atime.c @@ -23,8 +23,6 @@ do_test (void) int ch; struct stat st1; struct stat st2; - struct statvfs sv; - int e; buf = (char *) malloc (strlen (test_dir) + sizeof "/tst-atime.XXXXXX"); if (buf == NULL) @@ -44,7 +42,8 @@ do_test (void) #ifdef ST_NOATIME /* Make sure the filesystem doesn't have the noatime option set. If statvfs is not available just continue. */ - e = fstatvfs (fd, &sv); + struct statvfs sv; + int e = fstatvfs (fd, &sv); if (e != ENOSYS) { if (e != 0) diff --git a/login/Makefile b/login/Makefile index a2ebeff..0f4bb22 100644 --- a/login/Makefile +++ b/login/Makefile @@ -43,7 +43,7 @@ endif subdir-dirs = programs vpath %.c programs -tests := tst-utmp tst-utmpx tst-grantpt tst-ptsname +tests := tst-utmp tst-utmpx tst-grantpt tst-ptsname tst-getlogin # Build the -lutil library with these extra functions. extra-libs := libutil diff --git a/posix/tst-getlogin.c b/login/tst-getlogin.c similarity index 100% rename from posix/tst-getlogin.c rename to login/tst-getlogin.c diff --git a/misc/tst-pselect.c b/misc/tst-pselect.c index 095d794..0d11a80 100644 --- a/misc/tst-pselect.c +++ b/misc/tst-pselect.c @@ -31,8 +31,6 @@ do_test (void) } sa.sa_handler = SIG_IGN; - sa.sa_flags = SA_NOCLDWAIT; - if (sigaction (SIGCHLD, &sa, NULL) != 0) { puts ("2nd sigaction failed"); diff --git a/nptl/Makefile b/nptl/Makefile index 43d8510..6ae76bb 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -229,7 +229,7 @@ tests = tst-typesizes \ tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \ tst-sem8 tst-sem9 tst-sem10 tst-sem11 tst-sem12 tst-sem13 tst-sem14 \ tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \ - tst-align tst-align2 tst-align3 \ + tst-align tst-align3 \ tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \ tst-basic7 \ tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \ @@ -269,7 +269,7 @@ tests = tst-typesizes \ tst-backtrace1 \ tst-abstime \ tst-vfork1 tst-vfork2 tst-vfork1x tst-vfork2x \ - tst-getpid1 tst-getpid2 tst-getpid3 \ + tst-getpid3 \ tst-setuid3 \ tst-initializers1 $(addprefix tst-initializers1-,c89 gnu89 c99 gnu99) \ tst-bad-schedattr @@ -463,11 +463,6 @@ tst-cancel7-ARGS = --command "exec $(host-test-program-cmd)" tst-cancelx7-ARGS = $(tst-cancel7-ARGS) tst-umask1-ARGS = $(objpfx)tst-umask1.temp -# In this test, we create a CLONE_VM "thread" that shares TLS storage -# with the original thread. Both threads then race in ld.so with lazy PLT -# resolution. Avoid this race by disabling lazy binding. BZ #11214. -tst-getpid2-ENV = LD_BIND_NOW=1 - $(objpfx)tst-atfork2: $(libdl) $(shared-thread-library) LDFLAGS-tst-atfork2 = -rdynamic tst-atfork2-ENV = MALLOC_TRACE=$(objpfx)tst-atfork2.mtrace diff --git a/nptl/tst-cancel20.c b/nptl/tst-cancel20.c index 4a964da..51b558e 100644 --- a/nptl/tst-cancel20.c +++ b/nptl/tst-cancel20.c @@ -227,6 +227,7 @@ do_test (void) if (do_one_test ()) return 1; +#ifdef SA_SIGINFO sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh; sigemptyset (&sa.sa_mask); sa.sa_flags = SA_SIGINFO; @@ -254,6 +255,7 @@ do_test (void) puts ("sa_flags = SA_SIGINFO|SA_ONSTACK test"); if (do_one_test ()) return 1; +#endif return 0; } diff --git a/nptl/tst-cancel21.c b/nptl/tst-cancel21.c index 35a27d4..b54f236 100644 --- a/nptl/tst-cancel21.c +++ b/nptl/tst-cancel21.c @@ -257,6 +257,7 @@ do_test (void) if (do_one_test ()) return 1; +#ifdef SA_SIGINFO sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh; sigemptyset (&sa.sa_mask); sa.sa_flags = SA_SIGINFO; @@ -284,6 +285,7 @@ do_test (void) puts ("sa_flags = SA_SIGINFO|SA_ONSTACK test"); if (do_one_test ()) return 1; +#endif return 0; } diff --git a/nptl/tst-cancel25.c b/nptl/tst-cancel25.c index 00b99ad..ed4205e 100644 --- a/nptl/tst-cancel25.c +++ b/nptl/tst-cancel25.c @@ -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/nptl/tst-cleanup2.c b/nptl/tst-cleanup2.c index 8a524de..9e5a957 100644 --- a/nptl/tst-cleanup2.c +++ b/nptl/tst-cleanup2.c @@ -40,16 +40,11 @@ do_test (void) array. Mark the return value as volatile so that it gets reloaded on return. */ volatile int ret = 0; - struct sigaction sa; - sa.sa_handler = sig_handler; - sigemptyset (&sa.sa_mask); - sa.sa_flags = SA_SIGINFO; - - if (sigaction (SIGSEGV, &sa, 0)) + if (signal (SIGSEGV, &sig_handler) == SIG_ERR) { - perror ("installing SIGSEGV handler\n"); - exit (1); + perror ("installing SIGSEGV handler"); + return 1; } puts ("Attempting to sprintf to null ptr"); diff --git a/nptl/tst-join5.c b/nptl/tst-join5.c index e83f895..b45d210 100644 --- a/nptl/tst-join5.c +++ b/nptl/tst-join5.c @@ -22,15 +22,15 @@ #include #include #include -#include -#define wait_code() \ - do { \ - struct timespec ts = { .tv_sec = 0, .tv_nsec = 200000000 }; \ - while (syscall (__NR_nanosleep, &ts, &ts) < 0) \ - /* nothing */; \ - } while (0) +static void +wait_code (void) +{ + struct timespec ts = { .tv_sec = 0, .tv_nsec = 200000000 }; + while (nanosleep (&ts, &ts) < 0) + ; +} #ifdef WAIT_IN_CHILD diff --git a/nptl/tst-kill5.c b/nptl/tst-kill5.c index f16aae9..0717c03 100644 --- a/nptl/tst-kill5.c +++ b/nptl/tst-kill5.c @@ -21,6 +21,7 @@ #include #include #include +#include int @@ -28,7 +29,7 @@ do_test (void) { /* XXX This test might require architecture and system specific changes. There is no guarantee that this signal number is invalid. */ - int e = pthread_kill (pthread_self (), SIGRTMAX + 10); + int e = pthread_kill (pthread_self (), INT_MAX); if (e == 0) { puts ("kill didn't failed"); diff --git a/nptl/tst-locale1.c b/nptl/tst-locale1.c index 2ee4c3f..887b9a6 100644 --- a/nptl/tst-locale1.c +++ b/nptl/tst-locale1.c @@ -12,7 +12,11 @@ useless (void) { pthread_t th; pthread_create (&th, 0, (void *(*) (void *)) useless, 0); + int result = 0; +#ifdef SIGRTMIN /* This is to check __libc_current_sigrt* can be used in statically linked apps. */ - return SIGRTMIN; + result = SIGRTMIN; +#endif + return result; } diff --git a/nptl/tst-signal7.c b/nptl/tst-signal7.c index b388989..1fbf3db 100644 --- a/nptl/tst-signal7.c +++ b/nptl/tst-signal7.c @@ -27,6 +27,7 @@ do_test (void) { int result = 0; +#ifdef SIGCANCEL errno = 0; if (sigaction (SIGCANCEL, NULL, NULL) == 0) { @@ -38,7 +39,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 +53,7 @@ do_test (void) puts ("sigaction(SIGSETXID) did not set errno to EINVAL"); result = 1; } +#endif return result; } diff --git a/posix/Makefile b/posix/Makefile index 5ee7b28..15e8818 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -64,7 +64,7 @@ routines := \ aux := init-posix environ tests := tstgetopt testfnm runtests runptests \ tst-preadwrite tst-preadwrite64 test-vfork regexbug1 \ - tst-getlogin tst-mmap tst-getaddrinfo tst-truncate \ + tst-mmap tst-getaddrinfo tst-truncate \ tst-truncate64 tst-fork tst-fnmatch tst-regexloc tst-dir \ tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \ tst-gnuglob tst-regex bug-regex5 bug-regex6 bug-regex7 \ diff --git a/rt/tst-timer2.c b/rt/tst-timer2.c index 60026c1..b2ce987 100644 --- a/rt/tst-timer2.c +++ b/rt/tst-timer2.c @@ -30,9 +30,8 @@ do_test (void) itval.it_value.tv_nsec = 0; sigev.sigev_notify = SIGEV_THREAD; - sigev.sigev_signo = SIGRTMIN; sigev.sigev_notify_function = thread; - sigev.sigev_notify_attributes = 0; + sigev.sigev_notify_attributes = NULL; sigev.sigev_value.sival_ptr = (void *) &timerId; for (i = 0; i < 100; i++) diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 9f3718b..c26a12f 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -196,5 +196,10 @@ CFLAGS-gai.c += -DNEED_NETLINK endif ifeq ($(subdir),nptl) -tests += tst-setgetname +tests += tst-setgetname tst-align-clone tst-getpid1 tst-getpid2 + +# In this test, we create a CLONE_VM "thread" that shares TLS storage +# with the original thread. Both threads then race in ld.so with lazy PLT +# resolution. Avoid this race by disabling lazy binding. BZ #11214. +tst-getpid2-ENV = LD_BIND_NOW=1 endif diff --git a/nptl/tst-align2.c b/sysdeps/unix/sysv/linux/tst-align-clone.c similarity index 100% rename from nptl/tst-align2.c rename to sysdeps/unix/sysv/linux/tst-align-clone.c diff --git a/nptl/tst-getpid1.c b/sysdeps/unix/sysv/linux/tst-getpid1.c similarity index 100% rename from nptl/tst-getpid1.c rename to sysdeps/unix/sysv/linux/tst-getpid1.c diff --git a/nptl/tst-getpid2.c b/sysdeps/unix/sysv/linux/tst-getpid2.c similarity index 100% rename from nptl/tst-getpid2.c rename to sysdeps/unix/sysv/linux/tst-getpid2.c