Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/kernel Add io_read_auxv1 in t_ptrace_wait{, 3, 4, 6, id, pid}
details: https://anonhg.NetBSD.org/src/rev/f2e5a010a695
branches: trunk
changeset: 350887:f2e5a010a695
user: kamil <kamil%NetBSD.org@localhost>
date: Wed Jan 25 17:01:57 2017 +0000
description:
Add io_read_auxv1 in t_ptrace_wait{,3,4,6,id,pid}
io_read_auxv1:
Verify PT_READ_AUXV called for tracee
Sponsored by <The NetBSD Foundation>
diffstat:
tests/kernel/t_ptrace_wait.c | 73 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 71 insertions(+), 2 deletions(-)
diffs (108 lines):
diff -r da502007eae4 -r f2e5a010a695 tests/kernel/t_ptrace_wait.c
--- a/tests/kernel/t_ptrace_wait.c Wed Jan 25 16:11:54 2017 +0000
+++ b/tests/kernel/t_ptrace_wait.c Wed Jan 25 17:01:57 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.60 2017/01/14 19:17:10 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.61 2017/01/25 17:01:57 kamil Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.60 2017/01/14 19:17:10 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.61 2017/01/25 17:01:57 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -37,6 +37,7 @@
#include <sys/sysctl.h>
#include <sys/wait.h>
#include <machine/reg.h>
+#include <elf.h>
#include <err.h>
#include <errno.h>
#include <lwp.h>
@@ -2407,6 +2408,72 @@
TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
}
+ATF_TC(io_read_auxv1);
+ATF_TC_HEAD(io_read_auxv1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_READ_AUXV called for tracee");
+}
+
+ATF_TC_BODY(io_read_auxv1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ AuxInfo ai[100], *aip;
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_READ_AUXV,
+ .piod_offs = 0,
+ .piod_addr = ai,
+ .piod_len = sizeof(ai)
+ };
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read new AUXV from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ printf("Asserting that AUXV length (%zu) is > 0\n", io.piod_len);
+ ATF_REQUIRE(io.piod_len > 0);
+
+ for (aip = ai; aip->a_type != AT_NULL; aip++)
+ printf("a_type=%#llx a_v=%#llx\n",
+ (long long int)aip->a_type, (long long int)aip->a_v);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
ATF_TC(read_d1);
ATF_TC_HEAD(read_d1, tc)
{
@@ -5667,6 +5734,8 @@
ATF_TP_ADD_TC(tp, read_i3);
ATF_TP_ADD_TC(tp, read_i4);
+ ATF_TP_ADD_TC(tp, io_read_auxv1);
+
ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs1);
ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs2);
ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs3);
Home |
Main Index |
Thread Index |
Old Index