Skip to contentSkip to conversation

fcntl30.c: Convert the test to new LTP API

PATCH Superseded Avinesh Kumar 2 participants 8 messages Jun 1, 2023 – Jun 5, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fcntl30.c: Convert the test to new LTP API

---
 testcases/kernel/syscalls/fcntl/fcntl30.c | 112 +++++++---------------
 1 file changed, 36 insertions(+), 76 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl30.c +36 -76
index c4c3f81f1..62cc39e73 100644
@@ -1,103 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Fujitsu Ltd.
  * Author: Xiaoguang Wang <[email protected]>
- *
- * 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.
- *
- * 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.
+ * Copyright (c) 2023 SUSE LLC Avinesh Kumar <[email protected]>
  */
 
-/*
- * Description:
- * Verify that,
- *     Basic test for fcntl(2) using F_SETPIPE_SZ, F_GETPIPE_SZ argument.
+/*\
+ * [Description]
+ *
+ * Verify that, fetching and changing the capacity of a pipe works as
+ * expected with fcntl(2) syscall using F_GETPIPE_SZ, F_SETPIPE_SZ arguments.
  */
 
 
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <pwd.h>
-
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/fcntl.h"
 
-char *TCID = "fcntl30";
-int TST_TOTAL = 1;
+static int fds[2];
+static int max_size_unpriv;
 
-static void setup(void);
-static void cleanup(void);
-
-int main(int ac, char **av)
+static void run(void)
 {
-	int lc;
-	int pipe_fds[2], test_fd;
-	int orig_pipe_size, new_pipe_size;
-
-
-	tst_parse_opts(ac, av, NULL, NULL);
+	int orig_size, new_size;
 
-	setup();
+	SAFE_PIPE(fds);
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
+	TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
 
-		SAFE_PIPE(cleanup, pipe_fds);
-		test_fd = pipe_fds[1];
+	orig_size = TST_RET;
+	new_size = orig_size * 2;
 
-		TEST(fcntl(test_fd, F_GETPIPE_SZ));
-		if (TEST_RETURN < 0) {
-			tst_brkm(TFAIL | TTERRNO, cleanup,
-				 "fcntl get pipe size failed");
-		}
+	if (new_size > max_size_unpriv)
+		tst_brk(TBROK, "Requested pipe size above the allowed limit %d", max_size_unpriv);
 
-		orig_pipe_size = TEST_RETURN;
-		new_pipe_size = orig_pipe_size * 2;
-		TEST(fcntl(test_fd, F_SETPIPE_SZ, new_pipe_size));
-		if (TEST_RETURN < 0) {
-			tst_brkm(TFAIL | TTERRNO, cleanup,
-				 "fcntl test F_SETPIPE_SZ failed");
-		}
+	TST_EXP_POSITIVE(fcntl(fds[1], F_SETPIPE_SZ, new_size));
+	TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
+	TST_EXP_EXPR(TST_RET >= new_size,
+				"new pipe size (%ld) >= requested size (%d)",
+				TST_RET, new_size);
 
-		TEST(fcntl(test_fd, F_GETPIPE_SZ));
-		if (TEST_RETURN < 0) {
-			tst_brkm(TFAIL | TTERRNO, cleanup,
-				 "fcntl test F_GETPIPE_SZ failed");
-		}
-		tst_resm(TINFO, "orig_pipe_size: %d new_pipe_size: %d",
-			 orig_pipe_size, new_pipe_size);
-		if (TEST_RETURN >= new_pipe_size) {
-			tst_resm(TPASS, "fcntl test F_GETPIPE_SZ and F_SETPIPE_SZ passed");
-		} else {
-			tst_resm(TFAIL, "fcntl test F_GETPIPE_SZ and F_SETPIPE_SZ failed");
-		}
-		SAFE_CLOSE(cleanup, pipe_fds[0]);
-		SAFE_CLOSE(cleanup, pipe_fds[1]);
-	}
-
-	cleanup();
-	tst_exit();
+	SAFE_CLOSE(fds[0]);
+	SAFE_CLOSE(fds[1]);
 }
 
 static void setup(void)
 {
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
+	SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d",	&max_size_unpriv);
 }
 
 static void cleanup(void)
 {
+	if (fds[0] > 0)
+		SAFE_CLOSE(fds[0]);
+	if (fds[1] > 0)
+		SAFE_CLOSE(fds[1]);
 }
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup
+};
Signature · 5 lines
2.40.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#1 lore raw
Quoted 94 lines · Avinesh Kumar
---
 testcases/kernel/syscalls/fcntl/fcntl30.c | 112 +++++++---------------
 1 file changed, 36 insertions(+), 76 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl30.c +7 -16
index c4c3f81f1..62cc39e73 100644
@@ -1,103 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Fujitsu Ltd.
  * Author: Xiaoguang Wang <[email protected]>
- *
- * 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.
- *
- * 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.
+ * Copyright (c) 2023 SUSE LLC Avinesh Kumar <[email protected]>
  */
 
