[PATCH] add -Y test for waitid
SuHsueyu
anolasc13 at gmail.com
Tue Mar 15 17:31:55 UTC 2022
---
GSoC microproject. Try to add -Y test for waitid.
tests/Makefile.am | 1 +
tests/gen_tests.in | 1 +
tests/pure_executables.list | 1 +
tests/waitid-Y.c | 2 ++
tests/waitid.c | 35 +++++++++++++++++++----------------
5 files changed, 24 insertions(+), 16 deletions(-)
create mode 100644 tests/waitid-Y.c
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cd7e84cb7..4ece0cde3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -372,6 +372,7 @@ check_PROGRAMS = $(PURE_EXECUTABLES) \
vfork-f \
wait4-v \
waitid-v \
+ waitid-Y \
xet_robust_list--pidns-translation \
xetpgid--pidns-translation \
xetpriority--pidns-translation \
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index b98a733a0..1630edd50 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -1050,6 +1050,7 @@ wait4 -esignal=none
wait4-v -v -e signal=none -e trace=wait4
waitid -esignal=none
waitid-v -v -e signal=none -e trace=waitid
+waitid-Y -Y -e signal=none -e trace=waitid
waitpid -a28
xattr -a22 -e trace=getxattr,fgetxattr,lgetxattr,setxattr,fsetxattr,lsetxattr,listxattr,flistxattr,llistxattr,removexattr,fremovexattr,lremovexattr
xattr-strings -a22 -s 4 -e trace=fsetxattr
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index fe02fabb7..ff5939df1 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -756,6 +756,7 @@ vhangup
vmsplice
wait4
waitid
+waitid-Y
waitpid
xattr
xattr-strings
diff --git a/tests/waitid-Y.c b/tests/waitid-Y.c
new file mode 100644
index 000000000..74d7dcff8
--- /dev/null
+++ b/tests/waitid-Y.c
@@ -0,0 +1,2 @@
+#define MY_COMM "<waitid-Y>"
+#include "waitid.c"
diff --git a/tests/waitid.c b/tests/waitid.c
index 2ca81e921..cef0194d0 100644
--- a/tests/waitid.c
+++ b/tests/waitid.c
@@ -18,6 +18,10 @@
#include "kernel_rusage.h"
#include "scno.h"
+#ifndef MY_COMM
+# define MY_COMM ""
+#endif
+
static const char *
sprint_rusage(const kernel_rusage_t *const ru)
{
@@ -103,13 +107,14 @@ sprint_siginfo(const siginfo_t *const si, const char *const status_text)
snprintf(buf, sizeof(buf),
"{si_signo=SIGCHLD"
", si_code=%s"
- ", si_pid=%d"
+ ", si_pid=%d%s"
", si_uid=%d"
", si_status=%s"
", si_utime=%llu"
", si_stime=%llu}",
si_code_2_name(si->si_code),
si->si_pid,
+ MY_COMM,
si->si_uid,
status_text,
zero_extend_signed_to_ull(si->si_utime),
@@ -165,23 +170,23 @@ main(void)
if (do_waitid(P_PID, pid, 0, WNOHANG|WEXITED, 0))
perror_msg_and_fail("waitid #1");
- tprintf("waitid(P_PID, %d, NULL, WNOHANG|WEXITED, NULL) = 0\n", pid);
+ tprintf("waitid(P_PID, %d%s, NULL, WNOHANG|WEXITED, NULL) = 0\n", pid, MY_COMM);
TAIL_ALLOC_OBJECT_CONST_PTR(siginfo_t, sinfo);
memset(sinfo, 0, sizeof(*sinfo));
TAIL_ALLOC_OBJECT_CONST_PTR(kernel_rusage_t, rusage);
if (do_waitid(P_PID, pid, sinfo, WNOHANG|WEXITED|WSTOPPED, rusage))
perror_msg_and_fail("waitid #2");
- tprintf("waitid(P_PID, %d, {}, WNOHANG|WEXITED|WSTOPPED, %s) = 0\n",
- pid, sprint_rusage(rusage));
+ tprintf("waitid(P_PID, %d%s, {}, WNOHANG|WEXITED|WSTOPPED, %s) = 0\n",
+ pid, MY_COMM, sprint_rusage(rusage));
assert(write(1, "", 1) == 1);
(void) close(1);
if (do_waitid(P_PID, pid, sinfo, WEXITED, rusage))
perror_msg_and_fail("waitid #3");
- tprintf("waitid(P_PID, %d, %s, WEXITED, %s) = 0\n",
- pid, sprint_siginfo(sinfo, "42"), sprint_rusage(rusage));
+ tprintf("waitid(P_PID, %d%s, %s, WEXITED, %s) = 0\n",
+ pid, MY_COMM, sprint_siginfo(sinfo, "42"), sprint_rusage(rusage));
pid = fork();
if (pid < 0)
@@ -194,8 +199,8 @@ main(void)
if (do_waitid(P_PID, pid, sinfo, WEXITED, rusage))
perror_msg_and_fail("waitid #4");
- tprintf("waitid(P_PID, %d, %s, WEXITED, %s) = 0\n",
- pid, sprint_siginfo(sinfo, "SIGUSR1"), sprint_rusage(rusage));
+ tprintf("waitid(P_PID, %d%s, %s, WEXITED, %s) = 0\n",
+ pid, MY_COMM, sprint_siginfo(sinfo, "SIGUSR1"), sprint_rusage(rusage));
if (pipe(fds))
perror_msg_and_fail("pipe");
@@ -215,8 +220,8 @@ main(void)
if (do_waitid(P_PID, pid, sinfo, WSTOPPED, rusage))
perror_msg_and_fail("waitid #5");
- tprintf("waitid(P_PID, %d, %s, WSTOPPED, %s) = 0\n",
- pid, sprint_siginfo(sinfo, "SIGSTOP"), sprint_rusage(rusage));
+ tprintf("waitid(P_PID, %d%s, %s, WSTOPPED, %s) = 0\n",
+ pid, MY_COMM, sprint_siginfo(sinfo, "SIGSTOP"), sprint_rusage(rusage));
if (kill(pid, SIGCONT))
perror_msg_and_fail("kill(SIGCONT)");
@@ -224,8 +229,8 @@ main(void)
#if defined WCONTINUED
if (do_waitid(P_PID, pid, sinfo, WCONTINUED, rusage))
perror_msg_and_fail("waitid #6");
- tprintf("waitid(P_PID, %d, %s, WCONTINUED, %s) = 0\n",
- pid, sprint_siginfo(sinfo, "SIGCONT"), sprint_rusage(rusage));
+ tprintf("waitid(P_PID, %d%s, %s, WCONTINUED, %s) = 0\n",
+ pid, MY_COMM, sprint_siginfo(sinfo, "SIGCONT"), sprint_rusage(rusage));
#endif /* WCONTINUED */
assert(write(1, "", 1) == 1);
@@ -233,8 +238,8 @@ main(void)
if (do_waitid(P_PID, pid, sinfo, WEXITED, rusage))
perror_msg_and_fail("waitid #7");
- tprintf("waitid(P_PID, %d, %s, WEXITED, %s) = 0\n",
- pid, sprint_siginfo(sinfo, "0"), sprint_rusage(rusage));
+ tprintf("waitid(P_PID, %d%s, %s, WEXITED, %s) = 0\n",
+ pid, MY_COMM, sprint_siginfo(sinfo, "0"), sprint_rusage(rusage));
pid_t pgid = getpgid(pid);
long pgrc = do_waitid(P_PGID, pgid, sinfo, WEXITED, rusage);
@@ -245,8 +250,6 @@ main(void)
tprintf("waitid(P_ALL, -1, %p, WEXITED|WSTOPPED, %p)"
" = %ld %s (%m)\n", sinfo, rusage, rc, errno2name());
-
-
tprintf("%s\n", "+++ exited with 0 +++");
return 0;
}
--
2.25.1
More information about the Strace-devel
mailing list