All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 0/5] Convert syscalls/dup2/dup2{01...05} to new API
@ 2021-09-16 10:49 ` QI Fuli
  2021-09-16 10:49     ` QI Fuli
                     ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: QI Fuli @ 2021-09-16 10:49 UTC (permalink / raw)
  To: ltp; +Cc: QI Fuli

From: QI Fuli <qi.fuli@fujitsu.com>

Convert syscalls/dup2/dup2{01...05} to new API

QI Fuli (5):
  syscalls/dup2/dup201: Convert to new API
  syscalls/dup2/dup202: Convert to new API and merge dup204 into dup202
  syscalls/dup2/dup203: Convert to new API
  syscalls/dup2/dup205: Convert to new API
  syscalls/dup2: rename dup205 to dup204

 testcases/kernel/syscalls/dup2/dup201.c | 174 +++-----------
 testcases/kernel/syscalls/dup2/dup202.c | 191 ++++-----------
 testcases/kernel/syscalls/dup2/dup203.c | 307 ++++++++++--------------
 testcases/kernel/syscalls/dup2/dup204.c | 164 +++++--------
 testcases/kernel/syscalls/dup2/dup205.c | 134 -----------
 5 files changed, 263 insertions(+), 707 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/dup2/dup205.c

-- 
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v3 1/5] syscalls/dup2/dup201: Convert to new API
@ 2021-09-16 10:49     ` QI Fuli
  2021-09-17  7:04         ` Xiao Yang
  0 siblings, 1 reply; 14+ messages in thread
From: QI Fuli @ 2021-09-16 10:49 UTC (permalink / raw)
  To: ltp; +Cc: QI Fuli

From: QI Fuli <qi.fuli@fujitsu.com>

Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
---
 testcases/kernel/syscalls/dup2/dup201.c | 174 +++++-------------------
 1 file changed, 33 insertions(+), 141 deletions(-)

diff --git a/testcases/kernel/syscalls/dup2/dup201.c b/testcases/kernel/syscalls/dup2/dup201.c
index 4fa34466a..ff82b5fe7 100644
--- a/testcases/kernel/syscalls/dup2/dup201.c
+++ b/testcases/kernel/syscalls/dup2/dup201.c
@@ -1,163 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program 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 General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Copyright (c) International Business Machines  Corp., 2001
+ *	07/2001 Ported by Wayne Boyer
+ *	01/2002 Removed EMFILE test - Paul Larson
  */
 
-/*
- * NAME
- *	dup201.c
- *
- * DESCRIPTION
- *	Negative tests for dup2() with bad fd (EBADF)
- *
- * ALGORITHM
- * 	Setup:
- *	a.	Setup signal handling.
- *	b.	Pause for SIGUSR1 if option specified.
- *
- * 	Test:
- *	a.	Loop if the proper options are given.
- *	b.	Loop through the test cases
- * 	c.	Execute dup2() system call
- *	d.	Check return code, if system call failed (return=-1), test
- *		for EBADF.
- *
- * 	Cleanup:
- * 	a.	Print errno log and/or timing stats if options given
+/*\
+ * [Description]
  *
- * USAGE:  <for command-line>
- *  dup201 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -e   : Turn on errno logging.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
+ * Negative tests for dup2() with bad fd (EBADF)
+ * First fd argument is less than 0
+ * First fd argument is getdtablesize()
+ * Second fd argument is less than 0
+ * Second fd argument is getdtablesize()
  *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *	01/2002 Removed EMFILE test - Paul Larson
- *
- * RESTRICTIONS
- * 	NONE
  */
 
-#include <sys/types.h>
-#include <fcntl.h>
 #include <errno.h>
-#include <sys/time.h>
-#include <sys/resource.h>
 #include <unistd.h>
-#include <signal.h>
-#include "test.h"
-
-void setup(void);
-void cleanup(void);
-
-char *TCID = "dup201";
-int TST_TOTAL = 4;
+#include "tst_test.h"
 
-int maxfd;
-int goodfd = 5;
-int badfd = -1;
-int mystdout = 0;
+static int maxfd, mystdout;
+static int goodfd = 5;
+static int badfd = -1;
 
-struct test_case_t {
+static struct tcase {
 	int *ofd;
 	int *nfd;
-	int error;
-	void (*setupfunc) ();
-} TC[] = {
-	/* First fd argument is less than 0 - EBADF */
-	{&badfd, &goodfd, EBADF, NULL},
-	    /* First fd argument is getdtablesize() - EBADF */
-	{&maxfd, &goodfd, EBADF, NULL},
-	    /* Second fd argument is less than 0 - EBADF */
-	{&mystdout, &badfd, EBADF, NULL},
-	    /* Second fd argument is getdtablesize() - EBADF */
-	{&mystdout, &maxfd, EBADF, NULL},
+} tcases[] = {
+	{&badfd, &goodfd},
+	{&maxfd, &goodfd},
+	{&mystdout, &badfd},
+	{&mystdout, &maxfd},
 };
 
-int main(int ac, char **av)
+static void setup(void)
 {
-	int lc;
-	int i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/* loop through the test cases */
-
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			/* call the test case setup routine if necessary */
-			if (TC[i].setupfunc != NULL)
-				(*TC[i].setupfunc) ();
-
-			TEST(dup2(*TC[i].ofd, *TC[i].nfd));
-
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "call succeeded unexpectedly");
-				continue;
-			}
-
-			if (TEST_ERRNO == TC[i].error) {
-				tst_resm(TPASS,
-					 "failed as expected - errno = %d : %s",
-					 TEST_ERRNO, strerror(TEST_ERRNO));
-			} else {
-				tst_resm(TFAIL | TTERRNO,
-					 "failed unexpectedly; "
-					 "expected %d: %s", TC[i].error,
-					 strerror(TC[i].error));
-			}
-		}
-	}
-	cleanup();
-
-	tst_exit();
-}
-
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
 	/* get some test specific values */
 	maxfd = getdtablesize();
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *	       completion or premature exit.
- */
-void cleanup(void)
+static void run(unsigned int i)
 {
-	tst_rmdir();
+	struct tcase *tc = tcases + i;
+
+	TST_EXP_FAIL2(dup2(*tc->ofd, *tc->nfd), EBADF,
+			"dup2(%d, %d)", *tc->ofd, *tc->nfd);
 }
+
+static struct tst_test test = {
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+};
-- 
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v3 2/5] syscalls/dup2/dup202: Convert to new API and merge dup204 into dup202
@ 2021-09-16 10:49     ` QI Fuli
  2021-09-17  7:27         ` Xiao Yang
  0 siblings, 1 reply; 14+ messages in thread
From: QI Fuli @ 2021-09-16 10:49 UTC (permalink / raw)
  To: ltp; +Cc: QI Fuli

From: QI Fuli <qi.fuli@fujitsu.com>

Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
---
 testcases/kernel/syscalls/dup2/dup202.c | 191 +++++++-----------------
 testcases/kernel/syscalls/dup2/dup204.c | 128 ----------------
 2 files changed, 53 insertions(+), 266 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/dup2/dup204.c

diff --git a/testcases/kernel/syscalls/dup2/dup202.c b/testcases/kernel/syscalls/dup2/dup202.c
index c87769fa9..ac9808dd1 100644
--- a/testcases/kernel/syscalls/dup2/dup202.c
+++ b/testcases/kernel/syscalls/dup2/dup202.c
@@ -1,167 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program 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 General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Copyright (c) International Business Machines  Corp., 2001
+ * 	07/2001 Ported by Wayne Boyer
  */
 
-/*
- * NAME
- *	dup202.c
- *
- * DESCRIPTION
- *	Is the access mode the same for both file descriptors?
- *		0: read only ?	"0444"
- *		1: write only ? "0222"
- *		2: read/write ? "0666"
- *
- * ALGORITHM
- *	Creat a file with each access mode; dup each file descriptor;
- *	stat each file descriptor and compare modes of each pair
- *
- * USAGE:  <for command-line>
- *  dup202 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
- *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
+/*\
+ * [Description]
  *
- * RESTRICTIONS
- *	None
+ * Test whether the access mode and inode number are the same for both file 
+ * descriptors.
+ * Is the access mode the same for both file descriptors?
+ *	0: read only ?	"0444"
+ *	1: write only ? "0222"
+ *	2: read/write ? "0666"
  */
 
-#include <sys/types.h>
-#include <sys/stat.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <stdio.h>
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
+#include "tst_safe_macros.h"
 
-char *TCID = "dup202";
-int TST_TOTAL = 3;
-
-void setup(void);
-void cleanup(void);
-
-char testfile[40];
-int fail;
-int newfd;
+static char testfile[40];
 
 /* set these to a known index into our local file descriptor table */
-int duprdo = 10, dupwro = 20, duprdwr = 30;
+static int duprdo = 10, dupwro = 20, duprdwr = 30;
 
-struct test_case_t {
+static struct tcase {
 	int *nfd;
 	mode_t mode;
-} TC[] = {
-	/* The first test creat(es) a file with mode 0444 */
-	{
-	&duprdo, (S_IRUSR | S_IRGRP | S_IROTH)},
-	    /* The second test creat(es) a file with mode 0222 */
-	{
-	&dupwro, (S_IWUSR | S_IWGRP | S_IWOTH)},
-	    /* The third test creat(es) a file with mode 0666 */
-	{
-	&duprdwr,
-		    (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH)}
+} tcases[]= {
+	{&duprdo, (S_IRUSR | S_IRGRP | S_IROTH)},
+	{&dupwro, (S_IWUSR | S_IWGRP | S_IWOTH)},
+	{&duprdwr, (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH)},
 };
 
-int main(int ac, char **av)
+static void setup(void)
 {
-	int lc;
-	int i, ofd;
-	struct stat oldbuf, newbuf;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/* loop through the test cases */
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			if ((ofd = creat(testfile, TC[i].mode)) == -1)
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "creat failed");
-
-			TEST(dup2(ofd, *TC[i].nfd));
-
-			if (TEST_RETURN == -1) {
-				tst_resm(TFAIL | TTERRNO,
-					 "call failed unexpectedly");
-				continue;
-			}
+	umask(0);
+	sprintf(testfile, "dup202.%d", getpid());
+}
 
-			/* stat the original file */
-			SAFE_FSTAT(cleanup, ofd, &oldbuf);
+static void run(unsigned int i)
+{
+	int ofd;
+	struct stat oldbuf, newbuf;
+	struct tcase *tc = tcases + i;
 
-			/* stat the duped file */
-			SAFE_FSTAT(cleanup, *TC[i].nfd, &newbuf);
+	ofd = SAFE_OPEN(testfile, O_CREAT, tc->mode);
 
-			if (oldbuf.st_mode != newbuf.st_mode)
-				tst_resm(TFAIL, "original and dup "
-					 "modes do not match");
-			else
-				tst_resm(TPASS, "fstat shows new and "
-					 "old modes are the same");
+	TEST(dup2(ofd, *tc->nfd));
 
-			/* remove the file so that we can use it again */
-			if (close(*TC[i].nfd) == -1)
-				perror("close failed");
-			if (close(ofd) == -1)
-				perror("close failed");
-			if (unlink(testfile) == -1)
-				perror("unlink failed");
-		}
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TTERRNO, "call failed unexpectedly");
+		return;
 	}
 
-	cleanup();
-	tst_exit();
-}
-
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	/* stat the original file */
+	SAFE_FSTAT(ofd, &oldbuf);
 
-	TEST_PAUSE;
+	/* stat the duped file */
+	SAFE_FSTAT(*tc->nfd, &newbuf);
 
-	tst_tmpdir();
+	if (oldbuf.st_mode != newbuf.st_mode)
+		tst_res(TFAIL, "original and duped modes do not match");
+	else
+		tst_res(TPASS, "original and duped modes are the same");
 
-	(void)umask(0);
+	if (oldbuf.st_ino != newbuf.st_ino)
+		tst_res(TFAIL, "original and duped inodes do not match");
+	else
+		tst_res(TPASS, "original and duped inodes are the same");
 
-	sprintf(testfile, "dup202.%d", getpid());
+	SAFE_CLOSE(ofd);
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *	       completion or premature exit.
- */
-void cleanup(void)
-{
-	tst_rmdir();
-}
+static struct tst_test test = {
+	.needs_tmpdir = 1,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = run,
+	.setup = setup,
+};
diff --git a/testcases/kernel/syscalls/dup2/dup204.c b/testcases/kernel/syscalls/dup2/dup204.c
deleted file mode 100644
index a357bc17e..000000000
--- a/testcases/kernel/syscalls/dup2/dup204.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program 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 General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * NAME
- *	dup204.c
- *
- * DESCRIPTION
- *	Testcase to check the basic functionality of dup2(2).
- *
- * ALGORITHM
- *	attempt to call dup2() on read/write ends of a pipe
- *
- * USAGE:  <for command-line>
- *  dup204 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
- *
- * RESTRICTION
- *	NONE
- */
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-#include "test.h"
-#include "safe_macros.h"
-
-void setup();
-void cleanup();
-
-char *TCID = "dup204";
-int TST_TOTAL = 2;
-
-int fd[2];
-int nfd[2];
-
-int main(int ac, char **av)
-{
-	int lc;
-	int i;
-	struct stat oldbuf, newbuf;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/* loop through the test cases */
-		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(dup2(fd[i], nfd[i]));
-
-			if (TEST_RETURN == -1) {
-				tst_resm(TFAIL, "call failed unexpectedly");
-				continue;
-			}
-
-			SAFE_FSTAT(cleanup, fd[i], &oldbuf);
-			SAFE_FSTAT(cleanup, nfd[i], &newbuf);
-
-			if (oldbuf.st_ino != newbuf.st_ino)
-				tst_resm(TFAIL, "original and duped "
-					 "inodes do not match");
-			else
-				tst_resm(TPASS, "original and duped "
-					 "inodes are the same");
-
-			SAFE_CLOSE(cleanup, TEST_RETURN);
-		}
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-void setup(void)
-{
-	fd[0] = -1;
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	SAFE_PIPE(cleanup, fd);
-}
-
-void cleanup(void)
-{
-	int i;
-
-	for (i = 0; i < (int)ARRAY_SIZE(fd); i++) {
-		close(fd[i]);
-		close(nfd[i]);
-	}
-
-	tst_rmdir();
-}
-- 
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v3 3/5] syscalls/dup2/dup203: Convert to new API
@ 2021-09-16 10:49     ` QI Fuli
  2021-09-17  8:16         ` Xiao Yang
  0 siblings, 1 reply; 14+ messages in thread
From: QI Fuli @ 2021-09-16 10:49 UTC (permalink / raw)
  To: ltp; +Cc: QI Fuli

From: QI Fuli <qi.fuli@fujitsu.com>

Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
---
 testcases/kernel/syscalls/dup2/dup203.c | 307 ++++++++++--------------
 1 file changed, 121 insertions(+), 186 deletions(-)

diff --git a/testcases/kernel/syscalls/dup2/dup203.c b/testcases/kernel/syscalls/dup2/dup203.c
index e6f281adf..86ad49dc1 100644
--- a/testcases/kernel/syscalls/dup2/dup203.c
+++ b/testcases/kernel/syscalls/dup2/dup203.c
@@ -1,208 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program 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 General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Copyright (c) International Business Machines  Corp., 2001
+ * 	07/2001 Ported by Wayne Boyer
  */
 
-/*
- * NAME
- *	dup203.c
- *
- * DESCRIPTION
+/*\
+ * [Description]
  *	Testcase to check the basic functionality of dup2().
- *
- * ALGORITHM
- *	1.	Attempt to dup2() on an open file descriptor.
- *	2.	Attempt to dup2() on a close file descriptor.
- *
- * USAGE:  <for command-line>
- *  dup203 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *             -i n : Execute test n times.
- *             -I x : Execute test for x seconds.
- *             -P x : Pause for x seconds between iterations.
- *             -t   : Turn on syscall timing.
- *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS
- *	NONE
+ *	1. Attempt to dup2() on an open file descriptor.
+ *	2. Attempt to dup2() on a close file descriptor.
  */
 
-#include <fcntl.h>
-#include <sys/param.h>
 #include <errno.h>
-#include <string.h>
-#include "test.h"
-#include "safe_macros.h"
+#include <stdio.h>
+#include "tst_test.h"
+#include "tst_safe_macros.h"
+
+static int fd0, fd1, fd2;
+static char filename0[40], filename1[40];
+static char buf[40];
+
+static void verify_open(void);
+static void verify_close(void);
+
+static struct tcase {
+	char *desc;
+	void (*verify)();
+} tcases [] = {
+	{"Test duping over an open fd", verify_open},
+	{"Test close on exec flag", verify_close},
+};
+
+static void verify_open(void)
+{
+	fd0 = SAFE_CREAT(filename0, 0666);
+	SAFE_WRITE(1, fd0, filename0, strlen(filename0));
+	SAFE_CLOSE(fd0);
 
-void setup(void);
-void cleanup(void);
+	fd1 = SAFE_CREAT(filename1, 0666);
+	SAFE_WRITE(1, fd1, filename1, strlen(filename1));
+	SAFE_CLOSE(fd1);
 
-char *TCID = "dup203";
-int TST_TOTAL = 1;
+	fd0 = SAFE_OPEN(filename0, O_RDONLY);
+	fd1 = SAFE_OPEN(filename1, O_RDONLY);
 
-int main(int ac, char **av)
-{
-	int fd0, fd1, fd2, rval;
-	char filename0[40], filename1[40];
-	char buf[40];
-
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-//block1:
-		tst_resm(TINFO, "Enter block 1");
-		tst_resm(TINFO, "Test duping over an open fd");
-
-		sprintf(filename0, "dup202.file0.%d\n", getpid());
-		sprintf(filename1, "dup202.file1.%d\n", getpid());
-		unlink(filename0);
-		unlink(filename1);
-
-		if ((fd0 = creat(filename0, 0666)) == -1)
-			tst_brkm(TBROK, cleanup, "cannot create first file");
-		if (write(fd0, filename0, strlen(filename0)) == -1)
-			tst_brkm(TBROK, cleanup, "filename0: write(2) failed");
-
-		if ((fd1 = creat(filename1, 0666)) == -1)
-			tst_brkm(TBROK, cleanup, "Cannot create second file");
-		if (write(fd1, filename1, strlen(filename1)) == -1)
-			tst_brkm(TBROK, cleanup, "filename1: write(2) failed");
-
-		SAFE_CLOSE(cleanup, fd0);
-		if ((fd0 = open(filename0, O_RDONLY)) == -1)
-			tst_brkm(TBROK, cleanup, "open(2) on filename0 failed");
-
-		SAFE_CLOSE(cleanup, fd1);
-		if ((fd1 = open(filename1, O_RDONLY)) == -1)
-			tst_brkm(TBROK, cleanup, "open(2) on filename1 failed");
-
-		TEST(dup2(fd0, fd1));
-
-		if ((fd2 = TEST_RETURN) == -1) {
-			tst_resm(TFAIL, "call failed unexpectedly");
-		} else {
-			if (fd1 != fd2) {
-				tst_resm(TFAIL, "file descriptors don't match");
-				break;
-			}
-
-			memset(buf, 0, sizeof(buf));
-			if (read(fd2, buf, sizeof(buf)) == -1)
-				tst_brkm(TBROK, cleanup, "read(2) failed");
-			if (strcmp(buf, filename0) != 0)
-				tst_resm(TFAIL, "read from file got bad data");
-			tst_resm(TPASS, "dup2 test 1 functionality is correct");
-		}
-
-		close(fd0);
-		close(fd1);
-		close(fd2);
-		unlink(filename0);
-		unlink(filename1);
-
-		tst_resm(TINFO, "Exit block 1");
-
-//block2:
-		tst_resm(TINFO, "Enter block 2");
-		tst_resm(TINFO, "Test close on exec flag");
-
-		sprintf(filename0, "dup02.%d\n", getpid());
-		unlink(filename0);
-
-		if ((fd0 = creat(filename0, 0666)) == -1) {
-			tst_brkm(TBROK, cleanup, "Cannot create first file");
-		}
-		if (fcntl(fd0, F_SETFD, 1) == -1) {
-			tst_brkm(TBROK, cleanup, "setting close on exec flag "
-				 "on fd0 failed");
-		}
-
-		if ((fd2 = creat(filename1, 0666)) == -1) {
-			tst_brkm(TBROK, cleanup, "Cannot create second file");
-		}
-
-		/* SAFE_CLOSE() sets the fd to -1 avoid it here */
-		rval = fd2;
-		SAFE_CLOSE(cleanup, rval);
-
-		TEST(dup2(fd0, fd2));
-
-		if ((fd1 = TEST_RETURN) == -1) {
-			tst_resm(TFAIL, "call failed unexpectedly");
-		} else {
-			if (fd1 != fd2) {
-				tst_resm(TFAIL, "bad dup2 descriptor %d", fd1);
-				break;
-			}
-
-			if ((rval = fcntl(fd1, F_GETFD, 0)) != 0) {
-				tst_resm(TBROK | TERRNO,
-					 "fcntl F_GETFD on fd1 failed; expected a "
-					 "return value of 0x0, got %#x", rval);
-				break;
-			}
-			if ((rval = (fcntl(fd0, F_GETFL, 0) & O_ACCMODE)) !=
-			    O_WRONLY) {
-				tst_resm(TFAIL, "fctnl F_GETFL bad rval on fd0 "
-					 "Expected %#x got %#x", O_WRONLY,
-					 rval);
-			}
-			tst_resm(TPASS, "dup2 test 2 functionality is correct");
-		}
-
-		close(fd0);
-		close(fd1);
-
-		unlink(filename0);
-		unlink(filename1);
-		tst_resm(TINFO, "Exit block 2");
+	TEST(dup2(fd0, fd1));
+
+	fd2 = TST_RET;
+	if (TST_RET == -1) {
+		tst_res(TFAIL, "call failed unexpectedly");
+		goto free;
 	}
 
-	cleanup();
-	tst_exit();
+	if (fd1 != fd2) {
+		tst_res(TFAIL, "file descriptors don't match");
+		goto free;
+	}
+
+	memset(buf, 0, sizeof(buf));
+	SAFE_READ(0, fd2, buf, sizeof(buf));
+	if (strcmp(buf, filename0) != 0)
+		tst_res(TFAIL, "read from file got bad data");
+	else
+		tst_res(TPASS, "dup2 test 1 functionality is correct");
+
+free:
+	SAFE_CLOSE(fd0);
+	SAFE_CLOSE(fd1);
+	SAFE_UNLINK(filename0);
+	SAFE_UNLINK(filename1);
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
+static void verify_close(void)
 {
+	int rval, rc = 0;
+
+	sprintf(filename0, "dup203.%d\n", getpid());
+	unlink(filename0);
+
+	fd0 = SAFE_CREAT(filename0, 0666);
+	SAFE_FCNTL(fd0, F_SETFD, 1);
+
+	fd2 = SAFE_CREAT(filename1, 0666);
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	/* SAFE_CLOSE() sets the fd to -1 avoid it here */
+	rval = fd2;
+	SAFE_CLOSE(rval);
 
-	TEST_PAUSE;
+	TEST(dup2(fd0, fd2));
 
-	tst_tmpdir();
+	fd1 = TST_RET;
+	if (TST_RET == -1) {
+		tst_res(TFAIL, "call failed unexpectedly");
+		goto free;
+	}
+
+	if (fd1 != fd2) {
+		tst_res(TFAIL, "bad dup2 descriptor %d", fd1);
+		goto free;
+	}
+
+	rval = SAFE_FCNTL(fd1, F_GETFD, 0);
+	if (rval != 0) {
+		tst_res(TFAIL, "fcntl F_GETFD on fd1 failed; expected a "
+			"return value of 0x0, got %#x", rval);
+		rc++;
+	}
+
+	if (!rc)
+		tst_res(TPASS, "dup2 test 2 functionality is correct");
+
+free:
+	SAFE_CLOSE(fd0);
+	SAFE_CLOSE(fd1);
+	SAFE_UNLINK(filename0);
+	SAFE_UNLINK(filename1);
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *	       completion or premature exit.
- */
-void cleanup(void)
+static void run(unsigned int i)
 {
-	tst_rmdir();
+	struct tcase *tc = tcases + i;
+
+	tst_res(TINFO, tc->desc);
+	tc->verify();
+
+}
+
+static void setup(void)
+{
+	int pid;
+
+	pid = getpid();
+	sprintf(filename0, "dup203.file0.%d\n", pid);
+	sprintf(filename1, "dup203.file1.%d\n", pid);
 }
+
+static struct tst_test test = {
+	.setup = setup,
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_tmpdir = 1,
+	.test = run,
+};
-- 
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v3 4/5] syscalls/dup2/dup205: Convert to new API
@ 2021-09-16 10:49     ` QI Fuli
  2021-09-17  8:37         ` Xiao Yang
  0 siblings, 1 reply; 14+ messages in thread
From: QI Fuli @ 2021-09-16 10:49 UTC (permalink / raw)
  To: ltp; +Cc: QI Fuli

From: QI Fuli <qi.fuli@fujitsu.com>

Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
---
 testcases/kernel/syscalls/dup2/dup205.c | 166 ++++++++----------------
 1 file changed, 54 insertions(+), 112 deletions(-)

diff --git a/testcases/kernel/syscalls/dup2/dup205.c b/testcases/kernel/syscalls/dup2/dup205.c
index 0b324531f..0e2766d53 100644
--- a/testcases/kernel/syscalls/dup2/dup205.c
+++ b/testcases/kernel/syscalls/dup2/dup205.c
@@ -1,134 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
+ * Copyright (c) International Business Machines  Corp., 2002
  *
- *   Copyright (c) International Business Machines  Corp., 2002
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
+ */
+
+/*\
+ * [Description]
  *
- *   This program 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 General Public License for more details.
+ * Negative test for dup2() with max open file descriptors.
  *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /* Ported from SPIE, section2/iosuite/dup6.c, by Airong Zhang */
 
-/*======================================================================
-	=================== TESTPLAN SEGMENT ===================
->KEYS:  < dup2()
->WHAT:  < Does dup return -1 on the 21st file?
->HOW:   < Create up to _NFILE files and check for -1 return on the
-	< next attempt
-	< Should check NOFILE as well as _NFILE.  19-Jun-84 Dale.
->BUGS:  <
-======================================================================*/
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
+#include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
-#include "test.h"
-
-char *TCID = "dup205";
-int TST_TOTAL = 1;
-int *fildes;
-int min;
-int local_flag;
-
-#define PASSED 1
-#define FAILED 0
-
-static void setup(void);
-static void cleanup(void);
-
-int main(int ac, char *av[])
-{
-	int ifile;
-	char pfilname[40];
-	int serrno;
-
-	int lc;
-
-	ifile = -1;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	local_flag = PASSED;
+#include "tst_test.h"
+#include "tst_safe_macros.h"
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		sprintf(pfilname, "./dup205.%d\n", getpid());
-		unlink(pfilname);
-		serrno = 0;
-		if ((fildes[0] = creat(pfilname, 0666)) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "creat failed");
-		else {
-			fildes[fildes[0]] = fildes[0];
-			for (ifile = fildes[0] + 1; ifile < min + 10; ifile++) {
-				if ((fildes[ifile] = dup2(fildes[ifile - 1],
-							  ifile)) == -1) {
-					serrno = errno;
-					break;
-				} else {
-					if (fildes[ifile] != ifile) {
-						tst_brkm(TFAIL, cleanup,
-							 "got wrong descriptor "
-							 "number back (%d != %d)",
-							 fildes[ifile], ifile);
-					}
-				}
-			}	/* end for */
-			if (ifile < min) {
-				tst_resm(TFAIL, "Not enough files duped");
-				local_flag = FAILED;
-			} else if (ifile > min) {
-				tst_resm(TFAIL, "Too many files duped");
-				local_flag = FAILED;
-			}
-			if (serrno != EBADF && serrno != EMFILE &&
-			    serrno != EINVAL) {
-				tst_resm(TFAIL, "bad errno on dup2 failure");
-				local_flag = FAILED;
-			}
-		}
-		unlink(pfilname);
-		for (ifile = fildes[0]; ifile < min + 10; ifile++)
-			close(fildes[ifile]);
-		if (local_flag == PASSED) {
-			tst_resm(TPASS, "Test passed.");
-		} else {
-			tst_resm(TFAIL, "Test failed.");
-		}
-
-	}
-	cleanup();
-	tst_exit();
-}
+static int *fildes;
+static int min;
+static char pfilname[40];
 
 static void setup(void)
 {
-	tst_tmpdir();
-
 	min = getdtablesize();	/* get number of files allowed open */
-	fildes = malloc((min + 10) * sizeof(int));
-	if (fildes == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup, "malloc error");
+	fildes = SAFE_MALLOC((min + 10) * sizeof(int));
+
+	sprintf(pfilname, "./dup205.%d\n", getpid());
 }
 
 static void cleanup(void)
 {
 	if (fildes != NULL)
 		free(fildes);
-	tst_rmdir();
 }
+
+static void run(void)
+{
+	int ifile;
+
+	ifile = -1;
+
+	fildes[0] = SAFE_CREAT(pfilname, 0666);
+	fildes[fildes[0]] = fildes[0];
+	for (ifile = fildes[0] + 1; ifile < min + 10; ifile++) {
+		TEST(dup2(fildes[ifile - 1], ifile));
+		if ((fildes[ifile] = TST_RET) == -1)
+			break;
+		if (fildes[ifile] != ifile)
+			tst_brk(TFAIL, "got wrong descriptor number back "
+				"(%d != %d)", fildes[ifile], ifile);
+	}	/* end for */
+
+	if (TST_ERR != EBADF)
+		tst_res(TFAIL, "bad errno on dup2 failure");
+
+	if (ifile < min)
+		tst_res(TFAIL, "Not enough files duped");
+	else if (ifile > min)
+		tst_res(TFAIL, "Too many files duped");
+	else
+		tst_res(TPASS, "Test passed.");
+
+	SAFE_CLOSE(fildes[0]);
+	SAFE_UNLINK(pfilname);
+}
+
+static struct tst_test test = {
+	.needs_tmpdir = 1,
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+};
-- 
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v3 5/5] syscalls/dup2: rename dup205 to dup204
@ 2021-09-16 10:49     ` QI Fuli
  2021-09-17  3:20         ` xuyang2018.jy
  0 siblings, 1 reply; 14+ messages in thread
From: QI Fuli @ 2021-09-16 10:49 UTC (permalink / raw)
  To: ltp; +Cc: QI Fuli

From: QI Fuli <qi.fuli@fujitsu.com>

Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
---
 testcases/kernel/syscalls/dup2/{dup205.c => dup204.c} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename testcases/kernel/syscalls/dup2/{dup205.c => dup204.c} (100%)

diff --git a/testcases/kernel/syscalls/dup2/dup205.c b/testcases/kernel/syscalls/dup2/dup204.c
similarity index 100%
rename from testcases/kernel/syscalls/dup2/dup205.c
rename to testcases/kernel/syscalls/dup2/dup204.c
-- 
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v3 5/5] syscalls/dup2: rename dup205 to dup204
@ 2021-09-17  3:20         ` xuyang2018.jy
  2021-09-17  4:29             ` qi.fuli
  0 siblings, 1 reply; 14+ messages in thread
From: xuyang2018.jy @ 2021-09-17  3:20 UTC (permalink / raw)
  To: QI Fuli; +Cc: qi.fuli, ltp

Hi Qi

> From: QI Fuli<qi.fuli@fujitsu.com>
>
> Signed-off-by: QI Fuli<qi.fuli@fujitsu.com>
> ---
>   testcases/kernel/syscalls/dup2/{dup205.c =>  dup204.c} | 0
>   1 file changed, 0 insertions(+), 0 deletions(-)
>   rename testcases/kernel/syscalls/dup2/{dup205.c =>  dup204.c} (100%)
You miss .gitnore and runtest/syscalls. We also need to remove dup205 
tag in them.

No need v4. Maintainer Will remove them when merging this patchset.

Other than some nits(useless comments, empty line, whitespace), this 
patchset looks good to me.

Reviewed-by: Yang Xu <xuyang2018.jy@fujitsu.com>

Best Regards
Yang Xu

>
> diff --git a/testcases/kernel/syscalls/dup2/dup205.c b/testcases/kernel/syscalls/dup2/dup204.c
> similarity index 100%
> rename from testcases/kernel/syscalls/dup2/dup205.c
> rename to testcases/kernel/syscalls/dup2/dup204.c

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v3 5/5] syscalls/dup2: rename dup205 to dup204
@ 2021-09-17  4:29             ` qi.fuli
  0 siblings, 0 replies; 14+ messages in thread
From: qi.fuli @ 2021-09-17  4:29 UTC (permalink / raw)
  To: xuyang2018.jy, QI Fuli; +Cc: ltp

> Subject: Re: [LTP] [PATCH v3 5/5] syscalls/dup2: rename dup205 to dup204
> 
> Hi Qi
> 
> > From: QI Fuli<qi.fuli@fujitsu.com>
> >
> > Signed-off-by: QI Fuli<qi.fuli@fujitsu.com>
> > ---
> >   testcases/kernel/syscalls/dup2/{dup205.c =>  dup204.c} | 0
> >   1 file changed, 0 insertions(+), 0 deletions(-)
> >   rename testcases/kernel/syscalls/dup2/{dup205.c =>  dup204.c} (100%)
> You miss .gitnore and runtest/syscalls. We also need to remove dup205 tag in
> them.
> 
> No need v4. Maintainer Will remove them when merging this patchset.
> 
> Other than some nits(useless comments, empty line, whitespace), this patchset
> looks good to me.
> 
> Reviewed-by: Yang Xu <xuyang2018.jy@fujitsu.com>
> 
> Best Regards
> Yang Xu
> 

Thank you very much.

Best,
QI

> >
> > diff --git a/testcases/kernel/syscalls/dup2/dup205.c
> > b/testcases/kernel/syscalls/dup2/dup204.c
> > similarity index 100%
> > rename from testcases/kernel/syscalls/dup2/dup205.c
> > rename to testcases/kernel/syscalls/dup2/dup204.c

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v3 1/5] syscalls/dup2/dup201: Convert to new API
@ 2021-09-17  7:04         ` Xiao Yang
  0 siblings, 0 replies; 14+ messages in thread
From: Xiao Yang @ 2021-09-17  7:04 UTC (permalink / raw)
  To: QI Fuli, ltp; +Cc: QI Fuli

On 9/16/21 6:49 PM, QI Fuli wrote:
> From: QI Fuli <qi.fuli@fujitsu.com>
>
> Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
> ---
>   testcases/kernel/syscalls/dup2/dup201.c | 174 +++++-------------------
>   1 file changed, 33 insertions(+), 141 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/dup2/dup201.c b/testcases/kernel/syscalls/dup2/dup201.c
> index 4fa34466a..ff82b5fe7 100644
> --- a/testcases/kernel/syscalls/dup2/dup201.c
> +++ b/testcases/kernel/syscalls/dup2/dup201.c
> @@ -1,163 +1,55 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
>   /*
> - *
> - *   Copyright (c) International Business Machines  Corp., 2001
> - *
> - *   This program is free software;  you can redistribute it and/or modify
> - *   it under the terms of the GNU General Public License as published by
> - *   the Free Software Foundation; either version 2 of the License, or
> - *   (at your option) any later version.
> - *
> - *   This program 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 General Public License for more details.
> - *
> - *   You should have received a copy of the GNU General Public License
> - *   along with this program;  if not, write to the Free Software
> - *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Copyright (c) International Business Machines  Corp., 2001
> + *	07/2001 Ported by Wayne Boyer
> + *	01/2002 Removed EMFILE test - Paul Larson
>    */
>   
> -/*
> - * NAME
> - *	dup201.c
> - *
> - * DESCRIPTION
> - *	Negative tests for dup2() with bad fd (EBADF)
> - *
> - * ALGORITHM
> - * 	Setup:
> - *	a.	Setup signal handling.
> - *	b.	Pause for SIGUSR1 if option specified.
> - *
> - * 	Test:
> - *	a.	Loop if the proper options are given.
> - *	b.	Loop through the test cases
> - * 	c.	Execute dup2() system call
> - *	d.	Check return code, if system call failed (return=-1), test
> - *		for EBADF.
> - *
> - * 	Cleanup:
> - * 	a.	Print errno log and/or timing stats if options given
> +/*\
> + * [Description]
>    *
> - * USAGE:  <for command-line>
> - *  dup201 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
> - *     where,  -c n : Run n copies concurrently.
> - *             -e   : Turn on errno logging.
> - *             -i n : Execute test n times.
> - *             -I x : Execute test for x seconds.
> - *             -P x : Pause for x seconds between iterations.
> - *             -t   : Turn on syscall timing.
> + * Negative tests for dup2() with bad fd (EBADF)
> + * First fd argument is less than 0
> + * First fd argument is getdtablesize()
> + * Second fd argument is less than 0
> + * Second fd argument is getdtablesize()

Hi Qi,

You should use the following list in markdown so that the description 
can be processed by docparse properly:

* Negative tests for dup2() with bad fd (EBADF):
*
* - First fd argument is less than 0
* - First fd argument is getdtablesize()
* - Second fd argument is less than 0
* - Second fd argument is getdtablesize()

Best Regards,
Xiao Yang

>    *
> - * HISTORY
> - *	07/2001 Ported by Wayne Boyer
> - *	01/2002 Removed EMFILE test - Paul Larson
> - *
> - * RESTRICTIONS
> - * 	NONE
>    */
>   
> -#include <sys/types.h>
> -#include <fcntl.h>
>   #include <errno.h>
> -#include <sys/time.h>
> -#include <sys/resource.h>
>   #include <unistd.h>
> -#include <signal.h>
> -#include "test.h"
> -
> -void setup(void);
> -void cleanup(void);
> -
> -char *TCID = "dup201";
> -int TST_TOTAL = 4;
> +#include "tst_test.h"
>   
> -int maxfd;
> -int goodfd = 5;
> -int badfd = -1;
> -int mystdout = 0;
> +static int maxfd, mystdout;
> +static int goodfd = 5;
> +static int badfd = -1;
>   
> -struct test_case_t {
> +static struct tcase {
>   	int *ofd;
>   	int *nfd;
> -	int error;
> -	void (*setupfunc) ();
> -} TC[] = {
> -	/* First fd argument is less than 0 - EBADF */
> -	{&badfd, &goodfd, EBADF, NULL},
> -	    /* First fd argument is getdtablesize() - EBADF */
> -	{&maxfd, &goodfd, EBADF, NULL},
> -	    /* Second fd argument is less than 0 - EBADF */
> -	{&mystdout, &badfd, EBADF, NULL},
> -	    /* Second fd argument is getdtablesize() - EBADF */
> -	{&mystdout, &maxfd, EBADF, NULL},
> +} tcases[] = {
> +	{&badfd, &goodfd},
> +	{&maxfd, &goodfd},
> +	{&mystdout, &badfd},
> +	{&mystdout, &maxfd},
>   };
>   
> -int main(int ac, char **av)
> +static void setup(void)
>   {
> -	int lc;
> -	int i;
> -
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -	setup();
> -
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
> -		tst_count = 0;
> -
> -		/* loop through the test cases */
> -
> -		for (i = 0; i < TST_TOTAL; i++) {
> -
> -			/* call the test case setup routine if necessary */
> -			if (TC[i].setupfunc != NULL)
> -				(*TC[i].setupfunc) ();
> -
> -			TEST(dup2(*TC[i].ofd, *TC[i].nfd));
> -
> -			if (TEST_RETURN != -1) {
> -				tst_resm(TFAIL, "call succeeded unexpectedly");
> -				continue;
> -			}
> -
> -			if (TEST_ERRNO == TC[i].error) {
> -				tst_resm(TPASS,
> -					 "failed as expected - errno = %d : %s",
> -					 TEST_ERRNO, strerror(TEST_ERRNO));
> -			} else {
> -				tst_resm(TFAIL | TTERRNO,
> -					 "failed unexpectedly; "
> -					 "expected %d: %s", TC[i].error,
> -					 strerror(TC[i].error));
> -			}
> -		}
> -	}
> -	cleanup();
> -
> -	tst_exit();
> -}
> -
> -/*
> - * setup() - performs all ONE TIME setup for this test.
> - */
> -void setup(void)
> -{
> -
> -	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> -
> -	TEST_PAUSE;
> -
> -	tst_tmpdir();
> -
>   	/* get some test specific values */
>   	maxfd = getdtablesize();
>   }
>   
> -/*
> - * cleanup() - performs all ONE TIME cleanup for this test at
> - *	       completion or premature exit.
> - */
> -void cleanup(void)
> +static void run(unsigned int i)
>   {
> -	tst_rmdir();
> +	struct tcase *tc = tcases + i;
> +
> +	TST_EXP_FAIL2(dup2(*tc->ofd, *tc->nfd), EBADF,
> +			"dup2(%d, %d)", *tc->ofd, *tc->nfd);
>   }
> +
> +static struct tst_test test = {
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.test = run,
> +	.setup = setup,
> +};


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v3 2/5] syscalls/dup2/dup202: Convert to new API and merge dup204 into dup202
@ 2021-09-17  7:27         ` Xiao Yang
  0 siblings, 0 replies; 14+ messages in thread
From: Xiao Yang @ 2021-09-17  7:27 UTC (permalink / raw)
  To: QI Fuli, ltp; +Cc: QI Fuli

On 9/16/21 6:49 PM, QI Fuli wrote:
> From: QI Fuli <qi.fuli@fujitsu.com>
>
> Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
> ---
>   testcases/kernel/syscalls/dup2/dup202.c | 191 +++++++-----------------
>   testcases/kernel/syscalls/dup2/dup204.c | 128 ----------------
>   2 files changed, 53 insertions(+), 266 deletions(-)
>   delete mode 100644 testcases/kernel/syscalls/dup2/dup204.c
>
> diff --git a/testcases/kernel/syscalls/dup2/dup202.c b/testcases/kernel/syscalls/dup2/dup202.c
> index c87769fa9..ac9808dd1 100644
> --- a/testcases/kernel/syscalls/dup2/dup202.c
> +++ b/testcases/kernel/syscalls/dup2/dup202.c
> @@ -1,167 +1,82 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
>   /*
> - *
> - *   Copyright (c) International Business Machines  Corp., 2001
> - *
> - *   This program is free software;  you can redistribute it and/or modify
> - *   it under the terms of the GNU General Public License as published by
> - *   the Free Software Foundation; either version 2 of the License, or
> - *   (at your option) any later version.
> - *
> - *   This program 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 General Public License for more details.
> - *
> - *   You should have received a copy of the GNU General Public License
> - *   along with this program;  if not, write to the Free Software
> - *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Copyright (c) International Business Machines  Corp., 2001
> + * 	07/2001 Ported by Wayne Boyer
>    */
>   
> -/*
> - * NAME
> - *	dup202.c
> - *
> - * DESCRIPTION
> - *	Is the access mode the same for both file descriptors?
> - *		0: read only ?	"0444"
> - *		1: write only ? "0222"
> - *		2: read/write ? "0666"
> - *
> - * ALGORITHM
> - *	Creat a file with each access mode; dup each file descriptor;
> - *	stat each file descriptor and compare modes of each pair
> - *
> - * USAGE:  <for command-line>
> - *  dup202 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
> - *     where,  -c n : Run n copies concurrently.
> - *             -f   : Turn off functionality Testing.
> - *             -i n : Execute test n times.
> - *             -I x : Execute test for x seconds.
> - *             -P x : Pause for x seconds between iterations.
> - *             -t   : Turn on syscall timing.
> - *
> - * HISTORY
> - *	07/2001 Ported by Wayne Boyer
> +/*\
> + * [Description]
>    *
> - * RESTRICTIONS
> - *	None
> + * Test whether the access mode and inode number are the same for both file
> + * descriptors.
> + * Is the access mode the same for both file descriptors?
> + *	0: read only ?	"0444"
> + *	1: write only ? "0222"
> + *	2: read/write ? "0666"

Hi Qi,

Please rewrite the description as my suggestion on dup201.

>    */
>   
> -#include <sys/types.h>
> -#include <sys/stat.h>
>   #include <errno.h>
> -#include <fcntl.h>
>   #include <stdio.h>
> -#include "test.h"
> -#include "safe_macros.h"
> +#include "tst_test.h"
> +#include "tst_safe_macros.h"
>   
> -char *TCID = "dup202";
> -int TST_TOTAL = 3;
> -
> -void setup(void);
> -void cleanup(void);
> -
> -char testfile[40];
> -int fail;
> -int newfd;
> +static char testfile[40];
>   
>   /* set these to a known index into our local file descriptor table */
> -int duprdo = 10, dupwro = 20, duprdwr = 30;
> +static int duprdo = 10, dupwro = 20, duprdwr = 30;
>   
> -struct test_case_t {
> +static struct tcase {
>   	int *nfd;
>   	mode_t mode;
> -} TC[] = {
> -	/* The first test creat(es) a file with mode 0444 */
> -	{
> -	&duprdo, (S_IRUSR | S_IRGRP | S_IROTH)},
> -	    /* The second test creat(es) a file with mode 0222 */
> -	{
> -	&dupwro, (S_IWUSR | S_IWGRP | S_IWOTH)},
> -	    /* The third test creat(es) a file with mode 0666 */
> -	{
> -	&duprdwr,
> -		    (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH)}
> +} tcases[]= {
> +	{&duprdo, (S_IRUSR | S_IRGRP | S_IROTH)},
> +	{&dupwro, (S_IWUSR | S_IWGRP | S_IWOTH)},
> +	{&duprdwr, (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH)},
>   };
>   
> -int main(int ac, char **av)
> +static void setup(void)
>   {
> -	int lc;
> -	int i, ofd;
> -	struct stat oldbuf, newbuf;
> -
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -	setup();
> -
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
> -		tst_count = 0;
> -
> -		/* loop through the test cases */
> -		for (i = 0; i < TST_TOTAL; i++) {
> -
> -			if ((ofd = creat(testfile, TC[i].mode)) == -1)
> -				tst_brkm(TBROK | TERRNO, cleanup,
> -					 "creat failed");
> -
> -			TEST(dup2(ofd, *TC[i].nfd));
> -
> -			if (TEST_RETURN == -1) {
> -				tst_resm(TFAIL | TTERRNO,
> -					 "call failed unexpectedly");
> -				continue;
> -			}
> +	umask(0);
> +	sprintf(testfile, "dup202.%d", getpid());
> +}
>   
> -			/* stat the original file */
> -			SAFE_FSTAT(cleanup, ofd, &oldbuf);
> +static void run(unsigned int i)
> +{
> +	int ofd;
> +	struct stat oldbuf, newbuf;
> +	struct tcase *tc = tcases + i;
>   
> -			/* stat the duped file */
> -			SAFE_FSTAT(cleanup, *TC[i].nfd, &newbuf);
> +	ofd = SAFE_OPEN(testfile, O_CREAT, tc->mode);

It's my fault, it is clearer to use SAFE_CREAT().

>   
> -			if (oldbuf.st_mode != newbuf.st_mode)
> -				tst_resm(TFAIL, "original and dup "
> -					 "modes do not match");
> -			else
> -				tst_resm(TPASS, "fstat shows new and "
> -					 "old modes are the same");
> +	TEST(dup2(ofd, *tc->nfd));
>   
> -			/* remove the file so that we can use it again */
> -			if (close(*TC[i].nfd) == -1)
> -				perror("close failed");
> -			if (close(ofd) == -1)
> -				perror("close failed");
> -			if (unlink(testfile) == -1)
> -				perror("unlink failed");
> -		}
> +	if (TST_RET == -1) {
> +		tst_res(TFAIL | TTERRNO, "call failed unexpectedly");
If dup2() fails, SAFE_CLOSE(ofd) and SAFE_UNLINK() are needed.
> +		return;
>   	}
>   
> -	cleanup();
> -	tst_exit();
> -}
> -
> -/*
> - * setup() - performs all ONE TIME setup for this test.
> - */
> -void setup(void)
> -{
> -
> -	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> +	/* stat the original file */
> +	SAFE_FSTAT(ofd, &oldbuf);
>   
> -	TEST_PAUSE;
> +	/* stat the duped file */
> +	SAFE_FSTAT(*tc->nfd, &newbuf);
>   
> -	tst_tmpdir();
> +	if (oldbuf.st_mode != newbuf.st_mode)
> +		tst_res(TFAIL, "original and duped modes do not match");
> +	else
> +		tst_res(TPASS, "original and duped modes are the same");
>   
> -	(void)umask(0);
> +	if (oldbuf.st_ino != newbuf.st_ino)
> +		tst_res(TFAIL, "original and duped inodes do not match");
> +	else
> +		tst_res(TPASS, "original and duped inodes are the same");
>   
> -	sprintf(testfile, "dup202.%d", getpid());
> +	SAFE_CLOSE(ofd);

1) You should call SAFEC_CLOSE() for *tc->nfd here.

     Note: Please don't call SAFE_CLOSE(*tc->nfd) directly becasuse it 
will set *tc->nfd to -1.

2) You have to remove the "testfile" by SAFE_UNLINK() here.

     If not, the SAFE_OPEN()/SAFE_CREAT() will only open the existing 
"testfile" (it is created with 0444).

     By the way, I think we need to print the mode of "testfile" in each 
subtest.

Best Regards,

Xiao Yang

>   }
>   
> -/*
> - * cleanup() - performs all ONE TIME cleanup for this test at
> - *	       completion or premature exit.
> - */
> -void cleanup(void)
> -{
> -	tst_rmdir();
> -}
> +static struct tst_test test = {
> +	.needs_tmpdir = 1,
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.test = run,
> +	.setup = setup,
> +};
> diff --git a/testcases/kernel/syscalls/dup2/dup204.c b/testcases/kernel/syscalls/dup2/dup204.c
> deleted file mode 100644
> index a357bc17e..000000000
> --- a/testcases/kernel/syscalls/dup2/dup204.c
> +++ /dev/null
> @@ -1,128 +0,0 @@
> -/*
> - *
> - *   Copyright (c) International Business Machines  Corp., 2001
> - *
> - *   This program is free software;  you can redistribute it and/or modify
> - *   it under the terms of the GNU General Public License as published by
> - *   the Free Software Foundation; either version 2 of the License, or
> - *   (at your option) any later version.
> - *
> - *   This program 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 General Public License for more details.
> - *
> - *   You should have received a copy of the GNU General Public License
> - *   along with this program;  if not, write to the Free Software
> - *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> - */
> -
> -/*
> - * NAME
> - *	dup204.c
> - *
> - * DESCRIPTION
> - *	Testcase to check the basic functionality of dup2(2).
> - *
> - * ALGORITHM
> - *	attempt to call dup2() on read/write ends of a pipe
> - *
> - * USAGE:  <for command-line>
> - *  dup204 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
> - *     where,  -c n : Run n copies concurrently.
> - *             -f   : Turn off functionality Testing.
> - *             -i n : Execute test n times.
> - *             -I x : Execute test for x seconds.
> - *             -P x : Pause for x seconds between iterations.
> - *             -t   : Turn on syscall timing.
> - *
> - * RESTRICTION
> - *	NONE
> - */
> -
> -#ifndef _GNU_SOURCE
> -#define _GNU_SOURCE
> -#endif
> -#include <sys/types.h>
> -#include <fcntl.h>
> -#include <sys/stat.h>
> -#include <errno.h>
> -#include <signal.h>
> -#include <string.h>
> -#include "test.h"
> -#include "safe_macros.h"
> -
> -void setup();
> -void cleanup();
> -
> -char *TCID = "dup204";
> -int TST_TOTAL = 2;
> -
> -int fd[2];
> -int nfd[2];
> -
> -int main(int ac, char **av)
> -{
> -	int lc;
> -	int i;
> -	struct stat oldbuf, newbuf;
> -
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -	setup();
> -
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
> -		tst_count = 0;
> -
> -		/* loop through the test cases */
> -		for (i = 0; i < TST_TOTAL; i++) {
> -			TEST(dup2(fd[i], nfd[i]));
> -
> -			if (TEST_RETURN == -1) {
> -				tst_resm(TFAIL, "call failed unexpectedly");
> -				continue;
> -			}
> -
> -			SAFE_FSTAT(cleanup, fd[i], &oldbuf);
> -			SAFE_FSTAT(cleanup, nfd[i], &newbuf);
> -
> -			if (oldbuf.st_ino != newbuf.st_ino)
> -				tst_resm(TFAIL, "original and duped "
> -					 "inodes do not match");
> -			else
> -				tst_resm(TPASS, "original and duped "
> -					 "inodes are the same");
> -
> -			SAFE_CLOSE(cleanup, TEST_RETURN);
> -		}
> -	}
> -
> -	cleanup();
> -	tst_exit();
> -}
> -
> -void setup(void)
> -{
> -	fd[0] = -1;
> -
> -	tst_sig(FORK, DEF_HANDLER, cleanup);
> -
> -	TEST_PAUSE;
> -
> -	tst_tmpdir();
> -
> -	SAFE_PIPE(cleanup, fd);
> -}
> -
> -void cleanup(void)
> -{
> -	int i;
> -
> -	for (i = 0; i < (int)ARRAY_SIZE(fd); i++) {
> -		close(fd[i]);
> -		close(nfd[i]);
> -	}
> -
> -	tst_rmdir();
> -}


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v3 3/5] syscalls/dup2/dup203: Convert to new API
@ 2021-09-17  8:16         ` Xiao Yang
  0 siblings, 0 replies; 14+ messages in thread
From: Xiao Yang @ 2021-09-17  8:16 UTC (permalink / raw)
  To: QI Fuli, ltp; +Cc: QI Fuli

On 9/16/21 6:49 PM, QI Fuli wrote:
> From: QI Fuli <qi.fuli@fujitsu.com>
>
> Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
> ---
>   testcases/kernel/syscalls/dup2/dup203.c | 307 ++++++++++--------------
>   1 file changed, 121 insertions(+), 186 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/dup2/dup203.c b/testcases/kernel/syscalls/dup2/dup203.c
> index e6f281adf..86ad49dc1 100644
> --- a/testcases/kernel/syscalls/dup2/dup203.c
> +++ b/testcases/kernel/syscalls/dup2/dup203.c
> @@ -1,208 +1,143 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
>   /*
> - *
> - *   Copyright (c) International Business Machines  Corp., 2001
> - *
> - *   This program is free software;  you can redistribute it and/or modify
> - *   it under the terms of the GNU General Public License as published by
> - *   the Free Software Foundation; either version 2 of the License, or
> - *   (at your option) any later version.
> - *
> - *   This program 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 General Public License for more details.
> - *
> - *   You should have received a copy of the GNU General Public License
> - *   along with this program;  if not, write to the Free Software
> - *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * Copyright (c) International Business Machines  Corp., 2001
> + * 	07/2001 Ported by Wayne Boyer
>    */
>   
> -/*
> - * NAME
> - *	dup203.c
> - *
> - * DESCRIPTION
> +/*\
> + * [Description]
>    *	Testcase to check the basic functionality of dup2().
> - *
> - * ALGORITHM
> - *	1.	Attempt to dup2() on an open file descriptor.
> - *	2.	Attempt to dup2() on a close file descriptor.
> - *
> - * USAGE:  <for command-line>
> - *  dup203 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
> - *     where,  -c n : Run n copies concurrently.
> - *             -f   : Turn off functionality Testing.
> - *             -i n : Execute test n times.
> - *             -I x : Execute test for x seconds.
> - *             -P x : Pause for x seconds between iterations.
> - *             -t   : Turn on syscall timing.
> - *
> - * HISTORY
> - *	07/2001 Ported by Wayne Boyer
> - *
> - * RESTRICTIONS
> - *	NONE
> + *	1. Attempt to dup2() on an open file descriptor.
> + *	2. Attempt to dup2() on a close file descriptor.

Hi Qi,

Same issue.

>    */
>   
> -#include <fcntl.h>
> -#include <sys/param.h>
>   #include <errno.h>
> -#include <string.h>
> -#include "test.h"
> -#include "safe_macros.h"
> +#include <stdio.h>
> +#include "tst_test.h"
> +#include "tst_safe_macros.h"
> +
> +static int fd0, fd1, fd2;
> +static char filename0[40], filename1[40];
> +static char buf[40];
> +
> +static void verify_open(void);
> +static void verify_close(void);
> +
> +static struct tcase {
> +	char *desc;
> +	void (*verify)();
> +} tcases [] = {
> +	{"Test duping over an open fd", verify_open},
> +	{"Test close on exec flag", verify_close},
> +};
> +
> +static void verify_open(void)
> +{
> +	fd0 = SAFE_CREAT(filename0, 0666);
> +	SAFE_WRITE(1, fd0, filename0, strlen(filename0));
> +	SAFE_CLOSE(fd0);
>   
> -void setup(void);
> -void cleanup(void);
> +	fd1 = SAFE_CREAT(filename1, 0666);
> +	SAFE_WRITE(1, fd1, filename1, strlen(filename1));
> +	SAFE_CLOSE(fd1);
>   
> -char *TCID = "dup203";
> -int TST_TOTAL = 1;
> +	fd0 = SAFE_OPEN(filename0, O_RDONLY);
> +	fd1 = SAFE_OPEN(filename1, O_RDONLY);
>   
> -int main(int ac, char **av)
> -{
> -	int fd0, fd1, fd2, rval;
> -	char filename0[40], filename1[40];
> -	char buf[40];
> -
> -	int lc;
> -
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -	setup();
> -
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
> -		tst_count = 0;
> -//block1:
> -		tst_resm(TINFO, "Enter block 1");
> -		tst_resm(TINFO, "Test duping over an open fd");
> -
> -		sprintf(filename0, "dup202.file0.%d\n", getpid());
> -		sprintf(filename1, "dup202.file1.%d\n", getpid());
> -		unlink(filename0);
> -		unlink(filename1);
> -
> -		if ((fd0 = creat(filename0, 0666)) == -1)
> -			tst_brkm(TBROK, cleanup, "cannot create first file");
> -		if (write(fd0, filename0, strlen(filename0)) == -1)
> -			tst_brkm(TBROK, cleanup, "filename0: write(2) failed");
> -
> -		if ((fd1 = creat(filename1, 0666)) == -1)
> -			tst_brkm(TBROK, cleanup, "Cannot create second file");
> -		if (write(fd1, filename1, strlen(filename1)) == -1)
> -			tst_brkm(TBROK, cleanup, "filename1: write(2) failed");
> -
> -		SAFE_CLOSE(cleanup, fd0);
> -		if ((fd0 = open(filename0, O_RDONLY)) == -1)
> -			tst_brkm(TBROK, cleanup, "open(2) on filename0 failed");
> -
> -		SAFE_CLOSE(cleanup, fd1);
> -		if ((fd1 = open(filename1, O_RDONLY)) == -1)
> -			tst_brkm(TBROK, cleanup, "open(2) on filename1 failed");
> -
> -		TEST(dup2(fd0, fd1));
> -
> -		if ((fd2 = TEST_RETURN) == -1) {
> -			tst_resm(TFAIL, "call failed unexpectedly");
> -		} else {
> -			if (fd1 != fd2) {
> -				tst_resm(TFAIL, "file descriptors don't match");
> -				break;
> -			}
> -
> -			memset(buf, 0, sizeof(buf));
> -			if (read(fd2, buf, sizeof(buf)) == -1)
> -				tst_brkm(TBROK, cleanup, "read(2) failed");
> -			if (strcmp(buf, filename0) != 0)
> -				tst_resm(TFAIL, "read from file got bad data");
> -			tst_resm(TPASS, "dup2 test 1 functionality is correct");
> -		}
> -
> -		close(fd0);
> -		close(fd1);
> -		close(fd2);
> -		unlink(filename0);
> -		unlink(filename1);
> -
> -		tst_resm(TINFO, "Exit block 1");
> -
> -//block2:
> -		tst_resm(TINFO, "Enter block 2");
> -		tst_resm(TINFO, "Test close on exec flag");
> -
> -		sprintf(filename0, "dup02.%d\n", getpid());
> -		unlink(filename0);
> -
> -		if ((fd0 = creat(filename0, 0666)) == -1) {
> -			tst_brkm(TBROK, cleanup, "Cannot create first file");
> -		}
> -		if (fcntl(fd0, F_SETFD, 1) == -1) {
> -			tst_brkm(TBROK, cleanup, "setting close on exec flag "
> -				 "on fd0 failed");
> -		}
> -
> -		if ((fd2 = creat(filename1, 0666)) == -1) {
> -			tst_brkm(TBROK, cleanup, "Cannot create second file");
> -		}
> -
> -		/* SAFE_CLOSE() sets the fd to -1 avoid it here */
> -		rval = fd2;
> -		SAFE_CLOSE(cleanup, rval);
> -
> -		TEST(dup2(fd0, fd2));
> -
> -		if ((fd1 = TEST_RETURN) == -1) {
> -			tst_resm(TFAIL, "call failed unexpectedly");
> -		} else {
> -			if (fd1 != fd2) {
> -				tst_resm(TFAIL, "bad dup2 descriptor %d", fd1);
> -				break;
> -			}
> -
> -			if ((rval = fcntl(fd1, F_GETFD, 0)) != 0) {
> -				tst_resm(TBROK | TERRNO,
> -					 "fcntl F_GETFD on fd1 failed; expected a "
> -					 "return value of 0x0, got %#x", rval);
> -				break;
> -			}
> -			if ((rval = (fcntl(fd0, F_GETFL, 0) & O_ACCMODE)) !=
> -			    O_WRONLY) {
> -				tst_resm(TFAIL, "fctnl F_GETFL bad rval on fd0 "
> -					 "Expected %#x got %#x", O_WRONLY,
> -					 rval);
> -			}
> -			tst_resm(TPASS, "dup2 test 2 functionality is correct");
> -		}
> -
> -		close(fd0);
> -		close(fd1);
> -
> -		unlink(filename0);
> -		unlink(filename1);
> -		tst_resm(TINFO, "Exit block 2");
> +	TEST(dup2(fd0, fd1));
> +
> +	fd2 = TST_RET;
> +	if (TST_RET == -1) {
> +		tst_res(TFAIL, "call failed unexpectedly");
> +		goto free;
>   	}
>   
> -	cleanup();
> -	tst_exit();
> +	if (fd1 != fd2) {
> +		tst_res(TFAIL, "file descriptors don't match");
> +		goto free;
> +	}
> +
> +	memset(buf, 0, sizeof(buf));
> +	SAFE_READ(0, fd2, buf, sizeof(buf));
> +	if (strcmp(buf, filename0) != 0)
> +		tst_res(TFAIL, "read from file got bad data");
> +	else
> +		tst_res(TPASS, "dup2 test 1 functionality is correct");
> +
> +free:
> +	SAFE_CLOSE(fd0);
> +	SAFE_CLOSE(fd1);
> +	SAFE_UNLINK(filename0);
> +	SAFE_UNLINK(filename1);
>   }
>   
> -/*
> - * setup() - performs all ONE TIME setup for this test.
> - */
> -void setup(void)
> +static void verify_close(void)
>   {
> +	int rval, rc = 0;
> +
> +	sprintf(filename0, "dup203.%d\n", getpid());
> +	unlink(filename0);
Please remove these redundant lines.
> +
> +	fd0 = SAFE_CREAT(filename0, 0666);
> +	SAFE_FCNTL(fd0, F_SETFD, 1);
> +
> +	fd2 = SAFE_CREAT(filename1, 0666);
>   
> -	tst_sig(NOFORK, DEF_HANDLER, cleanup);
> +	/* SAFE_CLOSE() sets the fd to -1 avoid it here */
> +	rval = fd2;
> +	SAFE_CLOSE(rval);
>   
> -	TEST_PAUSE;
> +	TEST(dup2(fd0, fd2));
>   
> -	tst_tmpdir();
> +	fd1 = TST_RET;
> +	if (TST_RET == -1) {
> +		tst_res(TFAIL, "call failed unexpectedly");
> +		goto free;
> +	}
> +
> +	if (fd1 != fd2) {
> +		tst_res(TFAIL, "bad dup2 descriptor %d", fd1);
> +		goto free;
> +	}
> +
> +	rval = SAFE_FCNTL(fd1, F_GETFD, 0);
> +	if (rval != 0) {
> +		tst_res(TFAIL, "fcntl F_GETFD on fd1 failed; expected a "
> +			"return value of 0x0, got %#x", rval);
> +		rc++;
> +	}

I think both verify_open() and verify_close() should verify two points:

1) check the content of file.

2) check the FD_CLOEXEC flag.

