From patchwork Wed Oct 7 16:23:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 54598 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 8286722FF8 for ; Wed, 7 Oct 2015 16:24:16 +0000 (UTC) Received: by lbwr8 with SMTP id r8sf9767953lbw.0 for ; Wed, 07 Oct 2015 09:24:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results; bh=v2qUIG4G2307CtcOWf2cEti+WQG5gNruqUTbLqRfDVc=; b=hkEpMsbGMLL+00mdhVSP2FJMz+z+0iGA/zhe0IRP82zQ3RFwzm1edhZB5CZthpFn09 uzFcy/KNkQlaYjQ66Htjrp0lGa1mHvJfHzJAQ9khbTBSq/stcHaYv3JIfiCKpTJxvynw /3iLdG6FTePiPLMGiNmOqlWJwJzDYUiYdzyk2iBT/UU/QjTrCubftlyfG2ZB5SbS0+Pu WMav4a4SQFs7XBdYYsF9S0jP3gKNq2ouzCVI0Npx4tNcnuMH3FM70UxTdO2kLeckZ2Ka LyxQgYdfL8MWmciS8BWc3D5znlNRJXi5nv2S93yv1IdAUEpWylatT2mLAp0/h51sibmy dJFQ== X-Gm-Message-State: ALoCoQnBUX2YLtQCy/WyzvYBkQ665KP9aXmcOpXC5zf+ow2acXRIZcTuHkVK+ddRZdlewE6bzoG+ X-Received: by 10.112.164.1 with SMTP id ym1mr421063lbb.15.1444235055381; Wed, 07 Oct 2015 09:24:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.163.194 with SMTP id m185ls104577lfe.66.gmail; Wed, 07 Oct 2015 09:24:15 -0700 (PDT) X-Received: by 10.112.172.165 with SMTP id bd5mr1070551lbc.51.1444235055247; Wed, 07 Oct 2015 09:24:15 -0700 (PDT) Received: from mail-lb0-x229.google.com (mail-lb0-x229.google.com. [2a00:1450:4010:c04::229]) by mx.google.com with ESMTPS id c3si5076724lfc.113.2015.10.07.09.24.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Oct 2015 09:24:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::229 as permitted sender) client-ip=2a00:1450:4010:c04::229; Received: by lbwr8 with SMTP id r8so17317414lbw.2 for ; Wed, 07 Oct 2015 09:24:15 -0700 (PDT) X-Received: by 10.25.38.9 with SMTP id m9mr714309lfm.112.1444235054585; Wed, 07 Oct 2015 09:24:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp78839lbq; Wed, 7 Oct 2015 09:24:13 -0700 (PDT) X-Received: by 10.107.6.74 with SMTP id 71mr2974774iog.16.1444235053427; Wed, 07 Oct 2015 09:24:13 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v15si3150859igr.31.2015.10.07.09.24.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Oct 2015 09:24:13 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-63752-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 104631 invoked by alias); 7 Oct 2015 16:23:29 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 104572 invoked by uid 89); 7 Oct 2015 16:23:28 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f171.google.com X-Received: by 10.129.156.130 with SMTP id t124mr1583513ywg.151.1444235004602; Wed, 07 Oct 2015 09:23:24 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 01/13] nptl: Add NPTL cases for cancellation failures cases Date: Wed, 7 Oct 2015 13:23:03 -0300 Message-Id: <1444234995-9542-2-git-send-email-adhemerval.zanella@linaro.com> In-Reply-To: <1444234995-9542-1-git-send-email-adhemerval.zanella@linaro.com> References: <1444234995-9542-1-git-send-email-adhemerval.zanella@linaro.com> X-Original-Sender: adhemerval.zanella@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::229 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 This patch pthread cancellation tests to check for failures cases wherer the syscall cancel wrapper should both set the error and the errno values. Tested on i686, x86_64, x32, powerpc64le, and aarch64. * nptl/tst-cancel26.c: New file. * nptl/tst-cancel27.c: Likewise. --- ChangeLog | 6 +++++ nptl/tst-cancel26.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ nptl/tst-cancel27.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 nptl/tst-cancel26.c create mode 100644 nptl/tst-cancel27.c diff --git a/ChangeLog b/ChangeLog index e665153..75cd365 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ 2015-10-07 Adhemerval Zanella + Phil Blundell + + * nptl/tst-cancel26.c: New file. + * nptl/tst-cancel27.c: Likewise. + +2015-10-07 Adhemerval Zanella * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S diff --git a/nptl/tst-cancel26.c b/nptl/tst-cancel26.c new file mode 100644 index 0000000..9a370d0 --- /dev/null +++ b/nptl/tst-cancel26.c @@ -0,0 +1,68 @@ +/* Copyright (C) 2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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, see + . */ + +#include +#include +#include +#include +#include +#include + +static void * +tf (void *arg) +{ + int e, r; + + errno = 0; + + /* This is a cancellation point, but we should not be cancelled. */ + r = write (-1, 0, 0); + e = errno; + + /* Check that the cancelling syscall wrapper has handled the error correctly. */ + if (r != -1 || errno != EBADF) + { + printf ("write returned %d, errno %d\n", r, e); + exit (1); + } + + return NULL; +} + +static int +do_test (void) +{ + pthread_t th; + + if (pthread_create (&th, NULL, tf, NULL) != 0) + { + puts ("create failed"); + exit (1); + } + + void *r; + if (pthread_join (th, &r) != 0) + { + puts ("join failed"); + exit (1); + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/nptl/tst-cancel27.c b/nptl/tst-cancel27.c new file mode 100644 index 0000000..aee25c9 --- /dev/null +++ b/nptl/tst-cancel27.c @@ -0,0 +1,70 @@ +/* Copyright (C) 2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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, see + . */ + +#include +#include +#include +#include +#include +#include + +static void * +tf (void *arg) +{ + int e, r; + + errno = 0; + + pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL); + + /* This is a cancellation point, but we should not be cancelled. */ + r = write (-1, 0, 0); + e = errno; + + /* Check that the cancelling syscall wrapper has handled the error correctly. */ + if (r != -1 || errno != EBADF) + { + printf ("write returned %d, errno %d\n", r, e); + exit (1); + } + + return NULL; +} + +static int +do_test (void) +{ + pthread_t th; + + if (pthread_create (&th, NULL, tf, NULL) != 0) + { + puts ("create failed"); + exit (1); + } + + void *r; + if (pthread_join (th, &r) != 0) + { + puts ("join failed"); + exit (1); + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c"