-/*
- * Description:
- * Verify that,
- *     Basic test for fcntl(2) using F_SETPIPE_SZ, F_GETPIPE_SZ argument.
+/*\
+ * [Description]
+ *
+ * Verify that, fetching and changing the capacity of a pipe works as
+ * expected with fcntl(2) syscall using F_GETPIPE_SZ, F_SETPIPE_SZ

arguments.
*/

testcases/kernel/syscalls/fcntl/fcntl30.c +11 -32
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <pwd.h>
-
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/fcntl.h"
 
-char *TCID = "fcntl30";
-int TST_TOTAL = 1;
+static int fds[2];
+static int max_size_unpriv;
 
-static void setup(void);
-static void cleanup(void);
-
-int main(int ac, char **av)
+static void run(void)
 {
-       int lc;
-       int pipe_fds[2], test_fd;
-       int orig_pipe_size, new_pipe_size;
-
-
-       tst_parse_opts(ac, av, NULL, NULL);
+       int orig_size, new_size;
 
-       setup();
+       SAFE_PIPE(fds);
 
-       for (lc = 0; TEST_LOOPING(lc); lc++) {
-               tst_count = 0;
+       TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
 
-               SAFE_PIPE(cleanup, pipe_fds);
-               test_fd = pipe_fds[1];
+       orig_size = TST_RET;
+       new_size = orig_size * 2;
 
-               TEST(fcntl(test_fd, F_GETPIPE_SZ));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl get pipe size failed");
-               }
+       if (new_size > max_size_unpriv)
+               tst_brk(TBROK, "Requested pipe size above the allowed
Quoted 2 lines

limit %d", max_size_unpriv);

It is possible that the pipe-max-size value was set to a smaller size so that the test gets failure here. But it would not be a problem.

I guess TCONF should be more proper.

Otherwise, LGTM.

Quoted 69 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +4 -7
-               orig_pipe_size = TEST_RETURN;
-               new_pipe_size = orig_pipe_size * 2;
-               TEST(fcntl(test_fd, F_SETPIPE_SZ, new_pipe_size));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl test F_SETPIPE_SZ failed");
-               }
+       TST_EXP_POSITIVE(fcntl(fds[1], F_SETPIPE_SZ, new_size));
+       TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
+       TST_EXP_EXPR(TST_RET >= new_size,
+                               "new pipe size (%ld) >= requested size

(%d)",

testcases/kernel/syscalls/fcntl/fcntl30.c +1 -9
+                               TST_RET, new_size);
 
-               TEST(fcntl(test_fd, F_GETPIPE_SZ));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl test F_GETPIPE_SZ failed");
-               }
-               tst_resm(TINFO, "orig_pipe_size: %d new_pipe_size: %d",
-                        orig_pipe_size, new_pipe_size);
-               if (TEST_RETURN >= new_pipe_size) {
-                       tst_resm(TPASS, "fcntl test F_GETPIPE_SZ and

F_SETPIPE_SZ passed");

testcases/kernel/syscalls/fcntl/fcntl30.c +0 -2
-               } else {
-                       tst_resm(TFAIL, "fcntl test F_GETPIPE_SZ and

F_SETPIPE_SZ failed");

testcases/kernel/syscalls/fcntl/fcntl30.c +13 -11
-               }
-               SAFE_CLOSE(cleanup, pipe_fds[0]);
-               SAFE_CLOSE(cleanup, pipe_fds[1]);
-       }
-
-       cleanup();
-       tst_exit();
+       SAFE_CLOSE(fds[0]);
+       SAFE_CLOSE(fds[1]);
 }
 
 static void setup(void)
 {
-       tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-       TEST_PAUSE;
+       SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d",
 &max_size_unpriv);
 }
 
 static void cleanup(void)
 {
+       if (fds[0] > 0)
+               SAFE_CLOSE(fds[0]);
+       if (fds[1] > 0)
+               SAFE_CLOSE(fds[1]);
 }
+
+static struct tst_test test = {
+       .test_all = run,
+       .setup = setup,
+       .cleanup = cleanup
+};
--

2.40.1

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

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Li,

Quoted 98 lines · IST Li Wang
Quoted 97 lines · Avinesh Kumar

---

 testcases/kernel/syscalls/fcntl/fcntl30.c | 112 +++++++---------------
 1 file changed, 36 insertions(+), 76 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl30.c +1 -2
index c4c3f81f1..62cc39e73 100644
@@ -1,103 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0
 
 /*
 
  * Copyright (c) 2014 Fujitsu Ltd.
  * Author: Xiaoguang Wang <[email protected]>
 
- *
- * 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.
- *
- * 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.
+ * Copyright (c) 2023 SUSE LLC Avinesh Kumar <[email protected]>

*/

testcases/kernel/syscalls/fcntl/fcntl30.c +5 -4
-/*
- * Description:
- * Verify that,
- *     Basic test for fcntl(2) using F_SETPIPE_SZ, F_GETPIPE_SZ argument.
+/*\
+ * [Description]
+ *
+ * Verify that, fetching and changing the capacity of a pipe works as
+ * expected with fcntl(2) syscall using F_GETPIPE_SZ, F_SETPIPE_SZ

arguments.

*/

testcases/kernel/syscalls/fcntl/fcntl30.c +9 -27
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <pwd.h>
-
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 
 #include "lapi/fcntl.h"
 
-char *TCID = "fcntl30";
-int TST_TOTAL = 1;
+static int fds[2];
+static int max_size_unpriv;
 
-static void setup(void);
-static void cleanup(void);
-
-int main(int ac, char **av)
+static void run(void)
 
 {
 
-       int lc;
-       int pipe_fds[2], test_fd;
-       int orig_pipe_size, new_pipe_size;
-
-
-       tst_parse_opts(ac, av, NULL, NULL);
+       int orig_size, new_size;
 
-       setup();
+       SAFE_PIPE(fds);
 
-       for (lc = 0; TEST_LOOPING(lc); lc++) {
-               tst_count = 0;
+       TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
 
-               SAFE_PIPE(cleanup, pipe_fds);
-               test_fd = pipe_fds[1];
+       orig_size = TST_RET;
+       new_size = orig_size * 2;
Quoted 11 lines
Quoted 8 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +2 -5
-               TEST(fcntl(test_fd, F_GETPIPE_SZ));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl get pipe size failed");
-               }
+       if (new_size > max_size_unpriv)
+               tst_brk(TBROK, "Requested pipe size above the allowed

limit %d", max_size_unpriv);

It is possible that the pipe-max-size value was set to a smaller size so that the test gets failure here. But it would not be a problem.

Do you mean the EPERM scenario when unprivileged process trying to set the size larger than the value in /proc/sys/fs/pipe-max-size? if yes, this is being covered in fcntl37.

Quoted 2 lines

I guess TCONF should be more proper.

I'm not sure if TCONF is more apt.

Quoted 3 lines

Otherwise, LGTM.

Thank you for the review.

Quoted 71 lines
Quoted 71 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +4 -7
-               orig_pipe_size = TEST_RETURN;
-               new_pipe_size = orig_pipe_size * 2;
-               TEST(fcntl(test_fd, F_SETPIPE_SZ, new_pipe_size));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl test F_SETPIPE_SZ failed");
-               }
+       TST_EXP_POSITIVE(fcntl(fds[1], F_SETPIPE_SZ, new_size));
+       TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
+       TST_EXP_EXPR(TST_RET >= new_size,
+                               "new pipe size (%ld) >= requested size

(%d)",

testcases/kernel/syscalls/fcntl/fcntl30.c +1 -9
+                               TST_RET, new_size);
 
-               TEST(fcntl(test_fd, F_GETPIPE_SZ));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl test F_GETPIPE_SZ failed");
-               }
-               tst_resm(TINFO, "orig_pipe_size: %d new_pipe_size: %d",
-                        orig_pipe_size, new_pipe_size);
-               if (TEST_RETURN >= new_pipe_size) {
-                       tst_resm(TPASS, "fcntl test F_GETPIPE_SZ and

F_SETPIPE_SZ passed");

testcases/kernel/syscalls/fcntl/fcntl30.c +0 -2
-               } else {
-                       tst_resm(TFAIL, "fcntl test F_GETPIPE_SZ and

F_SETPIPE_SZ failed");

testcases/kernel/syscalls/fcntl/fcntl30.c +13 -11
-               }
-               SAFE_CLOSE(cleanup, pipe_fds[0]);
-               SAFE_CLOSE(cleanup, pipe_fds[1]);
-       }
-
-       cleanup();
-       tst_exit();
+       SAFE_CLOSE(fds[0]);
+       SAFE_CLOSE(fds[1]);
 
 }
 
 static void setup(void)
 {
 
-       tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-       TEST_PAUSE;
+       SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d",
 
 &max_size_unpriv);
 }
 
 static void cleanup(void)
 {
 
+       if (fds[0] > 0)
+               SAFE_CLOSE(fds[0]);
+       if (fds[1] > 0)
+               SAFE_CLOSE(fds[1]);
 
 }
 
+
+static struct tst_test test = {
+       .test_all = run,
+       .setup = setup,
+       .cleanup = cleanup
+};
--

2.40.1

Quoted 2 lines
Quoted 2 lines

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

--
Regards,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
Quoted 116 lines · Avinesh Kumar

Hi Li,

Quoted 15 lines · IST Li Wang
Quoted 14 lines · Avinesh Kumar

---

 testcases/kernel/syscalls/fcntl/fcntl30.c | 112 +++++++---------------
 1 file changed, 36 insertions(+), 76 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl30.c +1 -0
index c4c3f81f1..62cc39e73 100644
@@ -1,103 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0
 
Quoted 7 lines

