Skip to contentSkip to conversation

syscalls/clone3: New tests

PATCH New Viresh Kumar 2 participants 4 messages Mar 20, 2020

lore
Share & tools
lore
#0 lore raw

v3 cover syscalls/clone3: New tests

Hello,

Here is the second attempt at adding clone3() related tests.

--
viresh

V2->V3:
- Rename check_syscall_support() and make it a routine.
- Don't print messages from signal handlers.
- Don't allocate structures at runtime unnecessarily.
- Initialize invalid_args to an invalid address instead of NULL.

V1->V2:
- Relocated pidfd_send_signal.h, as clone3() needs to use the syscall.
- clone301.c is now sending and verifying signals between parent/child processes.
- More failure tests to validate remaining fields.

Viresh Kumar (2):
syscalls/pidfd_send_signal: Move pidfd_send_signal.h to include/lapi/ syscalls/clone3: New tests

 configure.ac                                  |   1 +
 include/lapi/clone.h                          |  49 ++++++
 .../lapi}/pidfd_send_signal.h                 |   3 +-
 runtest/syscalls                              |   3 +
 testcases/kernel/syscalls/clone3/.gitignore   |   2 +
 testcases/kernel/syscalls/clone3/Makefile     |   7 +
 testcases/kernel/syscalls/clone3/clone301.c   | 150 ++++++++++++++++++
 testcases/kernel/syscalls/clone3/clone302.c   | 102 ++++++++++++
 .../pidfd_send_signal/pidfd_send_signal01.c   |   4 +-
 .../pidfd_send_signal/pidfd_send_signal02.c   |   4 +-
 .../pidfd_send_signal/pidfd_send_signal03.c   |   4 +-
 11 files changed, 321 insertions(+), 8 deletions(-)
 create mode 100644 include/lapi/clone.h
 rename {testcases/kernel/syscalls/pidfd_send_signal => include/lapi}/pidfd_send_signal.h (85%)
 create mode 100644 testcases/kernel/syscalls/clone3/.gitignore
 create mode 100644 testcases/kernel/syscalls/clone3/Makefile
 create mode 100644 testcases/kernel/syscalls/clone3/clone301.c
 create mode 100644 testcases/kernel/syscalls/clone3/clone302.c
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
#1 lore raw

PATCH v3 1/2 syscalls/pidfd_send_signal: Move pidfd_send_signal.h to include/lapi/

Move pidfd_send_signal.h to include/lapi/ to make it available for other syscall tests.

While at it, also rename check_syscall_support() to pidfd_send_signal_supported().

---
 .../pidfd_send_signal => include/lapi}/pidfd_send_signal.h    | 3 +--
 .../kernel/syscalls/pidfd_send_signal/pidfd_send_signal01.c   | 4 ++--
 .../kernel/syscalls/pidfd_send_signal/pidfd_send_signal02.c   | 4 ++--
 .../kernel/syscalls/pidfd_send_signal/pidfd_send_signal03.c   | 4 ++--
 4 files changed, 7 insertions(+), 8 deletions(-)
 rename {testcases/kernel/syscalls/pidfd_send_signal => include/lapi}/pidfd_send_signal.h (85%)
include/lapi/pidfd_send_signal.h renamed from testcases/kernel/syscalls/pidfd_send_signal/pidfd_send_signal.h +1 -2
similarity index 85%
rename from testcases/kernel/syscalls/pidfd_send_signal/pidfd_send_signal.h
rename to include/lapi/pidfd_send_signal.h
index dc17fe058672..8352d2adf787 100644
@@ -10,7 +10,7 @@
 #include "tst_test.h"
 #include "lapi/syscalls.h"
 
-static void check_syscall_support(void)
+static inline void pidfd_send_signal_supported(void)
 {
 	/* allow the tests to fail early */
 	tst_syscall(__NR_pidfd_send_signal);
@@ -20,7 +20,6 @@ static void check_syscall_support(void)
 static int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
 				 unsigned int flags)
 {
-	tst_res(TINFO, "Testing syscall(__NR_pidfd_send_signal)");
 	return tst_syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags);
 }
 #endif /* HAVE_PIDFD_SEND_SIGNAL */
testcases/kernel/syscalls/pidfd_send_signal/pidfd_send_signal01.c +2 -2
index 03a4ae9bea41..4cb5df94c425 100644
@@ -12,8 +12,8 @@
 #define _GNU_SOURCE
 #include <signal.h>
 #include <stdlib.h>
+#include "lapi/pidfd_send_signal.h"
 #include "tst_safe_pthread.h"
-#include "pidfd_send_signal.h"
 
 #define SIGNAL  SIGUSR1
 #define DATA	777
@@ -69,7 +69,7 @@ static void verify_pidfd_send_signal(void)
 
 static void setup(void)
 {
-	check_syscall_support();
+	pidfd_send_signal_supported();
 
 	pidfd = SAFE_OPEN("/proc/self", O_DIRECTORY | O_CLOEXEC);
 
testcases/kernel/syscalls/pidfd_send_signal/pidfd_send_signal02.c +2 -2
index 74914523f0b8..1e62b417f29f 100644
@@ -24,8 +24,8 @@
 #define _GNU_SOURCE
 #include <pwd.h>
 #include <signal.h>
+#include "lapi/pidfd_send_signal.h"
 #include "tst_safe_pthread.h"
-#include "pidfd_send_signal.h"
 
 #define CORRECT_SIGNAL		SIGUSR1
 #define DIFFERENT_SIGNAL	SIGUSR2
@@ -68,7 +68,7 @@ static void setup(void)
 {
 	struct passwd *pw;
 
-	check_syscall_support();
+	pidfd_send_signal_supported();
 
 	pidfd = SAFE_OPEN("/proc/self", O_DIRECTORY | O_CLOEXEC);
 	init_pidfd = SAFE_OPEN("/proc/1", O_DIRECTORY | O_CLOEXEC);
testcases/kernel/syscalls/pidfd_send_signal/pidfd_send_signal03.c +2 -2
index 3420afbb9526..0903d67076aa 100644
@@ -19,7 +19,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
-#include "pidfd_send_signal.h"
+#include "lapi/pidfd_send_signal.h"
 #include "tst_safe_pthread.h"
 
 #define PIDTRIES	3
@@ -111,7 +111,7 @@ static void verify_pidfd_send_signal(void)
 
 static void setup(void)
 {
-	check_syscall_support();
+	pidfd_send_signal_supported();
 
 	last_pid_file = "/proc/sys/kernel/ns_last_pid";
 	if (access(last_pid_file, F_OK) == -1) {
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
#2 lore raw

PATCH v3 2/2 syscalls/clone3: New tests

In reply to Viresh Kumar

Add tests to check working of clone3() syscall.

---
 configure.ac                                |   1 +
 include/lapi/clone.h                        |  49 +++++++
 runtest/syscalls                            |   3 +
 testcases/kernel/syscalls/clone3/.gitignore |   2 +
 testcases/kernel/syscalls/clone3/Makefile   |   7 +
 testcases/kernel/syscalls/clone3/clone301.c | 150 ++++++++++++++++++++
 testcases/kernel/syscalls/clone3/clone302.c | 102 +++++++++++++
 7 files changed, 314 insertions(+)
 create mode 100644 include/lapi/clone.h
 create mode 100644 testcases/kernel/syscalls/clone3/.gitignore
 create mode 100644 testcases/kernel/syscalls/clone3/Makefile
 create mode 100644 testcases/kernel/syscalls/clone3/clone301.c
 create mode 100644 testcases/kernel/syscalls/clone3/clone302.c
configure.ac +1 -0
index 238d1cde85f2..cf89bd8c351e 100644
@@ -75,6 +75,7 @@ AC_CHECK_HEADERS(fts.h, [have_fts=1])
 AC_SUBST(HAVE_FTS_H, $have_fts)
 
 AC_CHECK_FUNCS([ \
+    clone3 \
     copy_file_range \
     epoll_pwait \
     execveat \
include/lapi/clone.h new file +49 -0

49 lines not on this page · raw message

runtest/syscalls +3 -0
index 6f2dcd82acf6..65ef53f33e0b 100644
@@ -105,6 +105,9 @@ clone07 clone07
 clone08 clone08
 clone09 clone09
 
+clone301 clone301
+clone302 clone302
+
 close01 close01
 close02 close02
 close08 close08
testcases/kernel/syscalls/clone3/.gitignore new file +2 -0
new file mode 100644
index 000000000000..604cb903e33d
@@ -0,0 +1,2 @@
+clone301
+clone302
testcases/kernel/syscalls/clone3/Makefile new file +7 -0
new file mode 100644
index 000000000000..18896b6f28c0
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/clone3/clone301.c new file +150 -0

150 lines not on this page · raw message

testcases/kernel/syscalls/clone3/clone302.c new file +102 -0

102 lines not on this page · raw message

Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
#3 lore raw

PATCH v3 2/2 syscalls/clone3: New tests

Hi!
Pushed with minor changes, thanks.

* Got rid of the unused variable warnings

* Changed it to allocate only one bad address and used that pointer for all cases

Signature · 2 lines
Cyril Hrubis
[email protected]