diff mbox series

io_pgetevents01: Move the SAFE_CLOSE to the suitable location

Message ID 20220328115026.182554-1-zhaogongyi@huawei.com
State Accepted
Headers show
Series io_pgetevents01: Move the SAFE_CLOSE to the suitable location | expand

Commit Message

Zhao Gongyi March 28, 2022, 11:50 a.m. UTC
If we run the test with the option -i 10000, and the ulimit
of open files little than 10000, the test would fail and report
error of EMFILE.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 .../kernel/syscalls/io_pgetevents/io_pgetevents01.c      | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

--
2.17.1

Comments

Petr Vorel April 5, 2022, 12:04 p.m. UTC | #1
Hi, Zhao,

> If we run the test with the option -i 10000, and the ulimit
> of open files little than 10000, the test would fail and report
> error of EMFILE.

Thanks a lot, merged (with slightly changed commit message).

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c
index a0b56d814..0525221e8 100644
--- a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c
+++ b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c
@@ -28,12 +28,6 @@  static void setup(void)
 	tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc);
 }

-static void cleanup(void)
-{
-	if (fd > 0)
-		SAFE_CLOSE(fd);
-}
-
 static void run(void)
 {
 	struct time64_variants *tv = &variants[tst_variant];
@@ -71,6 +65,8 @@  static void run(void)

 	if (io_destroy(ctx) < 0)
 		tst_brk(TBROK | TERRNO, "io_destroy() failed");
+
+	SAFE_CLOSE(fd);
 }

 static struct tst_test test = {
@@ -78,7 +74,6 @@  static struct tst_test test = {
 	.test_all = run,
 	.test_variants = ARRAY_SIZE(variants),
 	.needs_tmpdir = 1,
-	.cleanup = cleanup,
 	.setup = setup,
 };