[LTP] [PATCH] memfd_create04: Add SAFE_CLOSE before test return

Zhao Gongyi zhaogongyi@huawei.com
Tue Mar 22 04:02:45 CET 2022


If we run the test with the option -i 511, and the ulimit of
open files little than 1024, the test would fail and report:
memfd_create04.c:75: TFAIL: memfd_create() failed unexpectedly: EMFILE (24)

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 testcases/kernel/syscalls/memfd_create/memfd_create04.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/testcases/kernel/syscalls/memfd_create/memfd_create04.c b/testcases/kernel/syscalls/memfd_create/memfd_create04.c
index dc6e195f0..7b699b218 100644
--- a/testcases/kernel/syscalls/memfd_create/memfd_create04.c
+++ b/testcases/kernel/syscalls/memfd_create/memfd_create04.c
@@ -79,6 +79,8 @@ static void memfd_huge_x_controller(unsigned int n)
 	tst_res(TPASS,
 		"memfd_create succeeded for %s page size",
 		tflag.h_size);
+
+	SAFE_CLOSE(fd);
 }

 static void setup(void)
--
2.17.1



More information about the ltp mailing list