From patchwork Thu Apr 27 21:30:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 98295 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp299072qgf; Thu, 27 Apr 2017 14:31:17 -0700 (PDT) X-Received: by 10.99.153.9 with SMTP id d9mr8170481pge.214.1493328677587; Thu, 27 Apr 2017 14:31:17 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id q14si4131198pgn.416.2017.04.27.14.31.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Apr 2017 14:31:17 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-78919-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-78919-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-78919-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=eovgz0XkYmnHoPrqnRKFjFwnDKA2Bw8qNw2gqLSWepn8PdiKZu8I0 uc16lDHMj69DfeULoAn61KZzthwrJ1B1xh/EH4aEhrF0tFsM1sR7+KRkVuG5vzCs Iq890h/efrzRaGHbSiuCh5rUrO2uKdsbxUI9x3TaMhHkrsKnVwyuow= 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=yV4R/fUy/G/0PoocQBqUPeHZAb4=; b=QZWwLMKAFNz/+yNpnugMc619mj5J OxH5Lmagyoo/228ICso+kFtoGZsTICdW0z+1vx9Vlie+JeJ6PTMeRI7vk9hiayWy IohHngSQ61/PNOrP438tjNzcoXJNAKcS2N+vb4Ae5Q1hSfTk4J43ApAccuiuCbRh QsOBe+LvESjQyBE= Received: (qmail 11459 invoked by alias); 27 Apr 2017 21:31:04 -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 11444 invoked by uid 89); 27 Apr 2017 21:31:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=1631, iov, 8726, H*p:D*org X-HELO: mail-qk0-f171.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=QwRAn2OgAvDTTL9IbSd0a1xNvs2syEPdtDVKCB1Lqsw=; b=jVjBxIDCcnlMsbIGD0+v3SL1XsLHN/JQggj97X0N5eb/ehAdV5mlcIfk7vAVCMppck fpm6GgduSnhMbib3aFL8Ycg7IIaXQ2wp282XCtT+cLUtlnElQPMi2T9KR5SDIflawfVY fiCEm5psKVVQkonNV+tTGOfhmR3WkBvcT8LdQ00S56mxK+jwjc9eLwuuqc2rHgz1OOIj AwTVfM3ZBh/H6EZ8G7YK4AyqfWzAgYND3p5VPOhjBnVClMgbo+wT1wIUGp4+GTZTHxcn cSwKvhzrc2BlXKwxXRxXSRO60beKJCj8yUQR5Nbr2s0qR96xXiNcMUcRNVm0oBC2m547 sSsw== X-Gm-Message-State: AN3rC/5iykkSidNJbN21u2favGugdG7Mx7vCvBqhjlafZH4OJO/ffLjO 12lNUEp51JLn0vSEvenRfw== X-Received: by 10.55.33.17 with SMTP id h17mr7158628qkh.246.1493328661749; Thu, 27 Apr 2017 14:31:01 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/4] posix: Using libsupport for p{write,read}v tests Date: Thu, 27 Apr 2017 18:30:54 -0300 Message-Id: <1493328657-8172-1-git-send-email-adhemerval.zanella@linaro.org> Checked on x86_64-linux-gnu. * misc/tst-preadvwritev-common.c (do_prepare): Use libsupport expected arguments. (do_test): Adapt to use libsupport. --- ChangeLog | 6 ++++++ misc/tst-preadvwritev-common.c | 49 +++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 25 deletions(-) -- 2.7.4 diff --git a/misc/tst-preadvwritev-common.c b/misc/tst-preadvwritev-common.c index 2943312..5540dfb 100644 --- a/misc/tst-preadvwritev-common.c +++ b/misc/tst-preadvwritev-common.c @@ -16,31 +16,28 @@ License along with the GNU C Library; if not, see . */ +#include +#include +#include #include #include -static void do_prepare (void); -#define PREPARE(argc, argv) do_prepare () -static int do_test (void); -#define TEST_FUNCTION do_test () -#include "test-skeleton.c" +#include +#include static char *temp_filename; static int temp_fd; +static int do_test (void); + static void -do_prepare (void) +do_prepare (int argc, char **argv) { temp_fd = create_temp_file ("tst-preadvwritev.", &temp_filename); if (temp_fd == -1) - { - printf ("cannot create temporary file: %m\n"); - exit (1); - } + FAIL_EXIT1 ("cannot create temporary file"); } - -#define FAIL(str) \ - do { printf ("error: %s (line %d)\n", str, __LINE__); return 1; } while (0) +#define PREPARE do_prepare static int do_test_with_offset (off_t offset) @@ -63,15 +60,15 @@ do_test_with_offset (off_t offset) ret = pwritev (temp_fd, iov, 2, offset); if (ret == -1) - FAIL ("first pwritev returned -1"); + FAIL_RET ("first pwritev returned -1"); if (ret != (sizeof buf1 + sizeof buf2)) - FAIL ("first pwritev returned an unexpected value"); + FAIL_RET ("first pwritev returned an unexpected value"); ret = pwritev (temp_fd, iov, 2, sizeof buf1 + sizeof buf2 + offset); if (ret == -1) - FAIL ("second pwritev returned -1"); + FAIL_RET ("second pwritev returned -1"); if (ret != (sizeof buf1 + sizeof buf2)) - FAIL ("second pwritev returned an unexpected value"); + FAIL_RET ("second pwritev returned an unexpected value"); char buf3[32]; char buf4[64]; @@ -87,26 +84,28 @@ do_test_with_offset (off_t offset) /* Now read two buffer with 32 and 64 bytes respectively. */ ret = preadv (temp_fd, iov, 2, offset); if (ret == -1) - FAIL ("first preadv returned -1"); + FAIL_RET ("first preadv returned -1"); if (ret != (sizeof buf3 + sizeof buf4)) - FAIL ("first preadv returned an unexpected value"); + FAIL_RET ("first preadv returned an unexpected value"); if (memcmp (buf1, buf3, sizeof buf1) != 0) - FAIL ("first buffer from first preadv different than expected"); + FAIL_RET ("first buffer from first preadv different than expected"); if (memcmp (buf2, buf4, sizeof buf2) != 0) - FAIL ("second buffer from first preadv different than expected"); + FAIL_RET ("second buffer from first preadv different than expected"); ret = preadv (temp_fd, iov, 2, sizeof buf3 + sizeof buf4 + offset); if (ret == -1) - FAIL ("second preadv returned -1"); + FAIL_RET ("second preadv returned -1"); if (ret != (sizeof buf3 + sizeof buf4)) - FAIL ("second preadv returned an unexpected value"); + FAIL_RET ("second preadv returned an unexpected value"); /* And compare the buffers read and written to check if there are equal. */ if (memcmp (buf1, buf3, sizeof buf1) != 0) - FAIL ("first buffer from second preadv different than expected"); + FAIL_RET ("first buffer from second preadv different than expected"); if (memcmp (buf2, buf4, sizeof buf2) != 0) - FAIL ("second buffer from second preadv different than expected"); + FAIL_RET ("second buffer from second preadv different than expected"); return 0; } + +#include