All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it, Jan Stancek <jstancek@redhat.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	linux-unionfs@vger.kernel.org
Subject: [PATCH v3 1/6] syscalls/readahead01: Convert to newlib
Date: Thu, 11 Oct 2018 02:34:36 +0300	[thread overview]
Message-ID: <20181010233441.5337-2-amir73il@gmail.com> (raw)
In-Reply-To: <20181010233441.5337-1-amir73il@gmail.com>

* Use SPDX-License-Identifier

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Acked-by: Jan Stancek <jstancek@redhat.com>
---
 .../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 <sys/syscall.h>
 #include <sys/types.h>
 #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
-- 
2.17.1

WARNING: multiple messages have this Message-ID (diff)
From: Amir Goldstein <amir73il@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/6] syscalls/readahead01: Convert to newlib
Date: Thu, 11 Oct 2018 02:34:36 +0300	[thread overview]
Message-ID: <20181010233441.5337-2-amir73il@gmail.com> (raw)
In-Reply-To: <20181010233441.5337-1-amir73il@gmail.com>

* Use SPDX-License-Identifier

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Acked-by: Jan Stancek <jstancek@redhat.com>
---
 .../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 <sys/syscall.h>
 #include <sys/types.h>
 #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
-- 
2.17.1


  reply	other threads:[~2018-10-10 23:34 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10 23:34 [PATCH v3 0/6] Tests for readahead() and fadvise() on overlayfs Amir Goldstein
2018-10-10 23:34 ` [LTP] " Amir Goldstein
2018-10-10 23:34 ` Amir Goldstein [this message]
2018-10-10 23:34   ` [LTP] [PATCH v3 1/6] syscalls/readahead01: Convert to newlib Amir Goldstein
2018-11-02 15:34   ` Cyril Hrubis
2018-11-02 15:34     ` [LTP] " Cyril Hrubis
2018-10-10 23:34 ` [PATCH v3 2/6] syscalls/readahead02: Convert to newlib and cleanup Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-11-20 16:07   ` Cyril Hrubis
2018-11-20 16:07     ` [LTP] " Cyril Hrubis
2018-11-20 16:42     ` Cyril Hrubis
2018-11-20 16:42       ` Cyril Hrubis
2018-11-28 16:50     ` Amir Goldstein
2018-11-28 16:50       ` [LTP] " Amir Goldstein
2018-10-10 23:34 ` [PATCH v3 3/6] syscalls/readahead02: abort test if readahead syscall fails Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-11-20 16:30   ` Cyril Hrubis
2018-11-20 16:30     ` [LTP] " Cyril Hrubis
2018-11-28  9:52     ` Amir Goldstein
2018-11-28  9:52       ` [LTP] " Amir Goldstein
2018-10-10 23:34 ` [PATCH v3 4/6] syscalls/readahead02: test readahead() on an overlayfs file Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-10-10 23:34 ` [PATCH v3 5/6] syscalls/readahead02: test readahead using posix_fadvise() Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-10-10 23:34 ` [PATCH v3 6/6] syscalls/readahead02: fail test if readahead did not use any cache Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-11-02 10:32 ` [PATCH v3 0/6] Tests for readahead() and fadvise() on overlayfs Amir Goldstein
2018-11-02 10:32   ` [LTP] " Amir Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181010233441.5337-2-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=chrubis@suse.cz \
    --cc=jstancek@redhat.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=ltp@lists.linux.it \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.