From patchwork Fri Oct 9 17:48:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 54731 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 9DA9A22DB6 for ; Fri, 9 Oct 2015 17:48:42 +0000 (UTC) Received: by wicgb1 with SMTP id gb1sf32819820wic.3 for ; Fri, 09 Oct 2015 10:48:41 -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:x-original-sender:x-original-authentication-results; bh=H1zRnOCjZiBEVq9rCXhJtAd94s6DbaSVtOuLpacK6M4=; b=bzB/osdxb1MIy0Iyj/1B/EY7fpbXOptzrGec1Ugdicw5uIxmQqHtCF6BG3jIBU1W2e WgsLVu7dfzZxqt/qBU7fB47eWOfv+LsTvCsc9KeITMlYn2PLV+hMzak8fC+nLZgY347U u4SJN5xj4S3jqNdnF/aH+jZ2Nzo2ZGjAcnNHywpaOVBfp8/CI8f28lMprorNC7llQAlX ZGxpI2U39TmhkKgGN1Zyn7XEf/dOJRww1bI8DQI07U2UX5/aNCU4BI2ifGId9+NAqQpL +WznPpNrfvJIrQpuyalugRLUQJwdUmpQ4yR7Sn5SnLKKt2/6oGdYTqA9P3g25JOYPII9 ybVQ== X-Gm-Message-State: ALoCoQmbJxWzgNVJKH6LO12OtS68x37711UC6wXn142rQTwqLpnP7ZKgcz6PVWAmjVx21IQ+jfs7 X-Received: by 10.194.83.169 with SMTP id r9mr2888676wjy.6.1444412921556; Fri, 09 Oct 2015 10:48:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.78.81 with SMTP id c78ls302625lfb.45.gmail; Fri, 09 Oct 2015 10:48:41 -0700 (PDT) X-Received: by 10.112.137.169 with SMTP id qj9mr7279338lbb.34.1444412921408; Fri, 09 Oct 2015 10:48:41 -0700 (PDT) Received: from mail-lb0-x22d.google.com (mail-lb0-x22d.google.com. [2a00:1450:4010:c04::22d]) by mx.google.com with ESMTPS id jd9si1990309lbc.140.2015.10.09.10.48.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Oct 2015 10:48:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22d as permitted sender) client-ip=2a00:1450:4010:c04::22d; Received: by lbwr8 with SMTP id r8so88108420lbw.2 for ; Fri, 09 Oct 2015 10:48:41 -0700 (PDT) X-Received: by 10.25.40.130 with SMTP id o124mr4593099lfo.41.1444412920892; Fri, 09 Oct 2015 10:48:40 -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 w3csp125701lbq; Fri, 9 Oct 2015 10:48:39 -0700 (PDT) X-Received: by 10.68.228.129 with SMTP id si1mr16520759pbc.119.1444412919709; Fri, 09 Oct 2015 10:48:39 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g12si4169442pat.32.2015.10.09.10.48.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Oct 2015 10:48:39 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-63878-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 64891 invoked by alias); 9 Oct 2015 17:48:28 -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 64880 invoked by uid 89); 9 Oct 2015 17:48:27 -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-f172.google.com X-Received: by 10.13.232.148 with SMTP id r142mr11541800ywe.284.1444412904238; Fri, 09 Oct 2015 10:48:24 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2] nptl: Add NPTL cases for cancellation failures cases Date: Fri, 9 Oct 2015 14:48:15 -0300 Message-Id: <1444412895-18665-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::22d as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 Changes from v1: - Added descriptive comment in header. - Use C99 inline declaration. - Remove errno save in local variable. - Remove duplicate code. 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/Makefile (tests): Add tst-cancel26.c and tst-cancel27.c. * nptl/tst-cancel26.c: New file. * nptl/tst-cancel27.c: Likewise. --- ChangeLog | 7 ++++++ nptl/Makefile | 1 + nptl/tst-cancel26.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ nptl/tst-cancel27.c | 23 ++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 nptl/tst-cancel26.c create mode 100644 nptl/tst-cancel27.c diff --git a/ChangeLog b/ChangeLog index 025a3d8..0ad682a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,11 @@ 2015-10-09 Adhemerval Zanella + Phil Blundell + + * nptl/Makefile (tests): Add tst-cancel26.c and tst-cancel27.c. + * nptl/tst-cancel26.c: New file. + * nptl/tst-cancel27.c: Likewise. + +2015-10-09 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/Makefile b/nptl/Makefile index f3de49b..311b1a7 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -259,6 +259,7 @@ tests = tst-typesizes \ tst-cancel11 tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 \ tst-cancel16 tst-cancel17 tst-cancel18 tst-cancel19 tst-cancel20 \ tst-cancel21 tst-cancel22 tst-cancel23 tst-cancel24 tst-cancel25 \ + tst-cancel26 tst-cancel27 \ tst-cancel-self tst-cancel-self-cancelstate \ tst-cancel-self-canceltype tst-cancel-self-testcancel \ tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 tst-cleanup4 \ diff --git a/nptl/tst-cancel26.c b/nptl/tst-cancel26.c new file mode 100644 index 0000000..3c0a591 --- /dev/null +++ b/nptl/tst-cancel26.c @@ -0,0 +1,68 @@ +/* Check for failure paths handling for cancellation points. + 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 + +/* Check that the cancel syscall points handles both the errno and return code + correctly for invalid arguments. */ +static void * +tf (void *arg) +{ +#ifdef SET_CANCEL_DISABLE + pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL); +#endif + + /* This is a cancellation point, but we should not be cancelled. */ + int r = write (-1, 0, 0); + + if (r != -1 || errno != EBADF) + { + printf ("error: write returned %d, errno %d\n", r, errno); + exit (1); + } + + return NULL; +} + +static int +do_test (void) +{ + pthread_t th; + + if (pthread_create (&th, NULL, tf, NULL) != 0) + { + puts ("error: pthread_create failed"); + exit (1); + } + + if (pthread_join (th, NULL) != 0) + { + puts ("error: pthread_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..3264aea --- /dev/null +++ b/nptl/tst-cancel27.c @@ -0,0 +1,23 @@ +/* Check for failure paths handling for cancellation points. + 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 + . */ + +/* Similar to tst-cancel26.c but with pthread cancel state set to + PTHREAD_CANCEL_DISABLE. */ + +#define SET_CANCEL_DISABLE 1 +#include "tst-cancel26.c"