Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/sys Add a new ATF ptrace(2) test...
details: https://anonhg.NetBSD.org/src/rev/dd1ce2561695
branches: trunk
changeset: 319082:dd1ce2561695
user: kamil <kamil%NetBSD.org@localhost>
date: Wed May 16 01:27:27 2018 +0000
description:
Add a new ATF ptrace(2) test: traceme_vfork_breakpoint
Verify software breakpoint in a vfork(2)ed child.
The expected behavior is not to route this signal to the parent, even if
that parent is a tracer. The parent cannot handle it and it would lead to
the deadlock.
This test passes correctly.
Sponsored by <The NetBSD Foundation>
diffstat:
tests/lib/libc/sys/t_ptrace_wait.c | 49 ++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 2 deletions(-)
diffs (77 lines):
diff -r 50169d528b73 -r dd1ce2561695 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c Wed May 16 00:42:15 2018 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c Wed May 16 01:27:27 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.40 2018/05/16 00:42:15 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.41 2018/05/16 01:27:27 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.40 2018/05/16 00:42:15 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.41 2018/05/16 01:27:27 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -456,6 +456,49 @@
/// ----------------------------------------------------------------------------
+ATF_TC(traceme_vfork_breakpoint);
+ATF_TC_HEAD(traceme_vfork_breakpoint, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify software breakpoint in a vfork(2)ed child");
+}
+
+ATF_TC_BODY(traceme_vfork_breakpoint, tc)
+{
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ DPRINTF("Before forking process PID=%d\n", getpid());
+ SYSCALL_REQUIRE((child = vfork()) != -1);
+ if (child == 0) {
+ DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ DPRINTF("Before executing a software breakpoint\n");
+#ifdef PTRACE_BREAKPOINT_ASM
+ PTRACE_BREAKPOINT_ASM;
+#else
+ /* port me */
+#endif
+
+ /* NOTREACHED */
+ FORKEE_ASSERTX(0 && "This shall not be reached");
+ }
+ DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_signaled(status, SIGTRAP, 1);
+
+ DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+/// ----------------------------------------------------------------------------
+
#if defined(TWAIT_HAVE_PID)
ATF_TC(attach1);
ATF_TC_HEAD(attach1, tc)
@@ -6923,6 +6966,8 @@
ATF_TP_ADD_TC(tp, traceme_vfork_raise4);
ATF_TP_ADD_TC(tp, traceme_vfork_raise5);
+ ATF_TP_ADD_TC(tp, traceme_vfork_breakpoint);
+
ATF_TP_ADD_TC_HAVE_PID(tp, attach1);
ATF_TP_ADD_TC_HAVE_PID(tp, attach2);
ATF_TP_ADD_TC(tp, attach3);
Home |
Main Index |
Thread Index |
Old Index