Check how clone syscall is traced. * tests/clone-f.c: New file. * tests/clone-f.test: New test. * tests/Makefile.am: (check_PROGRAMS): Add clone-f. (TESTS): Add clone-f.test. * tests/.gitignore: Add clone-f. --- tests/.gitignore | 1 + tests/Makefile.am | 2 ++ tests/clone-f.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/clone-f.test | 13 +++++++++++ 4 files changed, 84 insertions(+) create mode 100644 tests/clone-f.c create mode 100755 tests/clone-f.test
diff --git a/tests/.gitignore b/tests/.gitignore index 207a9b2..e8d7a4c 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -14,6 +14,7 @@ bpf caps clock_nanosleep clock_xettime +clone-f epoll_create1 eventfd execve diff --git a/tests/Makefile.am b/tests/Makefile.am index f634583..883498a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -62,6 +62,7 @@ check_PROGRAMS = \ caps \ clock_nanosleep \ clock_xettime \ + clone-f \ epoll_create1 \ eventfd \ execve \ @@ -202,6 +203,7 @@ TESTS = \ caps.test \ clock_nanosleep.test \ clock_xettime.test \ + clone-f.test \ dumpio.test \ epoll_create1.test \ eventfd.test \ diff --git a/tests/clone-f.c b/tests/clone-f.c new file mode 100644 index 0000000..5407349 --- /dev/null +++ b/tests/clone-f.c @@ -0,0 +1,68 @@ +#include "tests.h" +#include <assert.h> +#include <sched.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <sys/wait.h> + +#define CHILD_STACK_SIZE 16384 + +#if defined (__s390__) || (__s390x__) +#define clone __clone +extern int __clone(int(void*),void*,int,void*); +#elif defined(__ia64__) +#define clone2 __clone2 +extern int __clone2(int (*fn) (void *arg), void *child_stack_base, + size_t child_stack_size, int flags, void *arg, + pid_t *parent_tid, void *tls, pid_t *child_tid); +#endif + +static inline int +logit_(const char *const str) +{ + return !chdir(str); +} + +#define prefix "clone-f." +#define logit(arg) logit_(prefix arg) + +int +child() +{ + logit("child"); + return 0; +} + +int main() +{ + void *child_stack; + if ((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) { + perror_msg_and_fail("cannot allocate stack for child!"); + } + + pid_t child_pid; +#if defined(__hppa__) + child_pid = clone(&child, child_stack, SIGCHLD, NULL); +#elif defined(__ia64__) + child_pid = clone2(&child, child_stack, CHILD_STACK_SIZE, SIGCHLD, NULL, + NULL, NULL, NULL); +#else + child_pid = clone(&child, child_stack + CHILD_STACK_SIZE, SIGCHLD, NULL); +#endif + int status; + assert(wait(&status) == child_pid); + assert(status == 0); + + free (child_stack); + + logit("parent"); + + pid_t pid = getpid(); + printf("%-5d chdir(\"%schild\") = -1 ENOENT (%m)\n" + "%-5d chdir(\"%sparent\") = -1 ENOENT (%m)\n", + child_pid, prefix, + pid, prefix); + return 0; +} diff --git a/tests/clone-f.test b/tests/clone-f.test new file mode 100755 index 0000000..20840de --- /dev/null +++ b/tests/clone-f.test @@ -0,0 +1,13 @@ +#!/bin/sh + +# Check how clone syscall is traced. + +. "${srcdir=.}/init.sh" + +OUT="$LOG.out" +run_prog > /dev/null +run_strace -a29 -echdir -esignal=none -f -qq $args >"$OUT" +match_diff "$LOG" "$OUT" +rm -f "$OUT" + +exit 0 -- 1.8.3.1 ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel