From patchwork Fri Sep 28 13:06:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 976287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QVFovQ/F"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42MBlQ0YP6z9s4Z for ; Fri, 28 Sep 2018 23:06:41 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8F78D3E6623 for ; Fri, 28 Sep 2018 15:06:39 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id B96BE3E6609 for ; Fri, 28 Sep 2018 15:06:30 +0200 (CEST) Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id AC00F6012D4 for ; Fri, 28 Sep 2018 15:06:29 +0200 (CEST) Received: by mail-wm1-x341.google.com with SMTP id y26-v6so2153750wma.2 for ; Fri, 28 Sep 2018 06:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ViYbgs3N2DNAB+0XO7u24ySEN8b3X/AhABluOtGPPx4=; b=QVFovQ/F6czdNnwxLemOlQKoqdloswSA8V/A/HnTOLodb2YVg+rIYhdfWUbBQ3Lpj7 9YGKuRDtl3f7x6/ZsZ8f938vRA3cmFq40Zn6s+HAbkBazq+tvdhUFq2On67NEUDlxYGC IbRiKLmHk6pCmfUrhUx9Ne1V3RkM4r8fVJ6T3cHTAicu+D9z0LZp6OAaZoI3/Bafo8QC 8wxKqMbzGAXQ4ofG+ld4yLfD3Jidy0oMagPB3bXKuf+1znqurllr0EViU4Ng2sGNny/o d33EV2sOifewwNXJmN6VtvzV1989vi4bBJWHm3A/9Iz9EJAa50mq4z6st7KJTGnp3qPD 3wpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ViYbgs3N2DNAB+0XO7u24ySEN8b3X/AhABluOtGPPx4=; b=VvjypRgIkWGHm0aYzXLDikqXx6Xw9Q1jw2tNPMA9AmtzFURHdZL526OPq3XEH5rMeb of/jeuhQfOvbBvCZAebSSSiNP/IyWPse36JGd4dhhWDIIPwKagyOpkpsr3FbtSmCF7jc aNhFUkjtrRRVnYBurNebShTLIk2GxeznYByyHuGliVoPpSziV94bs08UirpVGdDPMfMX fd5W7Ek+I6i69hLcAfI+YjOkXKU8D8uy+2oPFHkNiChVwed1FbTF+1RrJOljCQfjxUR4 iyVRVBuACLw7vJENBwt6OCTvvYBHvkCy4MN3VCeg7z/ufop+LLA8xm+HjE00XpJiKIUn PMeA== X-Gm-Message-State: ABuFfojJrRdDTgIkH5nUhwxsk/QjUBjYXeaZa18YU1ePDrrUARiJhB4z yWAGbrXSzrXEtorLpmdyiiA= X-Google-Smtp-Source: ACcGV60OMjM0n/YrzyoYxG9Y4aAXKZrC+oDRuyx7/x2o+y1XIlV/3yBRMFtpjTWrNRaRRWNFyrFG+w== X-Received: by 2002:a7b:c1cd:: with SMTP id a13-v6mr1813702wmj.35.1538139989137; Fri, 28 Sep 2018 06:06:29 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id o12-v6sm4616415wrj.58.2018.09.28.06.06.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Sep 2018 06:06:28 -0700 (PDT) From: Amir Goldstein To: Cyril Hrubis Date: Fri, 28 Sep 2018 16:06:18 +0300 Message-Id: <20180928130621.28932-2-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180928130621.28932-1-amir73il@gmail.com> References: <20180928130621.28932-1-amir73il@gmail.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Cc: linux-unionfs@vger.kernel.org, ltp@lists.linux.it, Miklos Szeredi Subject: [LTP] [PATCH 1/4] syscalls/readahead01: Convert to newlib X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" * Use SPDX-License-Identifier Signed-off-by: Amir Goldstein --- .../kernel/syscalls/readahead/readahead01.c | 119 +++++------------- 1 file changed, 34 insertions(+), 85 deletions(-) diff --git a/testcases/kernel/syscalls/readahead/readahead01.c b/testcases/kernel/syscalls/readahead/readahead01.c index f35019488..682b524b3 100644 --- a/testcases/kernel/syscalls/readahead/readahead01.c +++ b/testcases/kernel/syscalls/readahead/readahead01.c @@ -1,25 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Linux Test Project, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it - * is free of the rightful claim of any third person regarding - * infringement or the like. Any license provided herein, whether - * implied or otherwise, applies only to this software file. Patent - * licenses, if any, provided herein do not apply to combinations of - * this program with other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. */ /* @@ -36,47 +17,36 @@ #include #include #include "config.h" -#include "test.h" -#include "safe_macros.h" +#include "tst_test.h" #include "lapi/syscalls.h" -char *TCID = "readahead01"; -int TST_TOTAL = 1; - -option_t options[] = { - {NULL, NULL, NULL} -}; - #if defined(__NR_readahead) -static void setup(void); -static void cleanup(void); - static int check_ret(long expected_ret) { - if (expected_ret == TEST_RETURN) { - tst_resm(TPASS, "expected ret success - " - "returned value = %ld", TEST_RETURN); + if (expected_ret == TST_RET) { + tst_res(TPASS, "expected ret success - " + "returned value = %ld", TST_RET); return 0; } - tst_resm(TFAIL, "unexpected failure - " - "returned value = %ld, expected: %ld", - TEST_RETURN, expected_ret); + tst_res(TFAIL, "unexpected failure - " + "returned value = %ld, expected: %ld", + TST_RET, expected_ret); return 1; } static int check_errno(long expected_errno) { - if (TEST_ERRNO == expected_errno) { - tst_resm(TPASS | TTERRNO, "expected failure"); + if (TST_ERR == expected_errno) { + tst_res(TPASS | TTERRNO, "expected failure"); return 0; } - if (TEST_ERRNO == 0) - tst_resm(TFAIL, "call succeeded unexpectedly"); + if (TST_ERR == 0) + tst_res(TFAIL, "call succeeded unexpectedly"); else - tst_resm(TFAIL | TTERRNO, "unexpected failure - " - "expected = %ld : %s, actual", - expected_errno, strerror(expected_errno)); + tst_res(TFAIL | TTERRNO, "unexpected failure - " + "expected = %ld : %s, actual", + expected_errno, strerror(expected_errno)); return 1; } @@ -85,19 +55,17 @@ static void test_bad_fd(void) char tempname[PATH_MAX] = "readahead01_XXXXXX"; int fd; - tst_resm(TINFO, "test_bad_fd -1"); + tst_res(TINFO, "test_bad_fd -1"); TEST(readahead(-1, 0, getpagesize())); check_ret(-1); check_errno(EBADF); - tst_resm(TINFO, "test_bad_fd O_WRONLY"); + tst_res(TINFO, "test_bad_fd O_WRONLY"); fd = mkstemp(tempname); if (fd == -1) - tst_resm(TBROK | TERRNO, "mkstemp failed"); + tst_res(TBROK | TERRNO, "mkstemp failed"); close(fd); - fd = open(tempname, O_WRONLY); - if (fd == -1) - tst_resm(TBROK | TERRNO, "Failed to open testfile"); + fd = SAFE_OPEN(tempname, O_WRONLY); TEST(readahead(fd, 0, getpagesize())); check_ret(-1); check_errno(EBADF); @@ -109,60 +77,41 @@ static void test_invalid_fd(void) { int fd[2]; - tst_resm(TINFO, "test_invalid_fd pipe"); - if (pipe(fd) < 0) - tst_resm(TBROK | TERRNO, "Failed to create pipe"); + tst_res(TINFO, "test_invalid_fd pipe"); + SAFE_PIPE(fd); TEST(readahead(fd[0], 0, getpagesize())); check_ret(-1); check_errno(EINVAL); close(fd[0]); close(fd[1]); - tst_resm(TINFO, "test_invalid_fd socket"); - fd[0] = socket(AF_INET, SOCK_STREAM, 0); - if (fd[0] < 0) - tst_resm(TBROK | TERRNO, "Failed to create socket"); + tst_res(TINFO, "test_invalid_fd socket"); + fd[0] = SAFE_SOCKET(AF_INET, SOCK_STREAM, 0); TEST(readahead(fd[0], 0, getpagesize())); check_ret(-1); check_errno(EINVAL); close(fd[0]); } -int main(int argc, char *argv[]) +void test_readahead(void) { - int lc; - - tst_parse_opts(argc, argv, options, NULL); - - setup(); - for (lc = 0; TEST_LOOPING(lc); lc++) { - tst_count = 0; - test_bad_fd(); - test_invalid_fd(); - } - cleanup(); - tst_exit(); + test_bad_fd(); + test_invalid_fd(); } static void setup(void) { - tst_require_root(); - tst_tmpdir(); - /* check if readahead syscall is supported */ - ltp_syscall(__NR_readahead, 0, 0, 0); - - TEST_PAUSE; + tst_syscall(__NR_readahead, 0, 0, 0); } -static void cleanup(void) -{ - tst_rmdir(); -} +static struct tst_test test = { + .needs_root = 1, + .needs_tmpdir = 1, + .setup = setup, + .test_all = test_readahead, +}; #else /* __NR_readahead */ -int main(void) -{ - tst_brkm(TCONF, NULL, "System doesn't support __NR_readahead"); -} + TST_TEST_TCONF("System doesn't support __NR_readahead"); #endif