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 extra asserts in three A...
details: https://anonhg.NetBSD.org/src/rev/24da7d3b0901
branches: trunk
changeset: 319086:24da7d3b0901
user: kamil <kamil%NetBSD.org@localhost>
date: Wed May 16 03:52:35 2018 +0000
description:
Add extra asserts in three ATF ptrace(2) tests
In traceme* tests after validate_status_stopped() include additional check
the verify the received signal with PT_GET_SIGINFO.
All tests passes.
Sponsored by <The NetBSD Foundation>
diffstat:
tests/lib/libc/sys/t_ptrace_wait.c | 51 ++++++++++++++++++++++++++++++++++++-
1 files changed, 49 insertions(+), 2 deletions(-)
diffs (107 lines):
diff -r f99ea3188ace -r 24da7d3b0901 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c Wed May 16 03:18:38 2018 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c Wed May 16 03:52:35 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.44 2018/05/16 03:18:38 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.45 2018/05/16 03:52:35 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.44 2018/05/16 03:18:38 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.45 2018/05/16 03:52:35 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -93,6 +93,9 @@
int status;
#endif
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
DPRINTF("Before forking process PID=%d\n", getpid());
SYSCALL_REQUIRE((child = fork()) != -1);
if (child == 0) {
@@ -123,6 +126,20 @@
default:
validate_status_stopped(status, sigval);
+ DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for "
+ "child\n");
+ SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info,
+ sizeof(info)) != -1);
+
+ DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ DPRINTF("Signal properties: si_signo=%#x si_code=%#x "
+ "si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
+
DPRINTF("Before resuming the child process where it left off "
"and without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -170,6 +187,9 @@
int status;
#endif
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
DPRINTF("Before forking process PID=%d\n", getpid());
SYSCALL_REQUIRE((child = fork()) != -1);
if (child == 0) {
@@ -197,6 +217,18 @@
validate_status_stopped(status, sigval);
+ DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info))
+ != -1);
+
+ DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ DPRINTF("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
+
DPRINTF("Before resuming the child process where it left off and with "
"signal %s to be sent\n", strsignal(sigsent));
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1);
@@ -253,6 +285,9 @@
int expect_core = (sigsent == SIGABRT) ? 1 : 0;
#endif
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
DPRINTF("Before forking process PID=%d\n", getpid());
SYSCALL_REQUIRE((child = fork()) != -1);
if (child == 0) {
@@ -277,6 +312,18 @@
validate_status_stopped(status, sigval);
+ DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info))
+ != -1);
+
+ DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ DPRINTF("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
+
DPRINTF("Before resuming the child process where it left off and with "
"signal %s to be sent\n", strsignal(sigsent));
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1);
Home |
Main Index |
Thread Index |
Old Index