By the way, could you use a common function with different arguments? I 
think there are a lot of redundant code.

Best Regards,

Xiao Yang

> +
> +	if (!rc)
> +		tst_res(TPASS, "dup2 test 2 functionality is correct");
> +
> +free:
> +	SAFE_CLOSE(fd0);
> +	SAFE_CLOSE(fd1);
> +	SAFE_UNLINK(filename0);
> +	SAFE_UNLINK(filename1);
>   }
>   
> -/*
> - * cleanup() - performs all ONE TIME cleanup for this test at
> - *	       completion or premature exit.
> - */
> -void cleanup(void)
> +static void run(unsigned int i)
>   {
> -	tst_rmdir();
> +	struct tcase *tc = tcases + i;
> +
> +	tst_res(TINFO, tc->desc);
> +	tc->verify();
> +
> +}
> +
> +static void setup(void)
> +{
> +	int pid;
> +
> +	pid = getpid();
> +	sprintf(filename0, "dup203.file0.%d\n", pid);
> +	sprintf(filename1, "dup203.file1.%d\n", pid);
>   }
> +
> +static struct tst_test test = {
> +	.setup = setup,
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.needs_tmpdir = 1,
> +	.test = run,
> +};


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v3 4/5] syscalls/dup2/dup205: Convert to new API
@ 2021-09-17  8:37         ` Xiao Yang
  2021-09-17  9:20             ` qi.fuli
  0 siblings, 1 reply; 14+ messages in thread
From: Xiao Yang @ 2021-09-17  8:37 UTC (permalink / raw)
  To: QI Fuli, ltp; +Cc: QI Fuli

On 9/16/21 6:49 PM, QI Fuli wrote:
> From: QI Fuli <qi.fuli@fujitsu.com>
>
> Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
> ---
>   testcases/kernel/syscalls/dup2/dup205.c | 166 ++++++++----------------
>   1 file changed, 54 insertions(+), 112 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/dup2/dup205.c b/testcases/kernel/syscalls/dup2/dup205.c
> index 0b324531f..0e2766d53 100644
> --- a/testcases/kernel/syscalls/dup2/dup205.c
> +++ b/testcases/kernel/syscalls/dup2/dup205.c
> @@ -1,134 +1,76 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
>   /*
> + * Copyright (c) International Business Machines  Corp., 2002
>    *
> - *   Copyright (c) International Business Machines  Corp., 2002
> - *
> - *   This program is free software;  you can redistribute it and/or modify
> - *   it under the terms of the GNU General Public License as published by
> - *   the Free Software Foundation; either version 2 of the License, or
> - *   (at your option) any later version.
> + */
> +
> +/*\
> + * [Description]
>    *
> - *   This program 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 General Public License for more details.
> + * Negative test for dup2() with max open file descriptors.
>    *
> - *   You should have received a copy of the GNU General Public License
> - *   along with this program;  if not, write to the Free Software
> - *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>    */
>   
>   /* Ported from SPIE, section2/iosuite/dup6.c, by Airong Zhang */
>   
> -/*======================================================================
> -	=================== TESTPLAN SEGMENT ===================
> ->KEYS:  < dup2()
> ->WHAT:  < Does dup return -1 on the 21st file?
> ->HOW:   < Create up to _NFILE files and check for -1 return on the
> -	< next attempt
> -	< Should check NOFILE as well as _NFILE.  19-Jun-84 Dale.
> ->BUGS:  <
> -======================================================================*/
> -
> -#include <sys/param.h>
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -#include <errno.h>
> -#include <fcntl.h>
> +#include <stdlib.h>
>   #include <stdio.h>
>   #include <unistd.h>
> -#include "test.h"
> -
> -char *TCID = "dup205";
> -int TST_TOTAL = 1;
> -int *fildes;
> -int min;
> -int local_flag;
> -
> -#define PASSED 1
> -#define FAILED 0
> -
> -static void setup(void);
> -static void cleanup(void);
> -
> -int main(int ac, char *av[])
> -{
> -	int ifile;
> -	char pfilname[40];
> -	int serrno;
> -
> -	int lc;
> -
> -	ifile = -1;
> -
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -	local_flag = PASSED;
> +#include "tst_test.h"
> +#include "tst_safe_macros.h"
>   
> -	setup();
> -
> -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
> -		sprintf(pfilname, "./dup205.%d\n", getpid());
> -		unlink(pfilname);
> -		serrno = 0;
> -		if ((fildes[0] = creat(pfilname, 0666)) == -1)
> -			tst_brkm(TBROK | TERRNO, cleanup, "creat failed");
> -		else {
> -			fildes[fildes[0]] = fildes[0];
> -			for (ifile = fildes[0] + 1; ifile < min + 10; ifile++) {
> -				if ((fildes[ifile] = dup2(fildes[ifile - 1],
> -							  ifile)) == -1) {
> -					serrno = errno;
> -					break;
> -				} else {
> -					if (fildes[ifile] != ifile) {
> -						tst_brkm(TFAIL, cleanup,
> -							 "got wrong descriptor "
> -							 "number back (%d != %d)",
> -							 fildes[ifile], ifile);
> -					}
> -				}
> -			}	/* end for */
> -			if (ifile < min) {
> -				tst_resm(TFAIL, "Not enough files duped");
> -				local_flag = FAILED;
> -			} else if (ifile > min) {
> -				tst_resm(TFAIL, "Too many files duped");
> -				local_flag = FAILED;
> -			}
> -			if (serrno != EBADF && serrno != EMFILE &&
> -			    serrno != EINVAL) {
> -				tst_resm(TFAIL, "bad errno on dup2 failure");
> -				local_flag = FAILED;
> -			}
> -		}
> -		unlink(pfilname);
> -		for (ifile = fildes[0]; ifile < min + 10; ifile++)
> -			close(fildes[ifile]);
> -		if (local_flag == PASSED) {
> -			tst_resm(TPASS, "Test passed.");
> -		} else {
> -			tst_resm(TFAIL, "Test failed.");
> -		}
> -
> -	}
> -	cleanup();
> -	tst_exit();
> -}
> +static int *fildes;
> +static int min;
> +static char pfilname[40];
>   
>   static void setup(void)
>   {
> -	tst_tmpdir();
> -
>   	min = getdtablesize();	/* get number of files allowed open */
> -	fildes = malloc((min + 10) * sizeof(int));
> -	if (fildes == NULL)
> -		tst_brkm(TBROK | TERRNO, cleanup, "malloc error");
> +	fildes = SAFE_MALLOC((min + 10) * sizeof(int));
> +
> +	sprintf(pfilname, "./dup205.%d\n", getpid());
>   }
>   
>   static void cleanup(void)
>   {
>   	if (fildes != NULL)
>   		free(fildes);
> -	tst_rmdir();
>   }
> +
> +static void run(void)
> +{
> +	int ifile;
> +
> +	ifile = -1;
> +
> +	fildes[0] = SAFE_CREAT(pfilname, 0666);
> +	fildes[fildes[0]] = fildes[0];
> +	for (ifile = fildes[0] + 1; ifile < min + 10; ifile++) {
> +		TEST(dup2(fildes[ifile - 1], ifile));
> +		if ((fildes[ifile] = TST_RET) == -1)
> +			break;
> +		if (fildes[ifile] != ifile)
> +			tst_brk(TFAIL, "got wrong descriptor number back "
> +				"(%d != %d)", fildes[ifile], ifile);
> +	}	/* end for */
> +
> +	if (TST_ERR != EBADF)
> +		tst_res(TFAIL, "bad errno on dup2 failure");

Hi Qi,

Why do you only check EBADF? The old test checks three errno.

> +
> +	if (ifile < min)
> +		tst_res(TFAIL, "Not enough files duped");
> +	else if (ifile > min)
> +		tst_res(TFAIL, "Too many files duped");
> +	else
> +		tst_res(TPASS, "Test passed.");
> +
> +	SAFE_CLOSE(fildes[0]);

Why do you close only fildes[0]?

Best Regards,

Xiao Yang

> +	SAFE_UNLINK(pfilname);
> +}
> +
> +static struct tst_test test = {
> +	.needs_tmpdir = 1,
> +	.test_all = run,
> +	.setup = setup,
> +	.cleanup = cleanup,
> +};


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v3 4/5] syscalls/dup2/dup205: Convert to new API
@ 2021-09-17  9:20             ` qi.fuli
  2021-09-17  9:59                 ` xuyang2018.jy
  0 siblings, 1 reply; 14+ messages in thread
From: qi.fuli @ 2021-09-17  9:20 UTC (permalink / raw)
  To: 'Xiao Yang', QI Fuli, ltp, xuyang2018.jy

