From patchwork Fri Jun 16 15:09:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 105751 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1352319qgd; Fri, 16 Jun 2017 08:10:04 -0700 (PDT) X-Received: by 10.84.143.70 with SMTP id 64mr13374688ply.36.1497625804576; Fri, 16 Jun 2017 08:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497625804; cv=none; d=google.com; s=arc-20160816; b=sR2ZZ4KKl4Gi7rfvtTGXeakEUfoek76IhTqOqhH8RPo7YkNXW8aB4ElcBwK3GiumK2 AqAMCQ/XrKj7Wj4l5L/8d6zZXnmzAsG9TLRNAzcbW16zLfnhE9fIqdAg+fMlN7o6YplT wyPwGTxtRY3wZm4910qGr1ZuFNR7StbrMJEs+yHOTttlL3npWMyh+3EshiR/nzz0YtWx 0qHskUKOAoRi2pVIaaNiqw5DrwaEix5tFaxxmwuqfJwE3WoBWuftRcjwEduu277OvZwy K1M0JI+ygUwZZsOosp1QMUF8xb0oxOMAq+7pp81yr2e9T03vd0cjBIY/ewNds2InD7tw KrQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=D11Cp/+/3E1MN+Y4qLdfMFLszZ5FUmnMTmhf4NesB4g=; b=GXokN5nxYFFmPanFfl7QsyBdFccMor+B05nLDJrp8KJoRRYdst+QtVyo8GJoT9K6yL Il6zA4ruVk//nBiASSap7eN1F7Z8ePIHorhkb4Vdgco2dA2yPMf5ZnbmLQqptN2UImKT uWHGFYLNLjcPJ0aKVvmFNGoOhoMsmYCpK6dv87d5YWoTQ/meH/diXpKR8E85pWrxh5XT MJAFjjkKTCWTz8Ia5SMJzEe3yPjAHkqKMlCE2WGybmhD0x1H7l4B+/9SRXwCrAViehhK 6w5BccdEYFG/ozVfAUhAppu17B8NBHlmn6AqYhNPB7N7vwuMQOdarvF41g5aw51uul1z F8+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=IUsopFI7; spf=pass (google.com: domain of libc-alpha-return-80614-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-80614-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r25si2194058pfg.401.2017.06.16.08.10.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jun 2017 08:10:04 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-80614-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 header.b=IUsopFI7; spf=pass (google.com: domain of libc-alpha-return-80614-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-80614-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=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=ZrDHG5V3riZcKcqMaTLbsKzPEdKZ4MAugG02FIOXDvvE+3NWde5YF vmG+lkSBm7KlB/NYa1ACUu80Z5cTBigm76ydY21AnVZPMYUkEVMZLpqjGmDv/kFn teJlSpQnQoq6h5qahddbDyyB6R5v9lXegXCna3JeqG07GG9sPxirjk= 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=6UP+JBHZP6tcqdeZ/s1ShSpj2so=; b=IUsopFI7k0RlfKdF0CFpDUiMNTtR gBXhS/B4PMemAzjhPdfd6lySoMIKXZ2X3atApA7jK+GKWETKJwb1ztNK5j7a+OzA vl7Y2v/k5a+PsLeNIMbGNvVpo5ms1WkVAoKAxbiHqEeCzKQay6e+92Ka1FMsejdP GVF519ym27AAdgs= Received: (qmail 26339 invoked by alias); 16 Jun 2017 15:09:47 -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 23778 invoked by uid 89); 16 Jun 2017 15:09:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f181.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=D11Cp/+/3E1MN+Y4qLdfMFLszZ5FUmnMTmhf4NesB4g=; b=lBRUT0TXtQbI21eiYJFZ/w9Y6tB6rXYVOV+6HpDzoajP+typnN0XJIJCH2U8hKc8yH ZzbamkLa9XjJwwMZlpAPQ4SFv09hPRjw+K6VAn5o/dRxGb67QwbD3tZ3V5HTS81qv5as R9vfdP3rD6hJbYiMy5X6U7CTgLhbYrTDdwabDuj3cGyLhf/nGUfUaHocXLubUlFQC43d 3irxrPmqtbdTJnIigXCcRtdqU8aTzmmR27MHrtO9t/En5t310kZk9l6DgxeVQMX3+Gnr JxKsPH0nk6yVJYfl1RGfBbwhhq39bVI0b8Zmm3deTyDdovDD/orTQ69TDMZ2CmGjHzw+ d1wQ== X-Gm-Message-State: AKS2vOxHgepwWnKh4wg92o6pcdajZ4szAJSlYzqn5+/lAw15zjKzNO7n 12Ap0lPl3C43cGJfz3As2A== X-Received: by 10.55.23.197 with SMTP id 66mr13580409qkx.67.1497625787059; Fri, 16 Jun 2017 08:09:47 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] posix: Add invalid flags test for p{write,read}v2 Date: Fri, 16 Jun 2017 12:09:40 -0300 Message-Id: <1497625780-8732-1-git-send-email-adhemerval.zanella@linaro.org> This patch add an extra test for passing invalid flags and check its expected failure. It shows an invalid LO_HI_LONG macro definition for x86_64 with leads to passing invalid flags on some configurations. The new tests fails on i686-linux-gnu and potentially on other 32 bits architecture that uses the compat syscall definition due a kernel bug. It is intended to be fixed upstream. I have added a comment for it and I think disabling this is not the correct approach since if the syscall is ignoring the flag it defeats the whole purpose of the syscall. The failure indicates the kernel requires an update. Checked on x86_64-linux-gnu * misc/tst-preadvwritev2-common.c: New file. * misc/tst-preadvwritev2.c (do_test): Add test for invalid flag. * misc/tst-preadvwritev64v2.c (do_test): Likewise. --- ChangeLog | 6 ++++++ misc/tst-preadvwritev2-common.c | 48 +++++++++++++++++++++++++++++++++++++++++ misc/tst-preadvwritev2.c | 3 +++ misc/tst-preadvwritev64v2.c | 3 +++ 4 files changed, 60 insertions(+) create mode 100644 misc/tst-preadvwritev2-common.c -- 2.7.4 diff --git a/misc/tst-preadvwritev2-common.c b/misc/tst-preadvwritev2-common.c new file mode 100644 index 0000000..4c53d56 --- /dev/null +++ b/misc/tst-preadvwritev2-common.c @@ -0,0 +1,48 @@ +/* Common function for preadv2 and pwritev2 tests. + Copyright (C) 2017 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 + +static void +do_test_with_invalid_flags (void) +{ + int invalid_flag = 0x1; +#ifdef RWF_HIPRI + invalid_flag <<= 1; +#endif +#ifdef RWF_DSYNC + invalid_flag <<= 1; +#endif +#ifdef RWF_SYNC + invalid_flag <<= 1; +#endif + + char buf[32]; + const struct iovec vec = { .iov_base = buf, .iov_len = sizeof (buf) }; + if (preadv2 (temp_fd, &vec, 1, 0, invalid_flag) != -1) + FAIL_EXIT1 ("preadv2 did not fail with an invalid flag"); + if (errno != ENOTSUP) + FAIL_EXIT1 ("preadv2 failure did not set errno to ENOTSUP (%d)", errno); + + /* This might fail for compat syscall (32 bits running on 64 bits kernel) + due a kernel issue. */ + if (pwritev2 (temp_fd, &vec, 1, 0, invalid_flag) != -1) + FAIL_EXIT1 ("pwritev2 did not fail with an invalid flag"); + if (errno != ENOTSUP) + FAIL_EXIT1 ("pwritev2 failure did not set errno to ENOTSUP (%d)", errno); +} diff --git a/misc/tst-preadvwritev2.c b/misc/tst-preadvwritev2.c index cf36272..682c757 100644 --- a/misc/tst-preadvwritev2.c +++ b/misc/tst-preadvwritev2.c @@ -23,9 +23,12 @@ pwritev2 (__fd, __iov, __iovcnt, __offset, 0) #include "tst-preadvwritev-common.c" +#include "tst-preadvwritev2-common.c" static int do_test (void) { + do_test_with_invalid_flags (); + return do_test_with_offset (0); } diff --git a/misc/tst-preadvwritev64v2.c b/misc/tst-preadvwritev64v2.c index 8d0c48e..9ddc762 100644 --- a/misc/tst-preadvwritev64v2.c +++ b/misc/tst-preadvwritev64v2.c @@ -25,9 +25,12 @@ pwritev2 (__fd, __iov, __iovcnt, __offset, 0) #include "tst-preadvwritev-common.c" +#include "tst-preadvwritev2-common.c" static int do_test (void) { + do_test_with_invalid_flags (); + return do_test_with_offset (0); }