git: 6a68c094ed1b - stable/13 - ptrace_test: Add more debug output on test failures
Alex Richardson
arichardson at FreeBSD.org
Wed Mar 17 14:05:28 UTC 2021
The branch stable/13 has been updated by arichardson:
URL: https://cgit.FreeBSD.org/src/commit/?id=6a68c094ed1be74fd5556ac716c8bb12f3564f82
commit 6a68c094ed1be74fd5556ac716c8bb12f3564f82
Author: Alex Richardson <arichardson at FreeBSD.org>
AuthorDate: 2021-03-01 18:49:31 +0000
Commit: Alex Richardson <arichardson at FreeBSD.org>
CommitDate: 2021-03-17 12:23:57 +0000
ptrace_test: Add more debug output on test failures
Mostly automatic, using
`CHILD_REQUIRE\(([^|&\n]*) ==` -> `CHILD_REQUIRE_EQ_INT($1,`
`ATF_REQUIRE\(([^|&\n]*) ==` -> `REQUIRE_EQ_INT($1,` followed by
git-clang-format -f and then manually checking ones that contain ||/&&.
Test Plan:
Still getting the same failure but now it prints
`psr.sr_error (0) == EBADF (9) not met` instead of just failing
without printing the values.
PR: 243605
Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D28887
(cherry picked from commit 96a9e50e63bfcbca7309c012c2c7a477c8826824)
---
tests/sys/kern/ptrace_test.c | 1516 +++++++++++++++++++++---------------------
1 file changed, 770 insertions(+), 746 deletions(-)
diff --git a/tests/sys/kern/ptrace_test.c b/tests/sys/kern/ptrace_test.c
index 5422cce80713..a5655008eaa1 100644
--- a/tests/sys/kern/ptrace_test.c
+++ b/tests/sys/kern/ptrace_test.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sched.h>
#include <semaphore.h>
#include <signal.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -88,22 +89,45 @@ __FBSDID("$FreeBSD$");
* processes. This only works if the parent process is tripped up by
* the early exit and fails some requirement itself.
*/
-#define CHILD_REQUIRE(exp) do { \
- if (!(exp)) \
- child_fail_require(__FILE__, __LINE__, \
- #exp " not met"); \
- } while (0)
+#define CHILD_REQUIRE(exp) do { \
+ if (!(exp)) \
+ child_fail_require(__FILE__, __LINE__, \
+ #exp " not met\n"); \
+} while (0)
+
+#define CHILD_REQUIRE_EQ(actual, expected) do { \
+ __typeof__(expected) _e = expected; \
+ __typeof__(actual) _a = actual; \
+ if (_e != _a) \
+ child_fail_require(__FILE__, __LINE__, #actual \
+ " (%jd) == " #expected " (%jd) not met\n", \
+ (intmax_t)_a, (intmax_t)_e); \
+} while (0)
static __dead2 void
-child_fail_require(const char *file, int line, const char *str)
+child_fail_require(const char *file, int line, const char *fmt, ...)
{
- char buf[128];
+ va_list ap;
+ char buf[1024];
+
+ /* Use write() not fprintf() to avoid possible duplicate output. */
+ snprintf(buf, sizeof(buf), "%s:%d: ", file, line);
+ write(STDERR_FILENO, buf, strlen(buf));
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ write(STDERR_FILENO, buf, strlen(buf));
+ va_end(ap);
- snprintf(buf, sizeof(buf), "%s:%d: %s\n", file, line, str);
- write(2, buf, strlen(buf));
_exit(32);
}
+#define REQUIRE_EQ(actual, expected) do { \
+ __typeof__(expected) _e = expected; \
+ __typeof__(actual) _a = actual; \
+ ATF_REQUIRE_MSG(_e == _a, #actual " (%jd) == " \
+ #expected " (%jd) not met", (intmax_t)_a, (intmax_t)_e); \
+} while (0)
+
static void
trace_me(void)
{
@@ -121,12 +145,12 @@ attach_child(pid_t pid)
pid_t wpid;
int status;
- ATF_REQUIRE(ptrace(PT_ATTACH, pid, NULL, 0) == 0);
+ REQUIRE_EQ(ptrace(PT_ATTACH, pid, NULL, 0), 0);
wpid = waitpid(pid, &status, 0);
- ATF_REQUIRE(wpid == pid);
+ REQUIRE_EQ(wpid, pid);
ATF_REQUIRE(WIFSTOPPED(status));
- ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
}
static void
@@ -152,7 +176,7 @@ wait_for_zombie(pid_t pid)
mib[3] = pid;
len = sizeof(kp);
if (sysctl(mib, nitems(mib), &kp, &len, NULL, 0) == -1) {
- ATF_REQUIRE(errno == ESRCH);
+ REQUIRE_EQ(errno, ESRCH);
break;
}
if (kp.ki_stat == SZOMB)
@@ -183,23 +207,23 @@ ATF_TC_BODY(ptrace__parent_wait_after_trace_me, tc)
/* The first wait() should report the stop from SIGSTOP. */
wpid = waitpid(child, &status, 0);
- ATF_REQUIRE(wpid == child);
+ REQUIRE_EQ(wpid, child);
ATF_REQUIRE(WIFSTOPPED(status));
- ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
/* Continue the child ignoring the SIGSTOP. */
ATF_REQUIRE(ptrace(PT_CONTINUE, child, (caddr_t)1, 0) != -1);
/* The second wait() should report the exit status. */
wpid = waitpid(child, &status, 0);
- ATF_REQUIRE(wpid == child);
+ REQUIRE_EQ(wpid, child);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
/* The child should no longer exist. */
wpid = waitpid(child, &status, 0);
- ATF_REQUIRE(wpid == -1);
- ATF_REQUIRE(errno == ECHILD);
+ REQUIRE_EQ(wpid, -1);
+ REQUIRE_EQ(errno, ECHILD);
}
/*
@@ -216,14 +240,14 @@ ATF_TC_BODY(ptrace__parent_wait_after_attach, tc)
if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
atf_tc_skip("https://bugs.freebsd.org/244055");
- ATF_REQUIRE(pipe(cpipe) == 0);
+ REQUIRE_EQ(pipe(cpipe), 0);
ATF_REQUIRE((child = fork()) != -1);
if (child == 0) {
/* Child process. */
close(cpipe[0]);
/* Wait for the parent to attach. */
- CHILD_REQUIRE(read(cpipe[1], &c, sizeof(c)) == 0);
+ CHILD_REQUIRE_EQ(0, read(cpipe[1], &c, sizeof(c)));
_exit(1);
}
@@ -242,14 +266,14 @@ ATF_TC_BODY(ptrace__parent_wait_after_attach, tc)
/* The second wait() should report the exit status. */
wpid = waitpid(child, &status, 0);
- ATF_REQUIRE(wpid == child);
+ REQUIRE_EQ(wpid, child);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
/* The child should no longer exist. */
wpid = waitpid(child, &status, 0);
- ATF_REQUIRE(wpid == -1);
- ATF_REQUIRE(errno == ECHILD);
+ REQUIRE_EQ(wpid, -1);
+ REQUIRE_EQ(errno, ECHILD);
}
/*
@@ -266,7 +290,7 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_child_debugger, tc)
if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
atf_tc_skip("https://bugs.freebsd.org/239399");
- ATF_REQUIRE(pipe(cpipe) == 0);
+ REQUIRE_EQ(pipe(cpipe), 0);
ATF_REQUIRE((child = fork()) != -1);
if (child == 0) {
@@ -274,13 +298,13 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_child_debugger, tc)
close(cpipe[0]);
/* Wait for parent to be ready. */
- CHILD_REQUIRE(read(cpipe[1], &c, sizeof(c)) == sizeof(c));
+ CHILD_REQUIRE_EQ(read(cpipe[1], &c, sizeof(c)), sizeof(c));
_exit(1);
}
close(cpipe[1]);
- ATF_REQUIRE(pipe(dpipe) == 0);
+ REQUIRE_EQ(pipe(dpipe), 0);
ATF_REQUIRE((debugger = fork()) != -1);
if (debugger == 0) {
@@ -290,22 +314,22 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_child_debugger, tc)
CHILD_REQUIRE(ptrace(PT_ATTACH, child, NULL, 0) != -1);
wpid = waitpid(child, &status, 0);
- CHILD_REQUIRE(wpid == child);
+ CHILD_REQUIRE_EQ(wpid, child);
CHILD_REQUIRE(WIFSTOPPED(status));
- CHILD_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ CHILD_REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
CHILD_REQUIRE(ptrace(PT_CONTINUE, child, (caddr_t)1, 0) != -1);
/* Signal parent that debugger is attached. */
- CHILD_REQUIRE(write(dpipe[1], &c, sizeof(c)) == sizeof(c));
+ CHILD_REQUIRE_EQ(write(dpipe[1], &c, sizeof(c)), sizeof(c));
/* Wait for parent's failed wait. */
- CHILD_REQUIRE(read(dpipe[1], &c, sizeof(c)) == 0);
+ CHILD_REQUIRE_EQ(read(dpipe[1], &c, sizeof(c)), 0);
wpid = waitpid(child, &status, 0);
- CHILD_REQUIRE(wpid == child);
+ CHILD_REQUIRE_EQ(wpid, child);
CHILD_REQUIRE(WIFEXITED(status));
- CHILD_REQUIRE(WEXITSTATUS(status) == 1);
+ CHILD_REQUIRE_EQ(WEXITSTATUS(status), 1);
_exit(0);
}
@@ -314,11 +338,11 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_child_debugger, tc)
/* Parent process. */
/* Wait for the debugger to attach to the child. */
- ATF_REQUIRE(read(dpipe[0], &c, sizeof(c)) == sizeof(c));
+ REQUIRE_EQ(read(dpipe[0], &c, sizeof(c)), sizeof(c));
/* Release the child. */
- ATF_REQUIRE(write(cpipe[0], &c, sizeof(c)) == sizeof(c));
- ATF_REQUIRE(read(cpipe[0], &c, sizeof(c)) == 0);
+ REQUIRE_EQ(write(cpipe[0], &c, sizeof(c)), sizeof(c));
+ REQUIRE_EQ(read(cpipe[0], &c, sizeof(c)), 0);
close(cpipe[0]);
wait_for_zombie(child);
@@ -329,22 +353,22 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_child_debugger, tc)
* until the debugger sees the exit.
*/
wpid = waitpid(child, &status, WNOHANG);
- ATF_REQUIRE(wpid == 0);
+ REQUIRE_EQ(wpid, 0);
/* Signal the debugger to wait for the child. */
close(dpipe[0]);
/* Wait for the debugger. */
wpid = waitpid(debugger, &status, 0);
- ATF_REQUIRE(wpid == debugger);
+ REQUIRE_EQ(wpid, debugger);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 0);
+ REQUIRE_EQ(WEXITSTATUS(status), 0);
/* The child process should now be ready. */
wpid = waitpid(child, &status, WNOHANG);
- ATF_REQUIRE(wpid == child);
+ REQUIRE_EQ(wpid, child);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
}
/*
@@ -360,7 +384,7 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_unrelated_debugger, tc)
int cpipe[2], dpipe[2], status;
char c;
- ATF_REQUIRE(pipe(cpipe) == 0);
+ REQUIRE_EQ(pipe(cpipe), 0);
ATF_REQUIRE((child = fork()) != -1);
if (child == 0) {
@@ -368,13 +392,13 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_unrelated_debugger, tc)
close(cpipe[0]);
/* Wait for parent to be ready. */
- CHILD_REQUIRE(read(cpipe[1], &c, sizeof(c)) == sizeof(c));
+ CHILD_REQUIRE_EQ(read(cpipe[1], &c, sizeof(c)), sizeof(c));
_exit(1);
}
close(cpipe[1]);
- ATF_REQUIRE(pipe(dpipe) == 0);
+ REQUIRE_EQ(pipe(dpipe), 0);
ATF_REQUIRE((debugger = fork()) != -1);
if (debugger == 0) {
@@ -394,22 +418,22 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_unrelated_debugger, tc)
CHILD_REQUIRE(ptrace(PT_ATTACH, child, NULL, 0) != -1);
wpid = waitpid(child, &status, 0);
- CHILD_REQUIRE(wpid == child);
+ CHILD_REQUIRE_EQ(wpid, child);
CHILD_REQUIRE(WIFSTOPPED(status));
- CHILD_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ CHILD_REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
CHILD_REQUIRE(ptrace(PT_CONTINUE, child, (caddr_t)1, 0) != -1);
/* Signal parent that debugger is attached. */
- CHILD_REQUIRE(write(dpipe[1], &c, sizeof(c)) == sizeof(c));
+ CHILD_REQUIRE_EQ(write(dpipe[1], &c, sizeof(c)), sizeof(c));
/* Wait for parent's failed wait. */
- CHILD_REQUIRE(read(dpipe[1], &c, sizeof(c)) == sizeof(c));
+ CHILD_REQUIRE_EQ(read(dpipe[1], &c, sizeof(c)), sizeof(c));
wpid = waitpid(child, &status, 0);
- CHILD_REQUIRE(wpid == child);
+ CHILD_REQUIRE_EQ(wpid, child);
CHILD_REQUIRE(WIFEXITED(status));
- CHILD_REQUIRE(WEXITSTATUS(status) == 1);
+ CHILD_REQUIRE_EQ(WEXITSTATUS(status), 1);
_exit(0);
}
@@ -419,20 +443,20 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_unrelated_debugger, tc)
/* Wait for the debugger parent process to exit. */
wpid = waitpid(debugger, &status, 0);
- ATF_REQUIRE(wpid == debugger);
+ REQUIRE_EQ(wpid, debugger);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 2);
+ REQUIRE_EQ(WEXITSTATUS(status), 2);
/* A WNOHANG wait here should see the non-exited child. */
wpid = waitpid(child, &status, WNOHANG);
- ATF_REQUIRE(wpid == 0);
+ REQUIRE_EQ(wpid, 0);
/* Wait for the debugger to attach to the child. */
- ATF_REQUIRE(read(dpipe[0], &c, sizeof(c)) == sizeof(c));
+ REQUIRE_EQ(read(dpipe[0], &c, sizeof(c)), sizeof(c));
/* Release the child. */
- ATF_REQUIRE(write(cpipe[0], &c, sizeof(c)) == sizeof(c));
- ATF_REQUIRE(read(cpipe[0], &c, sizeof(c)) == 0);
+ REQUIRE_EQ(write(cpipe[0], &c, sizeof(c)), sizeof(c));
+ REQUIRE_EQ(read(cpipe[0], &c, sizeof(c)), 0);
close(cpipe[0]);
wait_for_zombie(child);
@@ -443,20 +467,20 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_unrelated_debugger, tc)
* until the debugger sees the exit.
*/
wpid = waitpid(child, &status, WNOHANG);
- ATF_REQUIRE(wpid == 0);
+ REQUIRE_EQ(wpid, 0);
/* Signal the debugger to wait for the child. */
- ATF_REQUIRE(write(dpipe[0], &c, sizeof(c)) == sizeof(c));
+ REQUIRE_EQ(write(dpipe[0], &c, sizeof(c)), sizeof(c));
/* Wait for the debugger. */
- ATF_REQUIRE(read(dpipe[0], &c, sizeof(c)) == 0);
+ REQUIRE_EQ(read(dpipe[0], &c, sizeof(c)), 0);
close(dpipe[0]);
/* The child process should now be ready. */
wpid = waitpid(child, &status, WNOHANG);
- ATF_REQUIRE(wpid == child);
+ REQUIRE_EQ(wpid, child);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
}
/*
@@ -472,11 +496,11 @@ ATF_TC_BODY(ptrace__parent_exits_before_child, tc)
if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
atf_tc_skip("https://bugs.freebsd.org/244056");
- ATF_REQUIRE(pipe(cpipe1) == 0);
- ATF_REQUIRE(pipe(cpipe2) == 0);
- ATF_REQUIRE(pipe(gcpipe) == 0);
+ REQUIRE_EQ(pipe(cpipe1), 0);
+ REQUIRE_EQ(pipe(cpipe2), 0);
+ REQUIRE_EQ(pipe(gcpipe), 0);
- ATF_REQUIRE(procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL) == 0);
+ REQUIRE_EQ(procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL), 0);
ATF_REQUIRE((child = fork()) != -1);
if (child == 0) {
@@ -496,31 +520,31 @@ ATF_TC_BODY(ptrace__parent_exits_before_child, tc)
_exit(status);
}
- ATF_REQUIRE(read(cpipe1[0], &gchild, sizeof(gchild)) == sizeof(gchild));
+ REQUIRE_EQ(read(cpipe1[0], &gchild, sizeof(gchild)), sizeof(gchild));
- ATF_REQUIRE(ptrace(PT_ATTACH, gchild, NULL, 0) == 0);
+ REQUIRE_EQ(ptrace(PT_ATTACH, gchild, NULL, 0), 0);
status = 0;
- ATF_REQUIRE(write(cpipe2[1], &status, sizeof(status)) ==
- sizeof(status));
- ATF_REQUIRE(waitpid(child, &status, 0) == child);
- ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+ REQUIRE_EQ(write(cpipe2[1], &status, sizeof(status)), sizeof(status));
+ REQUIRE_EQ(waitpid(child, &status, 0), child);
+ ATF_REQUIRE(WIFEXITED(status));
+ REQUIRE_EQ(WEXITSTATUS(status), 0);
status = 0;
- ATF_REQUIRE(write(gcpipe[1], &status, sizeof(status)) ==
- sizeof(status));
- ATF_REQUIRE(waitpid(gchild, &status, 0) == gchild);
+ REQUIRE_EQ(write(gcpipe[1], &status, sizeof(status)), sizeof(status));
+ REQUIRE_EQ(waitpid(gchild, &status, 0), gchild);
ATF_REQUIRE(WIFSTOPPED(status));
- ATF_REQUIRE(ptrace(PT_DETACH, gchild, (caddr_t)1, 0) == 0);
- ATF_REQUIRE(waitpid(gchild, &status, 0) == gchild);
- ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 0);
-
- ATF_REQUIRE(close(cpipe1[0]) == 0);
- ATF_REQUIRE(close(cpipe1[1]) == 0);
- ATF_REQUIRE(close(cpipe2[0]) == 0);
- ATF_REQUIRE(close(cpipe2[1]) == 0);
- ATF_REQUIRE(close(gcpipe[0]) == 0);
- ATF_REQUIRE(close(gcpipe[1]) == 0);
+ REQUIRE_EQ(ptrace(PT_DETACH, gchild, (caddr_t)1, 0), 0);
+ REQUIRE_EQ(waitpid(gchild, &status, 0), gchild);
+ ATF_REQUIRE(WIFEXITED(status));
+ REQUIRE_EQ(WEXITSTATUS(status), 0);
+
+ REQUIRE_EQ(close(cpipe1[0]), 0);
+ REQUIRE_EQ(close(cpipe1[1]), 0);
+ REQUIRE_EQ(close(cpipe2[0]), 0);
+ REQUIRE_EQ(close(cpipe2[1]), 0);
+ REQUIRE_EQ(close(gcpipe[0]), 0);
+ REQUIRE_EQ(close(gcpipe[1]), 0);
}
/*
@@ -543,9 +567,9 @@ follow_fork_parent(bool use_vfork)
_exit(2);
wpid = waitpid(fpid, &status, 0);
- CHILD_REQUIRE(wpid == fpid);
+ CHILD_REQUIRE_EQ(wpid, fpid);
CHILD_REQUIRE(WIFEXITED(status));
- CHILD_REQUIRE(WEXITSTATUS(status) == 2);
+ CHILD_REQUIRE_EQ(WEXITSTATUS(status), 2);
_exit(1);
}
@@ -585,23 +609,23 @@ handle_fork_events(pid_t parent, struct ptrace_lwpinfo *ppl)
(PL_FLAG_FORKED | PL_FLAG_CHILD));
if (pl.pl_flags & PL_FLAG_CHILD) {
ATF_REQUIRE(wpid != parent);
- ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
ATF_REQUIRE(!fork_reported[1]);
if (child == -1)
child = wpid;
else
- ATF_REQUIRE(child == wpid);
+ REQUIRE_EQ(child, wpid);
if (ppl != NULL)
ppl[1] = pl;
fork_reported[1] = true;
} else {
- ATF_REQUIRE(wpid == parent);
- ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP);
+ REQUIRE_EQ(wpid, parent);
+ REQUIRE_EQ(WSTOPSIG(status), SIGTRAP);
ATF_REQUIRE(!fork_reported[0]);
if (child == -1)
child = pl.pl_child_pid;
else
- ATF_REQUIRE(child == pl.pl_child_pid);
+ REQUIRE_EQ(child, pl.pl_child_pid);
if (ppl != NULL)
ppl[0] = pl;
fork_reported[0] = true;
@@ -633,9 +657,9 @@ ATF_TC_BODY(ptrace__follow_fork_both_attached, tc)
/* The first wait() should report the stop from SIGSTOP. */
wpid = waitpid(children[0], &status, 0);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFSTOPPED(status));
- ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
ATF_REQUIRE(ptrace(PT_FOLLOW_FORK, children[0], NULL, 1) != -1);
@@ -653,18 +677,18 @@ ATF_TC_BODY(ptrace__follow_fork_both_attached, tc)
* grandchild should report its exit first to the debugger.
*/
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[1]);
+ REQUIRE_EQ(wpid, children[1]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 2);
+ REQUIRE_EQ(WEXITSTATUS(status), 2);
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
wpid = wait(&status);
- ATF_REQUIRE(wpid == -1);
- ATF_REQUIRE(errno == ECHILD);
+ REQUIRE_EQ(wpid, -1);
+ REQUIRE_EQ(errno, ECHILD);
}
/*
@@ -689,9 +713,9 @@ ATF_TC_BODY(ptrace__follow_fork_child_detached, tc)
/* The first wait() should report the stop from SIGSTOP. */
wpid = waitpid(children[0], &status, 0);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFSTOPPED(status));
- ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
ATF_REQUIRE(ptrace(PT_FOLLOW_FORK, children[0], NULL, 1) != -1);
@@ -709,13 +733,13 @@ ATF_TC_BODY(ptrace__follow_fork_child_detached, tc)
* child.
*/
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
wpid = wait(&status);
- ATF_REQUIRE(wpid == -1);
- ATF_REQUIRE(errno == ECHILD);
+ REQUIRE_EQ(wpid, -1);
+ REQUIRE_EQ(errno, ECHILD);
}
/*
@@ -740,9 +764,9 @@ ATF_TC_BODY(ptrace__follow_fork_parent_detached, tc)
/* The first wait() should report the stop from SIGSTOP. */
wpid = waitpid(children[0], &status, 0);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFSTOPPED(status));
- ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
ATF_REQUIRE(ptrace(PT_FOLLOW_FORK, children[0], NULL, 1) != -1);
@@ -764,18 +788,18 @@ ATF_TC_BODY(ptrace__follow_fork_parent_detached, tc)
* after the grandchild.
*/
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[1]);
+ REQUIRE_EQ(wpid, children[1]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 2);
+ REQUIRE_EQ(WEXITSTATUS(status), 2);
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
wpid = wait(&status);
- ATF_REQUIRE(wpid == -1);
- ATF_REQUIRE(errno == ECHILD);
+ REQUIRE_EQ(wpid, -1);
+ REQUIRE_EQ(errno, ECHILD);
}
static void
@@ -792,10 +816,10 @@ attach_fork_parent(int cpipe[2])
/* Send the pid of the disassociated child to the debugger. */
fpid = getpid();
- CHILD_REQUIRE(write(cpipe[1], &fpid, sizeof(fpid)) == sizeof(fpid));
+ CHILD_REQUIRE_EQ(write(cpipe[1], &fpid, sizeof(fpid)), sizeof(fpid));
/* Wait for the debugger to attach. */
- CHILD_REQUIRE(read(cpipe[1], &fpid, sizeof(fpid)) == 0);
+ CHILD_REQUIRE_EQ(read(cpipe[1], &fpid, sizeof(fpid)), 0);
}
/*
@@ -813,7 +837,7 @@ ATF_TC_BODY(ptrace__follow_fork_both_attached_unrelated_debugger, tc)
if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
atf_tc_skip("https://bugs.freebsd.org/239397");
- ATF_REQUIRE(pipe(cpipe) == 0);
+ REQUIRE_EQ(pipe(cpipe), 0);
ATF_REQUIRE((fpid = fork()) != -1);
if (fpid == 0) {
attach_fork_parent(cpipe);
@@ -825,12 +849,12 @@ ATF_TC_BODY(ptrace__follow_fork_both_attached_unrelated_debugger, tc)
/* Wait for the direct child to exit. */
wpid = waitpid(fpid, &status, 0);
- ATF_REQUIRE(wpid == fpid);
+ REQUIRE_EQ(wpid, fpid);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 3);
+ REQUIRE_EQ(WEXITSTATUS(status), 3);
/* Read the pid of the fork parent. */
- ATF_REQUIRE(read(cpipe[0], &children[0], sizeof(children[0])) ==
+ REQUIRE_EQ(read(cpipe[0], &children[0], sizeof(children[0])),
sizeof(children[0]));
/* Attach to the fork parent. */
@@ -855,18 +879,18 @@ ATF_TC_BODY(ptrace__follow_fork_both_attached_unrelated_debugger, tc)
* so the child should report its exit first to the debugger.
*/
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[1]);
+ REQUIRE_EQ(wpid, children[1]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 2);
+ REQUIRE_EQ(WEXITSTATUS(status), 2);
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
wpid = wait(&status);
- ATF_REQUIRE(wpid == -1);
- ATF_REQUIRE(errno == ECHILD);
+ REQUIRE_EQ(wpid, -1);
+ REQUIRE_EQ(errno, ECHILD);
}
/*
@@ -884,7 +908,7 @@ ATF_TC_BODY(ptrace__follow_fork_child_detached_unrelated_debugger, tc)
if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
atf_tc_skip("https://bugs.freebsd.org/239292");
- ATF_REQUIRE(pipe(cpipe) == 0);
+ REQUIRE_EQ(pipe(cpipe), 0);
ATF_REQUIRE((fpid = fork()) != -1);
if (fpid == 0) {
attach_fork_parent(cpipe);
@@ -896,12 +920,12 @@ ATF_TC_BODY(ptrace__follow_fork_child_detached_unrelated_debugger, tc)
/* Wait for the direct child to exit. */
wpid = waitpid(fpid, &status, 0);
- ATF_REQUIRE(wpid == fpid);
+ REQUIRE_EQ(wpid, fpid);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 3);
+ REQUIRE_EQ(WEXITSTATUS(status), 3);
/* Read the pid of the fork parent. */
- ATF_REQUIRE(read(cpipe[0], &children[0], sizeof(children[0])) ==
+ REQUIRE_EQ(read(cpipe[0], &children[0], sizeof(children[0])),
sizeof(children[0]));
/* Attach to the fork parent. */
@@ -926,13 +950,13 @@ ATF_TC_BODY(ptrace__follow_fork_child_detached_unrelated_debugger, tc)
* parent.
*/
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
wpid = wait(&status);
- ATF_REQUIRE(wpid == -1);
- ATF_REQUIRE(errno == ECHILD);
+ REQUIRE_EQ(wpid, -1);
+ REQUIRE_EQ(errno, ECHILD);
}
/*
@@ -950,7 +974,7 @@ ATF_TC_BODY(ptrace__follow_fork_parent_detached_unrelated_debugger, tc)
if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
atf_tc_skip("https://bugs.freebsd.org/239425");
- ATF_REQUIRE(pipe(cpipe) == 0);
+ REQUIRE_EQ(pipe(cpipe), 0);
ATF_REQUIRE((fpid = fork()) != -1);
if (fpid == 0) {
attach_fork_parent(cpipe);
@@ -962,12 +986,12 @@ ATF_TC_BODY(ptrace__follow_fork_parent_detached_unrelated_debugger, tc)
/* Wait for the direct child to exit. */
wpid = waitpid(fpid, &status, 0);
- ATF_REQUIRE(wpid == fpid);
+ REQUIRE_EQ(wpid, fpid);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 3);
+ REQUIRE_EQ(WEXITSTATUS(status), 3);
/* Read the pid of the fork parent. */
- ATF_REQUIRE(read(cpipe[0], &children[0], sizeof(children[0])) ==
+ REQUIRE_EQ(read(cpipe[0], &children[0], sizeof(children[0])),
sizeof(children[0]));
/* Attach to the fork parent. */
@@ -992,13 +1016,13 @@ ATF_TC_BODY(ptrace__follow_fork_parent_detached_unrelated_debugger, tc)
* the child.
*/
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[1]);
+ REQUIRE_EQ(wpid, children[1]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 2);
+ REQUIRE_EQ(WEXITSTATUS(status), 2);
wpid = wait(&status);
- ATF_REQUIRE(wpid == -1);
- ATF_REQUIRE(errno == ECHILD);
+ REQUIRE_EQ(wpid, -1);
+ REQUIRE_EQ(errno, ECHILD);
}
/*
@@ -1015,8 +1039,7 @@ ATF_TC_BODY(ptrace__getppid, tc)
if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
atf_tc_skip("https://bugs.freebsd.org/240510");
-
- ATF_REQUIRE(pipe(cpipe) == 0);
+ REQUIRE_EQ(pipe(cpipe), 0);
ATF_REQUIRE((child = fork()) != -1);
if (child == 0) {
@@ -1024,7 +1047,7 @@ ATF_TC_BODY(ptrace__getppid, tc)
close(cpipe[0]);
/* Wait for parent to be ready. */
- CHILD_REQUIRE(read(cpipe[1], &c, sizeof(c)) == sizeof(c));
+ CHILD_REQUIRE_EQ(read(cpipe[1], &c, sizeof(c)), sizeof(c));
/* Report the parent PID to the parent. */
ppid = getppid();
@@ -1035,7 +1058,7 @@ ATF_TC_BODY(ptrace__getppid, tc)
}
close(cpipe[1]);
- ATF_REQUIRE(pipe(dpipe) == 0);
+ REQUIRE_EQ(pipe(dpipe), 0);
ATF_REQUIRE((debugger = fork()) != -1);
if (debugger == 0) {
@@ -1045,20 +1068,20 @@ ATF_TC_BODY(ptrace__getppid, tc)
CHILD_REQUIRE(ptrace(PT_ATTACH, child, NULL, 0) != -1);
wpid = waitpid(child, &status, 0);
- CHILD_REQUIRE(wpid == child);
+ CHILD_REQUIRE_EQ(wpid, child);
CHILD_REQUIRE(WIFSTOPPED(status));
- CHILD_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ CHILD_REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
CHILD_REQUIRE(ptrace(PT_CONTINUE, child, (caddr_t)1, 0) != -1);
/* Signal parent that debugger is attached. */
- CHILD_REQUIRE(write(dpipe[1], &c, sizeof(c)) == sizeof(c));
+ CHILD_REQUIRE_EQ(write(dpipe[1], &c, sizeof(c)), sizeof(c));
/* Wait for traced child to exit. */
wpid = waitpid(child, &status, 0);
- CHILD_REQUIRE(wpid == child);
+ CHILD_REQUIRE_EQ(wpid, child);
CHILD_REQUIRE(WIFEXITED(status));
- CHILD_REQUIRE(WEXITSTATUS(status) == 1);
+ CHILD_REQUIRE_EQ(WEXITSTATUS(status), 1);
_exit(0);
}
@@ -1067,28 +1090,28 @@ ATF_TC_BODY(ptrace__getppid, tc)
/* Parent process. */
/* Wait for the debugger to attach to the child. */
- ATF_REQUIRE(read(dpipe[0], &c, sizeof(c)) == sizeof(c));
+ REQUIRE_EQ(read(dpipe[0], &c, sizeof(c)), sizeof(c));
/* Release the child. */
- ATF_REQUIRE(write(cpipe[0], &c, sizeof(c)) == sizeof(c));
+ REQUIRE_EQ(write(cpipe[0], &c, sizeof(c)), sizeof(c));
/* Read the parent PID from the child. */
- ATF_REQUIRE(read(cpipe[0], &ppid, sizeof(ppid)) == sizeof(ppid));
+ REQUIRE_EQ(read(cpipe[0], &ppid, sizeof(ppid)), sizeof(ppid));
close(cpipe[0]);
- ATF_REQUIRE(ppid == getpid());
+ REQUIRE_EQ(ppid, getpid());
/* Wait for the debugger. */
wpid = waitpid(debugger, &status, 0);
- ATF_REQUIRE(wpid == debugger);
+ REQUIRE_EQ(wpid, debugger);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 0);
+ REQUIRE_EQ(WEXITSTATUS(status), 0);
/* The child process should now be ready. */
wpid = waitpid(child, &status, WNOHANG);
- ATF_REQUIRE(wpid == child);
+ REQUIRE_EQ(wpid, child);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
}
/*
@@ -1113,9 +1136,9 @@ ATF_TC_BODY(ptrace__new_child_pl_syscall_code_fork, tc)
/* The first wait() should report the stop from SIGSTOP. */
wpid = waitpid(children[0], &status, 0);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFSTOPPED(status));
- ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
ATF_REQUIRE(ptrace(PT_FOLLOW_FORK, children[0], NULL, 1) != -1);
@@ -1128,9 +1151,9 @@ ATF_TC_BODY(ptrace__new_child_pl_syscall_code_fork, tc)
ATF_REQUIRE((pl[0].pl_flags & PL_FLAG_SCX) != 0);
ATF_REQUIRE((pl[1].pl_flags & PL_FLAG_SCX) != 0);
- ATF_REQUIRE(pl[0].pl_syscall_code == SYS_fork);
- ATF_REQUIRE(pl[0].pl_syscall_code == pl[1].pl_syscall_code);
- ATF_REQUIRE(pl[0].pl_syscall_narg == pl[1].pl_syscall_narg);
+ REQUIRE_EQ(pl[0].pl_syscall_code, SYS_fork);
+ REQUIRE_EQ(pl[0].pl_syscall_code, pl[1].pl_syscall_code);
+ REQUIRE_EQ(pl[0].pl_syscall_narg, pl[1].pl_syscall_narg);
ATF_REQUIRE(ptrace(PT_CONTINUE, children[0], (caddr_t)1, 0) != -1);
ATF_REQUIRE(ptrace(PT_CONTINUE, children[1], (caddr_t)1, 0) != -1);
@@ -1140,18 +1163,18 @@ ATF_TC_BODY(ptrace__new_child_pl_syscall_code_fork, tc)
* grandchild should report its exit first to the debugger.
*/
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[1]);
+ REQUIRE_EQ(wpid, children[1]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 2);
+ REQUIRE_EQ(WEXITSTATUS(status), 2);
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
wpid = wait(&status);
- ATF_REQUIRE(wpid == -1);
- ATF_REQUIRE(errno == ECHILD);
+ REQUIRE_EQ(wpid, -1);
+ REQUIRE_EQ(errno, ECHILD);
}
/*
@@ -1176,9 +1199,9 @@ ATF_TC_BODY(ptrace__new_child_pl_syscall_code_vfork, tc)
/* The first wait() should report the stop from SIGSTOP. */
wpid = waitpid(children[0], &status, 0);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFSTOPPED(status));
- ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
ATF_REQUIRE(ptrace(PT_FOLLOW_FORK, children[0], NULL, 1) != -1);
@@ -1191,9 +1214,9 @@ ATF_TC_BODY(ptrace__new_child_pl_syscall_code_vfork, tc)
ATF_REQUIRE((pl[0].pl_flags & PL_FLAG_SCX) != 0);
ATF_REQUIRE((pl[1].pl_flags & PL_FLAG_SCX) != 0);
- ATF_REQUIRE(pl[0].pl_syscall_code == SYS_vfork);
- ATF_REQUIRE(pl[0].pl_syscall_code == pl[1].pl_syscall_code);
- ATF_REQUIRE(pl[0].pl_syscall_narg == pl[1].pl_syscall_narg);
+ REQUIRE_EQ(pl[0].pl_syscall_code, SYS_vfork);
+ REQUIRE_EQ(pl[0].pl_syscall_code, pl[1].pl_syscall_code);
+ REQUIRE_EQ(pl[0].pl_syscall_narg, pl[1].pl_syscall_narg);
ATF_REQUIRE(ptrace(PT_CONTINUE, children[0], (caddr_t)1, 0) != -1);
ATF_REQUIRE(ptrace(PT_CONTINUE, children[1], (caddr_t)1, 0) != -1);
@@ -1203,18 +1226,18 @@ ATF_TC_BODY(ptrace__new_child_pl_syscall_code_vfork, tc)
* grandchild should report its exit first to the debugger.
*/
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[1]);
+ REQUIRE_EQ(wpid, children[1]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 2);
+ REQUIRE_EQ(WEXITSTATUS(status), 2);
wpid = wait(&status);
- ATF_REQUIRE(wpid == children[0]);
+ REQUIRE_EQ(wpid, children[0]);
ATF_REQUIRE(WIFEXITED(status));
- ATF_REQUIRE(WEXITSTATUS(status) == 1);
+ REQUIRE_EQ(WEXITSTATUS(status), 1);
wpid = wait(&status);
- ATF_REQUIRE(wpid == -1);
- ATF_REQUIRE(errno == ECHILD);
+ REQUIRE_EQ(wpid, -1);
+ REQUIRE_EQ(errno, ECHILD);
}
static void *
@@ -1229,8 +1252,8 @@ simple_thread_main(void)
{
pthread_t thread;
- CHILD_REQUIRE(pthread_create(&thread, NULL, simple_thread, NULL) == 0);
- CHILD_REQUIRE(pthread_join(thread, NULL) == 0);
+ CHILD_REQUIRE_EQ(pthread_create(&thread, NULL, simple_thread, NULL), 0);
+ CHILD_REQUIRE_EQ(pthread_join(thread, NULL), 0);
exit(1);
}
@@ -1254,9 +1277,9 @@ ATF_TC_BODY(ptrace__new_child_pl_syscall_code_thread, tc)
/* The first wait() should report the stop from SIGSTOP. */
wpid = waitpid(fpid, &status, 0);
- ATF_REQUIRE(wpid == fpid);
+ REQUIRE_EQ(wpid, fpid);
ATF_REQUIRE(WIFSTOPPED(status));
- ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+ REQUIRE_EQ(WSTOPSIG(status), SIGSTOP);
ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl,
sizeof(pl)) != -1);
@@ -1277,10 +1300,10 @@ ATF_TC_BODY(ptrace__new_child_pl_syscall_code_thread, tc)
*/
for (;;) {
wpid = waitpid(fpid, &status, 0);
- ATF_REQUIRE(wpid == fpid);
+ REQUIRE_EQ(wpid, fpid);
ATF_REQUIRE(WIFSTOPPED(status));
- ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP);
-
+ REQUIRE_EQ(WSTOPSIG(status), SIGTRAP);
+
ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl,
sizeof(pl)) != -1);
ATF_REQUIRE((pl.pl_flags & PL_FLAG_SCX) != 0);
@@ -1289,27 +1312,27 @@ ATF_TC_BODY(ptrace__new_child_pl_syscall_code_thread, tc)
/* New thread seen. */
break;
- ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0);
*** 2629 LINES SKIPPED ***
More information about the dev-commits-src-all
mailing list