From patchwork Tue Jun 14 15:42:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 70049 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2115655qgf; Tue, 14 Jun 2016 08:43:00 -0700 (PDT) X-Received: by 10.107.4.78 with SMTP id 75mr35319266ioe.52.1465918979999; Tue, 14 Jun 2016 08:42:59 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w63si39186285pfb.135.2016.06.14.08.42.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jun 2016 08:42:59 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-70617-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-70617-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-70617-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=S8dNgBdnK7q184xDOHi0dPCyjunDu241hi4LjSCNjxnbJlspakqsZ 4TMI/E0Ef78YukfBGajdcLjvMQtNx/VTQHmlVgBtG5cPdznKRmwWeqn9kf88Pk8c t3UGbEperTdobxOJJNYbtzmDWWkewPH1jo1WOnbJrAxs12XeGN116M= 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:from:to:subject:date:message-id; s=default; bh=aPx2yANZ1ILA8L9edbh4bZG3OEs=; b=A1mWuxDcx2JaXtzIKyx22sIQJTSb lHJjbDTLsr/EP6gCgPHHCzGY+TUIb92kVO/LVp3PLAhXRdt886Zbm1j/6JDYTeUi X9Y8oceLsj5+fJWhUknQaRJiQFQ+YvS8XLG4RzjbbMoiw36mUFMNGEsY0tbNhSjT NntZLe/3xz+3PE4= Received: (qmail 94084 invoked by alias); 14 Jun 2016 15:42:50 -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 93604 invoked by uid 89); 14 Jun 2016 15:42:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Named, cnt, bsd, xxx X-HELO: mail-yw0-f173.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=enPX6TdpC506G4/TSPVjSLJVFpUDz6Ui+YUJNOqgNCU=; b=GIk4M41QexQQ4Ujoaz8hJ31gF4XFPsanEsZ8xKH4cyICdNHtDOa+8JrDsijuIjQwKm Fr1eOZt5LraSgtvIi+j25k6AVHtlXzJVoRgZCudZw3Zxw0v3KbWSwHkqfjBSbSr4rEDW xcmywV9xCp5/QUshjcvcsxTjHebp3VpJzefZY+BkK+roPQQcHMPxZ+3MaiFheIbDpiRM 4qWVyDCzwdMNY4EXmmUQyE7jXz8FYyJO6Kz+jsN3QgrVKQwb6PJH3gXxV2eTqPHKioDm Q8gChBlUDGksD1YDp37ECWPr8B9vjOowEGJDW/JoSDx51ujd6lUQ5cEkGEV5O9tTJOBV uKog== X-Gm-Message-State: ALyK8tLRdwQm+ZkN/KoS/L/8GMNUcQomobN0XEcBtWTWv9mV6JlavXKwZf+GsLGoU2bcOASF X-Received: by 10.13.204.137 with SMTP id o131mr2339726ywd.168.1465918957514; Tue, 14 Jun 2016 08:42:37 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] nptl: Add more coverage in tst-cancel4 Date: Tue, 14 Jun 2016 12:42:28 -0300 Message-Id: <1465918948-13371-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds early cancel test for open syscall through a FIFO (thus makign subsequent call to open block until the other end is also opened). It also cleanup the sigpause tests by using sigpause along with SIGINT instead of __xpg_sigpause and SIGCANCEL. Since the idea is just to test the cancellation handling there is no need to expose internal glibc implementation details to the test through pthreadP.h inclusion. Tested x86_64. * nptl/tst-cancel4-common.c (do_test): Add temporary fifo creation. * nptl/tst-cancel4-common.h (fifoname): New variable. (fifofd): Likewise. (cl_fifo): New function. * nptl/tst-cancel4.c (tf_sigpause): Replace SIGCANCEL usage by SIGINT. (tf_open): Add early cancel test. --- ChangeLog | 10 ++++++++++ nptl/tst-cancel4-common.c | 6 ++++++ nptl/tst-cancel4-common.h | 16 ++++++++++++++++ nptl/tst-cancel4.c | 40 ++++++++++++++++++++-------------------- 4 files changed, 52 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/nptl/tst-cancel4-common.c b/nptl/tst-cancel4-common.c index f235d53..cab99c4 100644 --- a/nptl/tst-cancel4-common.c +++ b/nptl/tst-cancel4-common.c @@ -44,6 +44,12 @@ do_test (void) } setsockopt (fds[1], SOL_SOCKET, SO_SNDBUF, &val, sizeof(val)); + if (mktemp (fifoname) == NULL) + { + printf ("%s: cannot generate temp file name\n", __FUNCTION__); + exit (1); + } + int result = 0; size_t cnt; for (cnt = 0; cnt < ntest_tf; ++cnt) diff --git a/nptl/tst-cancel4-common.h b/nptl/tst-cancel4-common.h index e1683c4..06ed0dc 100644 --- a/nptl/tst-cancel4-common.h +++ b/nptl/tst-cancel4-common.h @@ -67,6 +67,22 @@ cl (void *arg) ++cl_called; } +/* Named pipe used to check for blocking open. It should be closed + after the cancellation handling. */ +static char fifoname[] = "/tmp/tst-cancel4-fifo-XXXXXX"; +static int fifofd; + +static void +__attribute__ ((used)) +cl_fifo (void *arg) +{ + ++cl_called; + + unlink (fifoname); + close (fifofd); + fifofd = -1; +} + struct cancel_tests { const char *name; diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c index 4221af4..c1fac1b 100644 --- a/nptl/tst-cancel4.c +++ b/nptl/tst-cancel4.c @@ -36,8 +36,6 @@ #include #include -#include "pthreadP.h" - /* Since STREAMS are not supported in the standard Linux kernel and there we don't advertise STREAMS as supported is no need to test @@ -67,6 +65,7 @@ #include "tst-cancel4-common.h" + #ifndef IPC_ADDVAL # define IPC_ADDVAL 0 #endif @@ -734,13 +733,7 @@ tf_sigpause (void *arg) pthread_cleanup_push (cl, NULL); -#ifdef SIGCANCEL - /* Just for fun block the cancellation signal. We need to use - __xpg_sigpause since otherwise we will get the BSD version. */ - __xpg_sigpause (SIGCANCEL); -#else - pause (); -#endif + sigpause (sigmask (SIGINT)); pthread_cleanup_pop (0); @@ -1348,27 +1341,34 @@ static void * tf_open (void *arg) { if (arg == NULL) - // XXX If somebody can provide a portable test case in which open() - // blocks we can enable this test to run in both rounds. - abort (); - - int r = pthread_barrier_wait (&b2); - if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); + fifofd = mkfifo (fifoname, S_IWUSR | S_IRUSR); + if (fifofd == -1) + { + printf ("%s: mkfifo failed\n", __FUNCTION__); + exit (1); + } + } + else + { + int r = pthread_barrier_wait (&b2); + if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) + { + printf ("%s: barrier_wait failed\n", __FUNCTION__); + exit (1); + } } - r = pthread_barrier_wait (&b2); + int r = pthread_barrier_wait (&b2); if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) { printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); exit (1); } - pthread_cleanup_push (cl, NULL); + pthread_cleanup_push (cl_fifo, NULL); - open ("Makefile", O_RDONLY); + open (arg ? "Makefile" : fifoname, O_RDONLY); pthread_cleanup_pop (0);