[LTP] [PATCH 2/2] close_range02: Add simpler test and Check invalid params

Petr Vorel pvorel@suse.cz
Tue Feb 16 07:48:46 CET 2021


Hi Richard,

> This adds some coverage for invalid parameters and a min fd above or
> on the limits. There is also some overlap with close_range01, but this
> test is simpler and has less requirements.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

LGTM, just minor nit: could we close file descriptor?
Otherwise it fails on higher -i (> 50). Something like code below?

Kind regards,
Petr

diff --git testcases/kernel/syscalls/close_range/close_range02.c testcases/kernel/syscalls/close_range/close_range02.c
index 9e099cec4..237b3d759 100644
--- testcases/kernel/syscalls/close_range/close_range02.c
+++ testcases/kernel/syscalls/close_range/close_range02.c
@@ -42,7 +42,7 @@ static void run(unsigned int n)
 		.flags = CLONE_FILES,
 		.exit_signal = SIGCHLD,
 	};
-	int fd, res;
+	int fd = -1, res;
 
 	switch (n) {
 	case 0:
@@ -101,6 +101,9 @@ static void run(unsigned int n)
 
 		TST_EXP_PASS(fcntl(fd, F_GETFD), "%d is open", fd);
 	}
+
+	if (n != 0 && fd > 0)
+		SAFE_CLOSE(fd);
 }
 
 static struct tst_test test = {


More information about the ltp mailing list