> Subject: Re: [LTP] [PATCH v3 4/5] syscalls/dup2/dup205: Convert to new API
> 
> On 9/16/21 6:49 PM, QI Fuli wrote:
> > From: QI Fuli <qi.fuli@fujitsu.com>
> >
> > Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
> > ---
> >   testcases/kernel/syscalls/dup2/dup205.c | 166
> ++++++++----------------
> >   1 file changed, 54 insertions(+), 112 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/dup2/dup205.c
> b/testcases/kernel/syscalls/dup2/dup205.c
> > index 0b324531f..0e2766d53 100644
> > --- a/testcases/kernel/syscalls/dup2/dup205.c
> > +++ b/testcases/kernel/syscalls/dup2/dup205.c
> > @@ -1,134 +1,76 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> >   /*
> > + * Copyright (c) International Business Machines  Corp., 2002
> >    *
> > - *   Copyright (c) International Business Machines  Corp., 2002
> > - *
> > - *   This program is free software;  you can redistribute it and/or modify
> > - *   it under the terms of the GNU General Public License as published by
> > - *   the Free Software Foundation; either version 2 of the License, or
> > - *   (at your option) any later version.
> > + */
> > +
> > +/*\
> > + * [Description]
> >    *
> > - *   This program 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 General Public License for more details.
> > + * Negative test for dup2() with max open file descriptors.
> >    *
> > - *   You should have received a copy of the GNU General Public License
> > - *   along with this program;  if not, write to the Free Software
> > - *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> >    */
> >
> >   /* Ported from SPIE, section2/iosuite/dup6.c, by Airong Zhang */
> >
> >
> -/*=================================================
> =====================
> > -	=================== TESTPLAN SEGMENT
> ===================
> > ->KEYS:  < dup2()
> > ->WHAT:  < Does dup return -1 on the 21st file?
> > ->HOW:   < Create up to _NFILE files and check for -1 return on the
> > -	< next attempt
> > -	< Should check NOFILE as well as _NFILE.  19-Jun-84 Dale.
> > ->BUGS:  <
> >
> -==================================================
> ====================*/
> > -
> > -#include <sys/param.h>
> > -#include <sys/types.h>
> > -#include <sys/stat.h>
> > -#include <errno.h>
> > -#include <fcntl.h>
> > +#include <stdlib.h>
> >   #include <stdio.h>
> >   #include <unistd.h>
> > -#include "test.h"
> > -
> > -char *TCID = "dup205";
> > -int TST_TOTAL = 1;
> > -int *fildes;
> > -int min;
> > -int local_flag;
> > -
> > -#define PASSED 1
> > -#define FAILED 0
> > -
> > -static void setup(void);
> > -static void cleanup(void);
> > -
> > -int main(int ac, char *av[])
> > -{
> > -	int ifile;
> > -	char pfilname[40];
> > -	int serrno;
> > -
> > -	int lc;
> > -
> > -	ifile = -1;
> > -
> > -	tst_parse_opts(ac, av, NULL, NULL);
> > -
> > -	local_flag = PASSED;
> > +#include "tst_test.h"
> > +#include "tst_safe_macros.h"
> >
> > -	setup();
> > -
> > -	for (lc = 0; TEST_LOOPING(lc); lc++) {
> > -
> > -		sprintf(pfilname, "./dup205.%d\n", getpid());
> > -		unlink(pfilname);
> > -		serrno = 0;
> > -		if ((fildes[0] = creat(pfilname, 0666)) == -1)
> > -			tst_brkm(TBROK | TERRNO, cleanup, "creat failed");
> > -		else {
> > -			fildes[fildes[0]] = fildes[0];
> > -			for (ifile = fildes[0] + 1; ifile < min + 10; ifile++) {
> > -				if ((fildes[ifile] = dup2(fildes[ifile - 1],
> > -							  ifile)) == -1) {
> > -					serrno = errno;
> > -					break;
> > -				} else {
> > -					if (fildes[ifile] != ifile) {
> > -						tst_brkm(TFAIL, cleanup,
> > -							 "got wrong
> descriptor "
> > -							 "number back
> (%d != %d)",
> > -							 fildes[ifile], ifile);
> > -					}
> > -				}
> > -			}	/* end for */
> > -			if (ifile < min) {
> > -				tst_resm(TFAIL, "Not enough files duped");
> > -				local_flag = FAILED;
> > -			} else if (ifile > min) {
> > -				tst_resm(TFAIL, "Too many files duped");
> > -				local_flag = FAILED;
> > -			}
> > -			if (serrno != EBADF && serrno != EMFILE &&
> > -			    serrno != EINVAL) {
> > -				tst_resm(TFAIL, "bad errno on dup2 failure");
> > -				local_flag = FAILED;
> > -			}
> > -		}
> > -		unlink(pfilname);
> > -		for (ifile = fildes[0]; ifile < min + 10; ifile++)
> > -			close(fildes[ifile]);
> > -		if (local_flag == PASSED) {
> > -			tst_resm(TPASS, "Test passed.");
> > -		} else {
> > -			tst_resm(TFAIL, "Test failed.");
> > -		}
> > -
> > -	}
> > -	cleanup();
> > -	tst_exit();
> > -}
> > +static int *fildes;
> > +static int min;
> > +static char pfilname[40];
> >
> >   static void setup(void)
> >   {
> > -	tst_tmpdir();
> > -
> >   	min = getdtablesize();	/* get number of files allowed open */
> > -	fildes = malloc((min + 10) * sizeof(int));
> > -	if (fildes == NULL)
> > -		tst_brkm(TBROK | TERRNO, cleanup, "malloc error");
> > +	fildes = SAFE_MALLOC((min + 10) * sizeof(int));
> > +
> > +	sprintf(pfilname, "./dup205.%d\n", getpid());
> >   }
> >
> >   static void cleanup(void)
> >   {
> >   	if (fildes != NULL)
> >   		free(fildes);
> > -	tst_rmdir();
> >   }
> > +
> > +static void run(void)
> > +{
> > +	int ifile;
> > +
> > +	ifile = -1;
> > +
> > +	fildes[0] = SAFE_CREAT(pfilname, 0666);
> > +	fildes[fildes[0]] = fildes[0];
> > +	for (ifile = fildes[0] + 1; ifile < min + 10; ifile++) {
> > +		TEST(dup2(fildes[ifile - 1], ifile));
> > +		if ((fildes[ifile] = TST_RET) == -1)
> > +			break;
> > +		if (fildes[ifile] != ifile)
> > +			tst_brk(TFAIL, "got wrong descriptor number back "
> > +				"(%d != %d)", fildes[ifile], ifile);
> > +	}	/* end for */
> > +
> > +	if (TST_ERR != EBADF)
> > +		tst_res(TFAIL, "bad errno on dup2 failure");
> 
> Hi Qi,
> 
> Why do you only check EBADF? The old test checks three errno.

Thanks for the comments.
Both Xu and I got the failures with EBADF,
so I think that checking EINVAL and ENFILE is not necessary.
I wonder your opinion.
> 
> > +
> > +	if (ifile < min)
> > +		tst_res(TFAIL, "Not enough files duped");
> > +	else if (ifile > min)
> > +		tst_res(TFAIL, "Too many files duped");
> > +	else
> > +		tst_res(TPASS, "Test passed.");
> > +
> > +	SAFE_CLOSE(fildes[0]);
> 
> Why do you close only fildes[0]?

I did try close all fildes[ifile], and it occurred close(-1).
After talking with Xu, we think that close oldfd is enough.

Best,
QI

> 
> Best Regards,
> 
> Xiao Yang
> 
> > +	SAFE_UNLINK(pfilname);
> > +}
> > +
> > +static struct tst_test test = {
> > +	.needs_tmpdir = 1,
> > +	.test_all = run,
> > +	.setup = setup,
> > +	.cleanup = cleanup,
> > +};


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v3 4/5] syscalls/dup2/dup205: Convert to new API
@ 2021-09-17  9:59                 ` xuyang2018.jy
  0 siblings, 0 replies; 14+ messages in thread
From: xuyang2018.jy @ 2021-09-17  9:59 UTC (permalink / raw)
  To: qi.fuli; +Cc: ltp

Hi All
>> Subject: Re: [LTP] [PATCH v3 4/5] syscalls/dup2/dup205: Convert to new API

>>> +
>>> +	if (TST_ERR != EBADF)
>>> +		tst_res(TFAIL, "bad errno on dup2 failure");
>>
>> Hi Qi,
>>
>> Why do you only check EBADF? The old test checks three errno.
>
> Thanks for the comments.
> Both Xu and I got the failures with EBADF,
> so I think that checking EINVAL and ENFILE is not necessary.
Yes, My machine fails with EBADF.
Look this case history, it said nothing about why need three checks.
But kernel code in 4e1e018ecc6f ("PATCH] fix RLIM_NOFILE handling
") ,

it seems old kernel will return EINVAL when rlimit set to 0.
Then will return ENFILE when rlimit set to 0.


And now it looks only fails with EBADF from kernel fs/file.c code.

> I wonder your opinion.
>>
>>> +
>>> +	if (ifile<  min)
>>> +		tst_res(TFAIL, "Not enough files duped");
>>> +	else if (ifile>  min)
>>> +		tst_res(TFAIL, "Too many files duped");
>>> +	else
>>> +		tst_res(TPASS, "Test passed.");
>>> +
>>> +	SAFE_CLOSE(fildes[0]);
>>
>> Why do you close only fildes[0]?
>
> I did try close all fildes[ifile], and it occurred close(-1).
> After talking with Xu, we think that close oldfd is enough.
I think we don't need to close all filedes because dup2 can close newfd
before reuse.  We should close them in cleanup function.

Best Regards
Yang Xu
>
> Best,
> QI
>
>>
>> Best Regards,
>>
>> Xiao Yang
>>
>>> +	SAFE_UNLINK(pfilname);
>>> +}
>>> +
>>> +static struct tst_test test = {
>>> +	.needs_tmpdir = 1,
>>> +	.test_all = run,
>>> +	.setup = setup,
>>> +	.cleanup = cleanup,
>>> +};
>

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-09-17  9:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 10:49 [LTP] [PATCH v3 0/5] Convert syscalls/dup2/dup2{01...05} to new API QI Fuli
2021-09-16 10:49 ` QI Fuli
2021-09-16 10:49   ` [LTP] [PATCH v3 1/5] syscalls/dup2/dup201: Convert " QI Fuli
2021-09-16 10:49     ` QI Fuli
2021-09-17  7:04       ` Xiao Yang
2021-09-17  7:04         ` Xiao Yang
2021-09-16 10:49   ` [LTP] [PATCH v3 2/5] syscalls/dup2/dup202: Convert to new API and merge dup204 into dup202 QI Fuli
2021-09-16 10:49     ` QI Fuli
2021-09-17  7:27       ` Xiao Yang
2021-09-17  7:27         ` Xiao Yang
2021-09-16 10:49   ` [LTP] [PATCH v3 3/5] syscalls/dup2/dup203: Convert to new API QI Fuli
2021-09-16 10:49     ` QI Fuli
2021-09-17  8:16       ` Xiao Yang
2021-09-17  8:16         ` Xiao Yang
2021-09-16 10:49   ` [LTP] [PATCH v3 4/5] syscalls/dup2/dup205: " QI Fuli
2021-09-16 10:49     ` QI Fuli
2021-09-17  8:37       ` Xiao Yang
2021-09-17  8:37         ` Xiao Yang
2021-09-17  9:20           ` qi.fuli
2021-09-17  9:20             ` qi.fuli
2021-09-17  9:59               ` xuyang2018.jy
2021-09-17  9:59                 ` xuyang2018.jy
2021-09-16 10:49   ` [LTP] [PATCH v3 5/5] syscalls/dup2: rename dup205 to dup204 QI Fuli
2021-09-16 10:49     ` QI Fuli
2021-09-17  3:20       ` xuyang2018.jy
2021-09-17  3:20         ` xuyang2018.jy
2021-09-17  4:29           ` qi.fuli
2021-09-17  4:29             ` qi.fuli

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.