testcases/kernel/syscalls/fcntl/fcntl30.c

Quoted 7 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +0 -2
 /*
 
  * Copyright (c) 2014 Fujitsu Ltd.
  * Author: Xiaoguang Wang <[email protected]>
 
- *
- * This program is free software; you can redistribute it and/or

modify

Quoted 5 lines
Quoted 5 lines

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

Quoted 6 lines
Quoted 6 lines

- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation,

Inc.,

Quoted 9 lines
Quoted 9 lines

- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * Copyright (c) 2023 SUSE LLC Avinesh Kumar <[email protected]>

*/

-/*
- * Description:
- * Verify that,
- * Basic test for fcntl(2) using F_SETPIPE_SZ, F_GETPIPE_SZ

argument.

Quoted 56 lines
Quoted 56 lines

+/*\
+ * [Description]
+ *
+ * Verify that, fetching and changing the capacity of a pipe works as
+ * expected with fcntl(2) syscall using F_GETPIPE_SZ, F_SETPIPE_SZ arguments.

*/

testcases/kernel/syscalls/fcntl/fcntl30.c +9 -27
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <pwd.h>
-
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 
 #include "lapi/fcntl.h"
 
-char *TCID = "fcntl30";
-int TST_TOTAL = 1;
+static int fds[2];
+static int max_size_unpriv;
 
-static void setup(void);
-static void cleanup(void);
-
-int main(int ac, char **av)
+static void run(void)
 
 {
 
-       int lc;
-       int pipe_fds[2], test_fd;
-       int orig_pipe_size, new_pipe_size;
-
-
-       tst_parse_opts(ac, av, NULL, NULL);
+       int orig_size, new_size;
 
-       setup();
+       SAFE_PIPE(fds);
 
-       for (lc = 0; TEST_LOOPING(lc); lc++) {
-               tst_count = 0;
+       TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
 
-               SAFE_PIPE(cleanup, pipe_fds);
-               test_fd = pipe_fds[1];
+       orig_size = TST_RET;
+       new_size = orig_size * 2;
Quoted 11 lines
Quoted 8 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +2 -5
-               TEST(fcntl(test_fd, F_GETPIPE_SZ));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl get pipe size failed");
-               }
+       if (new_size > max_size_unpriv)
+               tst_brk(TBROK, "Requested pipe size above the allowed

limit %d", max_size_unpriv);

It is possible that the pipe-max-size value was set to a smaller size so that the test gets failure here. But it would not be a problem.

Quoted 4 lines

Do you mean the EPERM scenario when unprivileged process trying to set the size larger than the value in /proc/sys/fs/pipe-max-size? if yes, this is being covered in fcntl37.

No, as this file allows us to configure the maximum size of the buffer used for data transfer between processes through pipes.

Imagine that, if a test machine set it with a smaller size, this test will get a failure like:

# echo 8192 > /proc/sys/fs/pipe-max-size
# cat /proc/sys/fs/pipe-max-size
8192
# ./fcntl30
tst_test.c:1560: TINFO: Timeout per run is 0h 00m 30s
fcntl30.c:28: TPASS: fcntl(fds[1], F_GETPIPE_SZ) returned 65536
fcntl30.c:34: TBROK: Requested pipe size above the allowed limit 8192

Summary:

passed   1
failed   0
broken   1
skipped  0

warnings 0

Quoted 89 lines
Quoted 2 lines

I guess TCONF should be more proper.

I'm not sure if TCONF is more apt.

Quoted 3 lines

Otherwise, LGTM.

Thank you for the review.

Quoted 71 lines
Quoted 71 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +4 -7
-               orig_pipe_size = TEST_RETURN;
-               new_pipe_size = orig_pipe_size * 2;
-               TEST(fcntl(test_fd, F_SETPIPE_SZ, new_pipe_size));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl test F_SETPIPE_SZ failed");
-               }
+       TST_EXP_POSITIVE(fcntl(fds[1], F_SETPIPE_SZ, new_size));
+       TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
+       TST_EXP_EXPR(TST_RET >= new_size,
+                               "new pipe size (%ld) >= requested size

(%d)",

testcases/kernel/syscalls/fcntl/fcntl30.c +1 -9
+                               TST_RET, new_size);
 
-               TEST(fcntl(test_fd, F_GETPIPE_SZ));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl test F_GETPIPE_SZ failed");
-               }
-               tst_resm(TINFO, "orig_pipe_size: %d new_pipe_size: %d",
-                        orig_pipe_size, new_pipe_size);
-               if (TEST_RETURN >= new_pipe_size) {
-                       tst_resm(TPASS, "fcntl test F_GETPIPE_SZ and

F_SETPIPE_SZ passed");

testcases/kernel/syscalls/fcntl/fcntl30.c +0 -2
-               } else {
-                       tst_resm(TFAIL, "fcntl test F_GETPIPE_SZ and

F_SETPIPE_SZ failed");

testcases/kernel/syscalls/fcntl/fcntl30.c +13 -11
-               }
-               SAFE_CLOSE(cleanup, pipe_fds[0]);
-               SAFE_CLOSE(cleanup, pipe_fds[1]);
-       }
-
-       cleanup();
-       tst_exit();
+       SAFE_CLOSE(fds[0]);
+       SAFE_CLOSE(fds[1]);
 
 }
 
 static void setup(void)
 {
 
-       tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-       TEST_PAUSE;
+       SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d",
 
 &max_size_unpriv);
 }
 
 static void cleanup(void)
 {
 
+       if (fds[0] > 0)
+               SAFE_CLOSE(fds[0]);
+       if (fds[1] > 0)
+               SAFE_CLOSE(fds[1]);
 
 }
 
+
+static struct tst_test test = {
+       .test_all = run,
+       .setup = setup,
+       .cleanup = cleanup
+};
--

2.40.1

Quoted 2 lines
Quoted 2 lines

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

--
Regards,
Avinesh

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw
Quoted 131 lines · IST Li Wang
Quoted 126 lines · Avinesh Kumar

Hi Li,

Quoted 16 lines · IST Li Wang
Quoted 15 lines · Avinesh Kumar

---

 testcases/kernel/syscalls/fcntl/fcntl30.c | 112
 +++++++---------------
 1 file changed, 36 insertions(+), 76 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl30.c +1 -0
index c4c3f81f1..62cc39e73 100644
@@ -1,103 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0
 
Quoted 7 lines

testcases/kernel/syscalls/fcntl/fcntl30.c

Quoted 7 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +0 -2
 /*
 
  * Copyright (c) 2014 Fujitsu Ltd.
  * Author: Xiaoguang Wang <[email protected]>
 
- *
- * This program is free software; you can redistribute it and/or

modify

Quoted 5 lines
Quoted 5 lines

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

Quoted 6 lines
Quoted 6 lines

- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation,

Inc.,

Quoted 9 lines
Quoted 9 lines

- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * Copyright (c) 2023 SUSE LLC Avinesh Kumar <[email protected]>

*/

-/*
- * Description:
- * Verify that,
- * Basic test for fcntl(2) using F_SETPIPE_SZ, F_GETPIPE_SZ

argument.

Quoted 56 lines
Quoted 56 lines

+/*\
+ * [Description]
+ *
+ * Verify that, fetching and changing the capacity of a pipe works as
+ * expected with fcntl(2) syscall using F_GETPIPE_SZ, F_SETPIPE_SZ arguments.

*/

testcases/kernel/syscalls/fcntl/fcntl30.c +9 -27
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <pwd.h>
-
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 
 #include "lapi/fcntl.h"
 
-char *TCID = "fcntl30";
-int TST_TOTAL = 1;
+static int fds[2];
+static int max_size_unpriv;
 
-static void setup(void);
-static void cleanup(void);
-
-int main(int ac, char **av)
+static void run(void)
 
 {
 
-       int lc;
-       int pipe_fds[2], test_fd;
-       int orig_pipe_size, new_pipe_size;
-
-
-       tst_parse_opts(ac, av, NULL, NULL);
+       int orig_size, new_size;
 
-       setup();
+       SAFE_PIPE(fds);
 
-       for (lc = 0; TEST_LOOPING(lc); lc++) {
-               tst_count = 0;
+       TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
 
-               SAFE_PIPE(cleanup, pipe_fds);
-               test_fd = pipe_fds[1];
+       orig_size = TST_RET;
+       new_size = orig_size * 2;
Quoted 11 lines
Quoted 8 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +2 -5
-               TEST(fcntl(test_fd, F_GETPIPE_SZ));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl get pipe size failed");
-               }
+       if (new_size > max_size_unpriv)
+               tst_brk(TBROK, "Requested pipe size above the allowed

limit %d", max_size_unpriv);

It is possible that the pipe-max-size value was set to a smaller size so that the test gets failure here. But it would not be a problem.

Quoted 3 lines

Do you mean the EPERM scenario when unprivileged process trying to set the size larger than the value in /proc/sys/fs/pipe-max-size? if yes, this is being covered in fcntl37.

Quoted 5 lines

No, as this file allows us to configure the maximum size of the buffer used for data transfer between processes through pipes.

Imagine that, if a test machine set it with a smaller size, this test will get a failure like:

okay, so instead we can just do ?

- new_size = orig_size * 2;
+ new_size = max_size_unpriv;

this should always test the F_SETPIPE_SZ positive case.

Quoted 104 lines
# echo 8192 > /proc/sys/fs/pipe-max-size
# cat /proc/sys/fs/pipe-max-size
8192
# ./fcntl30
tst_test.c:1560: TINFO: Timeout per run is 0h 00m 30s
fcntl30.c:28: TPASS: fcntl(fds[1], F_GETPIPE_SZ) returned 65536
fcntl30.c:34: TBROK: Requested pipe size above the allowed limit 8192

Summary:

passed   1
failed   0
broken   1
skipped  0

warnings 0

Quoted 86 lines
Quoted 1 line

I guess TCONF should be more proper.

I'm not sure if TCONF is more apt.

Quoted 2 lines

Otherwise, LGTM.

Thank you for the review.

Quoted 71 lines
Quoted 71 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +4 -7
-               orig_pipe_size = TEST_RETURN;
-               new_pipe_size = orig_pipe_size * 2;
-               TEST(fcntl(test_fd, F_SETPIPE_SZ, new_pipe_size));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl test F_SETPIPE_SZ failed");
-               }
+       TST_EXP_POSITIVE(fcntl(fds[1], F_SETPIPE_SZ, new_size));
+       TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
+       TST_EXP_EXPR(TST_RET >= new_size,
+                               "new pipe size (%ld) >= requested size

(%d)",

testcases/kernel/syscalls/fcntl/fcntl30.c +1 -6
+                               TST_RET, new_size);
 
-               TEST(fcntl(test_fd, F_GETPIPE_SZ));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl test F_GETPIPE_SZ failed");
-               }
-               tst_resm(TINFO, "orig_pipe_size: %d new_pipe_size:

%d",

testcases/kernel/syscalls/fcntl/fcntl30.c +0 -3
-                        orig_pipe_size, new_pipe_size);
-               if (TEST_RETURN >= new_pipe_size) {
-                       tst_resm(TPASS, "fcntl test F_GETPIPE_SZ and

F_SETPIPE_SZ passed");

testcases/kernel/syscalls/fcntl/fcntl30.c +0 -2
-               } else {
-                       tst_resm(TFAIL, "fcntl test F_GETPIPE_SZ and

F_SETPIPE_SZ failed");

testcases/kernel/syscalls/fcntl/fcntl30.c +13 -11
-               }
-               SAFE_CLOSE(cleanup, pipe_fds[0]);
-               SAFE_CLOSE(cleanup, pipe_fds[1]);
-       }
-
-       cleanup();
-       tst_exit();
+       SAFE_CLOSE(fds[0]);
+       SAFE_CLOSE(fds[1]);
 
 }
 
 static void setup(void)
 {
 
-       tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-       TEST_PAUSE;
+       SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d",
 
 &max_size_unpriv);
 }
 
 static void cleanup(void)
 {
 
+       if (fds[0] > 0)
+               SAFE_CLOSE(fds[0]);
+       if (fds[1] > 0)
+               SAFE_CLOSE(fds[1]);
 
 }
 
+
+static struct tst_test test = {
+       .test_all = run,
+       .setup = setup,
+       .cleanup = cleanup
+};
--

2.40.1

Quoted 2 lines
Quoted 2 lines

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

--
Regards,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw
Quoted 150 lines · Avinesh Kumar
Quoted 25 lines · IST Li Wang
Quoted 24 lines · Avinesh Kumar

Hi Li,

Quoted 21 lines · IST Li Wang
Quoted 20 lines · Avinesh Kumar

---

 testcases/kernel/syscalls/fcntl/fcntl30.c | 112
 +++++++---------------
 1 file changed, 36 insertions(+), 76 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl30.c +1 -0
index c4c3f81f1..62cc39e73 100644
@@ -1,103 +1,63 @@
+// SPDX-License-Identifier: GPL-2.0
 
 /*
 
  * Copyright (c) 2014 Fujitsu Ltd.
  * Author: Xiaoguang Wang <[email protected]>
 
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

testcases/kernel/syscalls/fcntl/fcntl30.c line 8

Quoted 2 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +0 -2
- *
- * This program is free software; you can redistribute it and/or

modify

Quoted 2 lines
Quoted 2 lines

it
- * under the terms of version 2 of the GNU General Public License

as

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be

useful,

Quoted 7 lines
Quoted 7 lines

but

Quoted 4 lines
Quoted 4 lines

- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public

License

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

along
- * with this program; if not, write the Free Software Foundation,

Inc.,

Quoted 2 lines
Quoted 2 lines

- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * Copyright (c) 2023 SUSE LLC Avinesh Kumar <

[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

*/

-/*
- * Description:
- * Verify that,
- * Basic test for fcntl(2) using F_SETPIPE_SZ, F_GETPIPE_SZ

Quoted 6 lines
Quoted 6 lines

argument.

Quoted 4 lines
Quoted 4 lines

+/*\
+ * [Description]
+ *
+ * Verify that, fetching and changing the capacity of a pipe

works as

Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
Quoted 52 lines

+ * expected with fcntl(2) syscall using F_GETPIPE_SZ, F_SETPIPE_SZ arguments.

*/

testcases/kernel/syscalls/fcntl/fcntl30.c +9 -27
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <pwd.h>
-
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 
 #include "lapi/fcntl.h"
 
-char *TCID = "fcntl30";
-int TST_TOTAL = 1;
+static int fds[2];
+static int max_size_unpriv;
 
