[LTP] [PATCH v2] accept02: Add SAFE_CLOSE before test return

Zhao Gongyi zhaogongyi@huawei.com
Thu Mar 24 03:24:55 CET 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>
---
v1->v2: according Cyril's review, add SAFE_CLOSE before test return.
 testcases/kernel/syscalls/accept/accept02.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/testcases/kernel/syscalls/accept/accept02.c b/testcases/kernel/syscalls/accept/accept02.c
index 12a1e3ca3..7cb3d6970 100644
--- a/testcases/kernel/syscalls/accept/accept02.c
+++ b/testcases/kernel/syscalls/accept/accept02.c
@@ -67,6 +67,7 @@ static void *server_thread(void *arg)

 	TEST(setsockopt(clone_server_sockfd, SOL_IP, MCAST_LEAVE_GROUP,
 			mc_group, mc_group_len));
+	SAFE_CLOSE(clone_server_sockfd);

 	if (TST_RET != -1)
 		tst_res(TFAIL, "Multicast group was copied!");
--
2.17.1



More information about the ltp mailing list