[PATCH v3 7/7] tests: extend the test case for -Y option
Masatake YAMATO
yamato at redhat.com
Thu Sep 9 13:43:37 UTC 2021
* tests/strace-Y-0123456789.c: Include "scno.h".
(do_default_action): Call pidfd_open as a system
call taking and returning pids. Printe expected comm
values.
Call `pidfd_open' to compare arguments and retvals.
* tests/gen_tests.in (strace-YY-0123456789): Add -yy option
and `pidfd_open' system call as a target system call.
Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
tests/gen_tests.in | 2 +-
tests/strace-Y-0123456789.c | 18 ++++++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index ed8a0f4ac..d3348a134 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -857,7 +857,7 @@ strace--timestamps-unix-us +strace-ttt.test 6 --timestamps=unix,us
strace-n -e trace=listen -n -qq -a 12
strace-x -e trace=chdir -x -a 12
strace-xx -e trace=chdir -xx -a 18
-strace-Y-0123456789 -e trace=getppid -e signal='!SIGCHLD' -q -f -Y -a 18
+strace-Y-0123456789 -e trace=getppid,pidfd_open -e signal='!SIGCHLD' -q -f -yy -Y -a 18
swap -a23 -e trace=swapon,swapoff
sxetmask -a11 -e trace=sgetmask,ssetmask
symlink -a34
diff --git a/tests/strace-Y-0123456789.c b/tests/strace-Y-0123456789.c
index 45b86aada..9febc2ac2 100644
--- a/tests/strace-Y-0123456789.c
+++ b/tests/strace-Y-0123456789.c
@@ -14,6 +14,7 @@
* not crash.
*/
+#include "scno.h"
#include "tests.h"
#include <stdio.h>
@@ -35,7 +36,14 @@ do_default_action(void)
char comm[sizeof(NEW_NAME)];
prctl(PR_GET_NAME, comm);
- printf("%-5d<%s> getppid() = %d\n", pid, comm, ppid);
+ char ocomm[sizeof(NEW_NAME)];
+ strcpy(ocomm, comm);
+
+ printf("%-5d<%s> getppid() = %d<strace>\n", pid, comm, ppid);
+
+ int pfd = syscall(__NR_pidfd_open, ppid, 0, 0, 0, 0, 0);
+ printf("%-5d<%s> pidfd_open(%d<strace>, 0) = %d<pid:%d<strace>>\n",
+ pid, comm, ppid, pfd, ppid);
fflush(stdout);
@@ -46,12 +54,13 @@ do_default_action(void)
pid = getpid();
ppid = getppid();
prctl(PR_GET_NAME, comm);
- printf("%-5d<%s> getppid() = %d\n", pid, comm, ppid);
+ printf("%-5d<%s> getppid() = %d<%s>\n", pid, comm, ppid, ocomm);
strcpy(comm, NEW_NAME);
prctl(PR_SET_NAME, comm);
prctl(PR_GET_NAME, comm);
ppid = getppid();
- printf("%-5d<%s> getppid() = %d\n", pid, comm, ppid);
+ printf("%-5d<%s> getppid() = %d<%s>\n",
+ pid, comm, ppid, ocomm);
fflush(stdout);
char *self_argv[] = { (char *)"unused", (char *)"execve", NULL };
@@ -64,7 +73,8 @@ do_default_action(void)
printf("%-5d<exe> +++ exited with 0 +++\n", child);
ppid = getppid();
- printf("%-5d<%s> getppid() = %d\n", pid, comm, ppid);
+ printf("%-5d<%s> getppid() = %d<strace>\n",
+ pid, comm, ppid);
printf("%-5d<%s> +++ exited with 0 +++\n", pid, comm);
return WEXITSTATUS(status);
}
--
2.31.1
More information about the Strace-devel
mailing list