Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/kernel Add new test file t_ptrace_amd64_wait.c and ref...
details: https://anonhg.NetBSD.org/src/rev/ce073e979f32
branches: trunk
changeset: 349238:ce073e979f32
user: kamil <kamil%NetBSD.org@localhost>
date: Thu Dec 01 20:11:17 2016 +0000
description:
Add new test file t_ptrace_amd64_wait.c and refactor t_ptrace_*wait* tests
Clone t_ptrace_wait.c to t_ptrace_amd64_wait.c and put common parts to
t_ptrace_wait.h.
The t_ptrace_amd64_wait.c file is dedicated to hold amd64-specific tests
for the ptrace(2) interface.
Add new basic test dbreg1 in t_ptrace_amd64_wait{,3,4,6,id,pid}:
Verify plain PT_GETDBREGS with printing Debug Registers
Fix evbarm64-aarch64 issue pointed by <christos>, kill1 and kill2 tests
must be defined without PT_STEP guards.
Sponsored by <The NetBSD Foundation>
diffstat:
tests/kernel/Makefile | 11 +-
tests/kernel/t_ptrace_amd64_wait.c | 122 ++++++++++
tests/kernel/t_ptrace_amd64_wait3.c | 30 ++
tests/kernel/t_ptrace_amd64_wait4.c | 30 ++
tests/kernel/t_ptrace_amd64_wait6.c | 30 ++
tests/kernel/t_ptrace_amd64_waitid.c | 30 ++
tests/kernel/t_ptrace_amd64_waitpid.c | 30 ++
tests/kernel/t_ptrace_wait.c | 391 +--------------------------------
tests/kernel/t_ptrace_wait.h | 408 ++++++++++++++++++++++++++++++++++
9 files changed, 695 insertions(+), 387 deletions(-)
diffs (truncated from 1159 to 300 lines):
diff -r 9f40ec360e67 -r ce073e979f32 tests/kernel/Makefile
--- a/tests/kernel/Makefile Thu Dec 01 18:21:39 2016 +0000
+++ b/tests/kernel/Makefile Thu Dec 01 20:11:17 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.41 2016/11/07 21:09:03 kamil Exp $
+# $NetBSD: Makefile,v 1.42 2016/12/01 20:11:17 kamil Exp $
NOMAN= # defined
@@ -23,6 +23,15 @@
TESTS_C+= t_kauth_pr_47598
TESTS_C+= t_sysctl
+.if (${MACHINE} == "amd64")
+TESTS_C+= t_ptrace_amd64_wait
+TESTS_C+= t_ptrace_amd64_wait3
+TESTS_C+= t_ptrace_amd64_wait4
+TESTS_C+= t_ptrace_amd64_wait6
+TESTS_C+= t_ptrace_amd64_waitid
+TESTS_C+= t_ptrace_amd64_waitpid
+.endif
+
TESTS_SH= t_umount
TESTS_SH+= t_umountstress
TESTS_SH+= t_ps_strings
diff -r 9f40ec360e67 -r ce073e979f32 tests/kernel/t_ptrace_amd64_wait.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/kernel/t_ptrace_amd64_wait.c Thu Dec 01 20:11:17 2016 +0000
@@ -0,0 +1,122 @@
+/* $NetBSD: t_ptrace_amd64_wait.c,v 1.1 2016/12/01 20:11:17 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_ptrace_amd64_wait.c,v 1.1 2016/12/01 20:11:17 kamil Exp $");
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <sys/wait.h>
+#include <machine/reg.h>
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#include "../h_macros.h"
+
+#include "t_ptrace_wait.h"
+
+#if defined(HAVE_DBREGS)
+ATF_TC(dbregs1);
+ATF_TC_HEAD(dbregs1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify plain PT_GETDBREGS with printing Debug Registers");
+}
+
+ATF_TC_BODY(dbregs1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct dbreg r;
+ size_t i;
+
+ printf("Before forking process PID=%d\n", getpid());
+ child = atf_utils_fork();
+ 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("Call GETDBREGS for the child process\n");
+ ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r, 0) != -1);
+
+ printf("State of the debug registers:\n");
+ for (i = 0; i < __arraycount(r.dbregs); i++)
+ printf("r[%zu]=%#lx\n", i, r.dbregs[i]);
+
+ 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));
+}
+#endif
+
+ATF_TP_ADD_TCS(tp)
+{
+ setvbuf(stdout, NULL, _IONBF, 0);
+ setvbuf(stderr, NULL, _IONBF, 0);
+
+ ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs1);
+
+ return atf_no_error();
+}
diff -r 9f40ec360e67 -r ce073e979f32 tests/kernel/t_ptrace_amd64_wait3.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/kernel/t_ptrace_amd64_wait3.c Thu Dec 01 20:11:17 2016 +0000
@@ -0,0 +1,30 @@
+/* $NetBSD: t_ptrace_amd64_wait3.c,v 1.1 2016/12/01 20:11:17 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define TWAIT_WAIT3
+#include "t_ptrace_amd64_wait.c"
diff -r 9f40ec360e67 -r ce073e979f32 tests/kernel/t_ptrace_amd64_wait4.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/kernel/t_ptrace_amd64_wait4.c Thu Dec 01 20:11:17 2016 +0000
@@ -0,0 +1,30 @@
+/* $NetBSD: t_ptrace_amd64_wait4.c,v 1.1 2016/12/01 20:11:17 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define TWAIT_WAIT4
+#include "t_ptrace_amd64_wait.c"
diff -r 9f40ec360e67 -r ce073e979f32 tests/kernel/t_ptrace_amd64_wait6.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/kernel/t_ptrace_amd64_wait6.c Thu Dec 01 20:11:17 2016 +0000
@@ -0,0 +1,30 @@
+/* $NetBSD: t_ptrace_amd64_wait6.c,v 1.1 2016/12/01 20:11:17 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define TWAIT_WAIT6
+#include "t_ptrace_amd64_wait.c"
diff -r 9f40ec360e67 -r ce073e979f32 tests/kernel/t_ptrace_amd64_waitid.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/kernel/t_ptrace_amd64_waitid.c Thu Dec 01 20:11:17 2016 +0000
@@ -0,0 +1,30 @@
+/* $NetBSD: t_ptrace_amd64_waitid.c,v 1.1 2016/12/01 20:11:17 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define TWAIT_WAITID
+#include "t_ptrace_amd64_wait.c"
diff -r 9f40ec360e67 -r ce073e979f32 tests/kernel/t_ptrace_amd64_waitpid.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/kernel/t_ptrace_amd64_waitpid.c Thu Dec 01 20:11:17 2016 +0000
@@ -0,0 +1,30 @@
+/* $NetBSD: t_ptrace_amd64_waitpid.c,v 1.1 2016/12/01 20:11:17 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
- Prev by Date:
[src/trunk]: src/distrib/sets/lists Add t_ptrace_amd64_wait{, 3, 4, 6, id, pid} tests
- Next by Date:
[src/trunk]: src/distrib/sets/lists Fix !amd64 sets
- Previous by Thread:
[src/trunk]: src/distrib/sets/lists Add t_ptrace_amd64_wait{, 3, 4, 6, id, pid} tests
- Next by Thread:
[src/trunk]: src/distrib/sets/lists Fix !amd64 sets
- Indexes:
Home |
Main Index |
Thread Index |
Old Index