aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/clone3/clone3_selftests.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/clone3/clone3_selftests.h')
-rw-r--r--tools/testing/selftests/clone3/clone3_selftests.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/testing/selftests/clone3/clone3_selftests.h b/tools/testing/selftests/clone3/clone3_selftests.h
index 0e3dea58855f..a3f2c8ad8bcc 100644
--- a/tools/testing/selftests/clone3/clone3_selftests.h
+++ b/tools/testing/selftests/clone3/clone3_selftests.h
@@ -34,4 +34,30 @@ static pid_t sys_clone3(struct clone_args *args, size_t size)
return syscall(__NR_clone3, args, size);
}
+static inline void test_clone3_supported(void)
+{
+ pid_t pid;
+ struct clone_args args = {};
+
+ if (__NR_clone3 < 0)
+ ksft_exit_skip("clone3() syscall is not supported\n");
+
+ /* Set to something that will always cause EINVAL. */
+ args.exit_signal = -1;
+ pid = sys_clone3(&args, sizeof(args));
+ if (!pid)
+ exit(EXIT_SUCCESS);
+
+ if (pid > 0) {
+ wait(NULL);
+ ksft_exit_fail_msg(
+ "Managed to create child process with invalid exit_signal\n");
+ }
+
+ if (errno == ENOSYS)
+ ksft_exit_skip("clone3() syscall is not supported\n");
+
+ ksft_print_msg("clone3() syscall supported\n");
+}
+
#endif /* _CLONE3_SELFTESTS_H */