-static void setup(void);
-static void cleanup(void);
-
-int main(int ac, char **av)
+static void run(void)
 
 {
 
-       int lc;
-       int pipe_fds[2], test_fd;
-       int orig_pipe_size, new_pipe_size;
-
-
-       tst_parse_opts(ac, av, NULL, NULL);
+       int orig_size, new_size;
 
-       setup();
+       SAFE_PIPE(fds);
 
-       for (lc = 0; TEST_LOOPING(lc); lc++) {
-               tst_count = 0;
+       TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
 
-               SAFE_PIPE(cleanup, pipe_fds);
-               test_fd = pipe_fds[1];
+       orig_size = TST_RET;
+       new_size = orig_size * 2;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

testcases/kernel/syscalls/fcntl/fcntl30.c

Quoted 7 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +2 -5
-               TEST(fcntl(test_fd, F_GETPIPE_SZ));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl get pipe size failed");
-               }
+       if (new_size > max_size_unpriv)
+               tst_brk(TBROK, "Requested pipe size above the

allowed

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

limit %d", max_size_unpriv);

It is possible that the pipe-max-size value was set to a smaller size so that the test gets failure here. But it would not be a problem.

Do you mean the EPERM scenario when unprivileged process trying to set

the

Quoted 1 line
Quoted 1 line

size larger than the value in /proc/sys/fs/pipe-max-size? if yes, this

is

Quoted 7 lines
Quoted 1 line

being covered in fcntl37.

No, as this file allows us to configure the maximum size of the buffer used for data transfer between processes through pipes.

Imagine that, if a test machine set it with a smaller size, this test will get a failure like:

okay, so instead we can just do ?

(quoted diff) +1 -1
-       new_size = orig_size * 2;
+       new_size = max_size_unpriv;
Quoted 2 lines

this should always test the F_SETPIPE_SZ positive case.

Yes, this should work.

Quoted 113 lines
Quoted 12 lines

# echo 8192 > /proc/sys/fs/pipe-max-size
# cat /proc/sys/fs/pipe-max-size
8192
# ./fcntl30
tst_test.c:1560: TINFO: Timeout per run is 0h 00m 30s
fcntl30.c:28: TPASS: fcntl(fds[1], F_GETPIPE_SZ) returned 65536
fcntl30.c:34: TBROK: Requested pipe size above the allowed limit 8192
Quoted 27 lines

Summary:

passed   1
failed   0
broken   1
skipped  0

warnings 0

Quoted 20 lines
Quoted 1 line

I guess TCONF should be more proper.

I'm not sure if TCONF is more apt.

Quoted 2 lines

Otherwise, LGTM.

Thank you for the review.

Quoted 11 lines
Quoted 11 lines
testcases/kernel/syscalls/fcntl/fcntl30.c +4 -7
-               orig_pipe_size = TEST_RETURN;
-               new_pipe_size = orig_pipe_size * 2;
-               TEST(fcntl(test_fd, F_SETPIPE_SZ, new_pipe_size));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl test F_SETPIPE_SZ failed");
-               }
+       TST_EXP_POSITIVE(fcntl(fds[1], F_SETPIPE_SZ, new_size));
+       TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
+       TST_EXP_EXPR(TST_RET >= new_size,
+                               "new pipe size (%ld) >= requested

size

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

testcases/kernel/syscalls/fcntl/fcntl30.c

Quoted 13 lines

(%d)",

testcases/kernel/syscalls/fcntl/fcntl30.c +1 -6
+                               TST_RET, new_size);
 
-               TEST(fcntl(test_fd, F_GETPIPE_SZ));
-               if (TEST_RETURN < 0) {
-                       tst_brkm(TFAIL | TTERRNO, cleanup,
-                                "fcntl test F_GETPIPE_SZ failed");
-               }
-               tst_resm(TINFO, "orig_pipe_size: %d new_pipe_size:

%d",

testcases/kernel/syscalls/fcntl/fcntl30.c +0 -3
-                        orig_pipe_size, new_pipe_size);
-               if (TEST_RETURN >= new_pipe_size) {
-                       tst_resm(TPASS, "fcntl test F_GETPIPE_SZ

and

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

testcases/kernel/syscalls/fcntl/fcntl30.c

Quoted 3 lines

F_SETPIPE_SZ passed");

testcases/kernel/syscalls/fcntl/fcntl30.c +0 -2
-               } else {
-                       tst_resm(TFAIL, "fcntl test F_GETPIPE_SZ

and

Quoted 50 lines
Quoted 50 lines
Quoted 44 lines
Quoted 44 lines

F_SETPIPE_SZ failed");

testcases/kernel/syscalls/fcntl/fcntl30.c +13 -11
-               }
-               SAFE_CLOSE(cleanup, pipe_fds[0]);
-               SAFE_CLOSE(cleanup, pipe_fds[1]);
-       }
-
-       cleanup();
-       tst_exit();
+       SAFE_CLOSE(fds[0]);
+       SAFE_CLOSE(fds[1]);
 
 }
 
 static void setup(void)
 {
 
-       tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-       TEST_PAUSE;
+       SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d",
 
 &max_size_unpriv);
 }
 
 static void cleanup(void)
 {
 
+       if (fds[0] > 0)
+               SAFE_CLOSE(fds[0]);
+       if (fds[1] > 0)
+               SAFE_CLOSE(fds[1]);
 
 }
 
+
+static struct tst_test test = {
+       .test_all = run,
+       .setup = setup,
+       .cleanup = cleanup
+};
--

2.40.1

Quoted 2 lines
Quoted 2 lines

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

--
Regards,
Avinesh

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

PATCH v2 1/1 fcntl30.c: Convert the test to new LTP API

---
 testcases/kernel/syscalls/fcntl/fcntl30.c | 111 ++++++----------------
 1 file changed, 31 insertions(+), 80 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl30.c +31 -80
index c4c3f81f1..d5edbd885 100644
@@ -1,103 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Fujitsu Ltd.
  * Author: Xiaoguang Wang <[email protected]>
- *
- * 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.
- *
- * 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.
+ * Copyright (c) 2023 SUSE LLC Avinesh Kumar <[email protected]>
  */
 
-/*
- * Description:
- * Verify that,
- *     Basic test for fcntl(2) using F_SETPIPE_SZ, F_GETPIPE_SZ argument.
+/*\
+ * [Description]
+ *
+ * Verify that, fetching and changing the capacity of a pipe works as
+ * expected with fcntl(2) syscall using F_GETPIPE_SZ, F_SETPIPE_SZ arguments.
  */
 
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <pwd.h>
-
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/fcntl.h"
 
-char *TCID = "fcntl30";
-int TST_TOTAL = 1;
-
-static void setup(void);
-static void cleanup(void);
+static int fds[2];
+static int max_size_unpriv;
 
-int main(int ac, char **av)
+static void run(void)
 {
-	int lc;
-	int pipe_fds[2], test_fd;
-	int orig_pipe_size, new_pipe_size;
+	SAFE_PIPE(fds);
 
+	TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	TST_EXP_POSITIVE(fcntl(fds[1], F_SETPIPE_SZ, max_size_unpriv));
+	TST_EXP_POSITIVE(fcntl(fds[1], F_GETPIPE_SZ));
+	TST_EXP_EXPR(TST_RET >= max_size_unpriv,
+				"new pipe size (%ld) >= requested size (%d)",
+				TST_RET, max_size_unpriv);
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		SAFE_PIPE(cleanup, pipe_fds);
-		test_fd = pipe_fds[1];
-
-		TEST(fcntl(test_fd, F_GETPIPE_SZ));
-		if (TEST_RETURN < 0) {
-			tst_brkm(TFAIL | TTERRNO, cleanup,
-				 "fcntl get pipe size failed");
-		}
-
-		orig_pipe_size = TEST_RETURN;
-		new_pipe_size = orig_pipe_size * 2;
-		TEST(fcntl(test_fd, F_SETPIPE_SZ, new_pipe_size));
-		if (TEST_RETURN < 0) {
-			tst_brkm(TFAIL | TTERRNO, cleanup,
-				 "fcntl test F_SETPIPE_SZ failed");
-		}
-
-		TEST(fcntl(test_fd, F_GETPIPE_SZ));
-		if (TEST_RETURN < 0) {
-			tst_brkm(TFAIL | TTERRNO, cleanup,
-				 "fcntl test F_GETPIPE_SZ failed");
-		}
-		tst_resm(TINFO, "orig_pipe_size: %d new_pipe_size: %d",
-			 orig_pipe_size, new_pipe_size);
-		if (TEST_RETURN >= new_pipe_size) {
-			tst_resm(TPASS, "fcntl test F_GETPIPE_SZ and F_SETPIPE_SZ passed");
-		} else {
-			tst_resm(TFAIL, "fcntl test F_GETPIPE_SZ and F_SETPIPE_SZ failed");
-		}
-		SAFE_CLOSE(cleanup, pipe_fds[0]);
-		SAFE_CLOSE(cleanup, pipe_fds[1]);
-	}
-
-	cleanup();
-	tst_exit();
+	SAFE_CLOSE(fds[0]);
+	SAFE_CLOSE(fds[1]);
 }
 
 static void setup(void)
 {
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
+	SAFE_FILE_SCANF("/proc/sys/fs/pipe-max-size", "%d",	&max_size_unpriv);
 }
 
 static void cleanup(void)
 {
+	if (fds[0] > 0)
+		SAFE_CLOSE(fds[0]);
+	if (fds[1] > 0)
+		SAFE_CLOSE(fds[1]);
 }
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup
+};
Signature · 5 lines
2.40.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Applied
#7 lore raw

Merged, thanks!

Signature · 5 lines
Regards,
Li Wang

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