Update clone3 wrapper signature
PATCH v2 1/1 Update clone3 wrapper signature
This CL adds the ltp_clone3_raw wrapper for direct testing of the syscall and adds a ltp_clone3 wrapper for libc implementations that provide clone3.
Signed-off-by Chris Wailes <[email protected]>
---
Notes:
V2: Added HAVE_STRUCT_CLONE_ARGS and updated clone304.c
configure.ac | 1 + include/lapi/sched.h | 27 +++++++++++++++------ testcases/kernel/syscalls/clone3/clone301.c | 2 +- testcases/kernel/syscalls/clone3/clone302.c | 2 +- testcases/kernel/syscalls/clone3/clone304.c | 2 +- 5 files changed, 24 insertions(+), 10 deletions(-)
configure.ac +1 -0
@@ -189,6 +189,7 @@ AC_CHECK_MEMBERS([struct utsname.domainname],,,[ AC_CHECK_TYPES([enum kcmp_type],,,[#include <linux/kcmp.h>]) AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>]) AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>]) +AC_CHECK_TYPES([struct clone_args],,,[#include <sched.h>]) AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_error, struct fanotify_event_info_header, struct fanotify_event_info_pidfd, struct fanotify_event_info_range],,,[#include <sys/fanotify.h>])
include/lapi/sched.h +20 -7
@@ -49,8 +49,7 @@ static inline int sched_getattr(pid_t pid, struct sched_attr *attr,# define SCHED_ATTR_SIZE_VER0 48/* sizeof first published struct */ #endif -#ifndef HAVE_CLONE3 -struct clone_args { +struct clone_args_minimal {uint64_t __attribute__((aligned (8 ))) flags;uint64_t __attribute__((aligned (8 ))) pidfd;uint64_t __attribute__((aligned (8 ))) child_tid;
@@ -59,12 +58,10 @@ struct clone_args {uint64_t __attribute__((aligned (8 ))) stack;uint64_t __attribute__((aligned (8 ))) stack_size;uint64_t __attribute__((aligned (8 ))) tls; -uint64_t __attribute__((aligned (8 ))) set_tid; -uint64_t __attribute__((aligned (8 ))) set_tid_size; -uint64_t __attribute__((aligned (8 ))) cgroup; }; -struct clone_args_minimal { +#ifndef HAVE_STRUCT_CLONE_ARGS +struct clone_args { uint64_t __attribute__((aligned(8))) flags; uint64_t __attribute__((aligned(8))) pidfd; uint64_t __attribute__((aligned(8))) child_tid;
@@ -73,12 +70,28 @@ struct clone_args_minimal {uint64_t __attribute__((aligned (8 ))) stack;uint64_t __attribute__((aligned (8 ))) stack_size;uint64_t __attribute__((aligned (8 ))) tls; +uint64_t __attribute__((aligned (8 ))) set_tid; +uint64_t __attribute__((aligned (8 ))) set_tid_size; + uint64_t __attribute__((aligned(8))) cgroup; }; +#endif -static inline int clone3 (struct clone_args *args,size_t size) +static inline int ltp_clone3_raw (struct clone_args *args,size_t size) {return tst_syscall (__NR_clone3, args, size); } + +#ifdef HAVE_CLONE3 +static inline int ltp_clone3 (struct clone_args *cl_args,size_t size, +int (*fn)(void *),void *arg) { +return clone3 (cl_args, size, fn, arg); +} +#else +static inline int ltp_clone3 (struct clone_args *cl_args,size_t size, +int (*fn)(void *),void *arg) +{ +return -1 ; +}#endif static inline void clone3_supported_by_kernel (void )
testcases/kernel/syscalls/clone3/clone301.c +1 -1
@@ -123,7 +123,7 @@ static void run(unsigned int n) parent_received_signal =0 ;SAFE_SIGACTION (tc->exit_signal, &psig_action,NULL ); -TEST (pid =clone3 (args,sizeof (*args))); +TEST (pid =ltp_clone3_raw (args,sizeof (*args)));if (pid <0 ) {tst_res (TFAIL |TTERRNO ,"clone3() failed (%d)" , n);return ;
testcases/kernel/syscalls/clone3/clone302.c +1 -1
@@ -83,7 +83,7 @@ static void run(unsigned int n) args->tls = tc->tls; } -TEST (clone3 (args, tc->size)); +TEST (ltp_clone3_raw (args, tc->size));if (!TST_RET )exit (EXIT_SUCCESS );
testcases/kernel/syscalls/clone3/clone304.c +1 -1
@@ -58,7 +58,7 @@ static void run(unsigned int n) args.set_tid_size =1 ; } -TST_EXP_FAIL (clone3 (&args,sizeof (args)),EPERM , +TST_EXP_FAIL (ltp_clone3_raw (&args,sizeof (args)),EPERM ,"clone3(%s) set_tid_size=%ld" , tc->sflags, args.set_tid_size); }
Signature · 5 lines
2.53.0.959.g497ff81fa9-goog -- Mailing list info: https://lists.linux.it/listinfo/ltp
Patch merged, thanks!
Signature · 6 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp