[LTP] [PATCH] io_pgetevents01: Move the SAFE_CLOSE to the suitable location

Zhao Gongyi zhaogongyi@huawei.com
Mon Mar 28 13:50:26 CEST 2022


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(-)

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,
 };

--
2.17.1



More information about the ltp mailing list