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 sync a bit more with reality; some things...



details:   https://anonhg.NetBSD.org/src/rev/f3b610de4076
branches:  trunk
changeset: 828457:f3b610de4076
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Dec 14 22:06:54 2017 +0000

description:
sync a bit more with reality; some things still fail, some new failures.
reduce spewage, be more explanatory about syscall errors.

diffstat:

 tests/lib/libc/sys/t_ptrace_amd64_wait.h |    74 +-
 tests/lib/libc/sys/t_ptrace_i386_wait.h  |    60 +-
 tests/lib/libc/sys/t_ptrace_wait.c       |  3696 ++++++++++++++---------------
 tests/lib/libc/sys/t_ptrace_x86_wait.h   |   600 ++--
 4 files changed, 2208 insertions(+), 2222 deletions(-)

diffs (truncated from 8507 to 300 lines):

diff -r df43c27059e6 -r f3b610de4076 tests/lib/libc/sys/t_ptrace_amd64_wait.h
--- a/tests/lib/libc/sys/t_ptrace_amd64_wait.h  Thu Dec 14 18:34:41 2017 +0000
+++ b/tests/lib/libc/sys/t_ptrace_amd64_wait.h  Thu Dec 14 22:06:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_amd64_wait.h,v 1.1 2017/04/02 21:44:00 kamil Exp $    */
+/*     $NetBSD: t_ptrace_amd64_wait.h,v 1.2 2017/12/14 22:06:54 christos Exp $ */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -44,67 +44,67 @@
 #endif
        struct reg r;
 
-       printf("Before forking process PID=%d\n", getpid());
-       ATF_REQUIRE((child = fork()) != -1);
+       DPRINTF("Before forking process PID=%d\n", getpid());
+       SYSCALL_REQUIRE((child = fork()) != -1);
        if (child == 0) {
-               printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+               DPRINTF("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));
+               DPRINTF("Before raising %s from child\n", strsignal(sigval));
                FORKEE_ASSERT(raise(sigval) == 0);
 
-               printf("Before exiting of the child process\n");
+               DPRINTF("Before exiting of the child process\n");
                _exit(exitval);
        }
-       printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+       DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
 
-       printf("Before calling %s() for the child\n", TWAIT_FNAME);
+       DPRINTF("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 GETREGS for the child process\n");
-       ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
+       DPRINTF("Call GETREGS for the child process\n");
+       SYSCALL_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
 
-       printf("RAX=%#" PRIxREGISTER "\n", r.regs[_REG_RAX]);
-       printf("RBX=%#" PRIxREGISTER "\n", r.regs[_REG_RBX]);
-       printf("RCX=%#" PRIxREGISTER "\n", r.regs[_REG_RCX]);
-       printf("RDX=%#" PRIxREGISTER "\n", r.regs[_REG_RDX]);
+       DPRINTF("RAX=%#" PRIxREGISTER "\n", r.regs[_REG_RAX]);
+       DPRINTF("RBX=%#" PRIxREGISTER "\n", r.regs[_REG_RBX]);
+       DPRINTF("RCX=%#" PRIxREGISTER "\n", r.regs[_REG_RCX]);
+       DPRINTF("RDX=%#" PRIxREGISTER "\n", r.regs[_REG_RDX]);
 
-       printf("RDI=%#" PRIxREGISTER "\n", r.regs[_REG_RDI]);
-       printf("RSI=%#" PRIxREGISTER "\n", r.regs[_REG_RSI]);
+       DPRINTF("RDI=%#" PRIxREGISTER "\n", r.regs[_REG_RDI]);
+       DPRINTF("RSI=%#" PRIxREGISTER "\n", r.regs[_REG_RSI]);
 
-       printf("GS=%#" PRIxREGISTER "\n", r.regs[_REG_GS]);
-       printf("FS=%#" PRIxREGISTER "\n", r.regs[_REG_FS]);
-       printf("ES=%#" PRIxREGISTER "\n", r.regs[_REG_ES]);
-       printf("DS=%#" PRIxREGISTER "\n", r.regs[_REG_DS]);
-       printf("CS=%#" PRIxREGISTER "\n", r.regs[_REG_CS]);
-       printf("SS=%#" PRIxREGISTER "\n", r.regs[_REG_SS]);
+       DPRINTF("GS=%#" PRIxREGISTER "\n", r.regs[_REG_GS]);
+       DPRINTF("FS=%#" PRIxREGISTER "\n", r.regs[_REG_FS]);
+       DPRINTF("ES=%#" PRIxREGISTER "\n", r.regs[_REG_ES]);
+       DPRINTF("DS=%#" PRIxREGISTER "\n", r.regs[_REG_DS]);
+       DPRINTF("CS=%#" PRIxREGISTER "\n", r.regs[_REG_CS]);
+       DPRINTF("SS=%#" PRIxREGISTER "\n", r.regs[_REG_SS]);
 
-       printf("RSP=%#" PRIxREGISTER "\n", r.regs[_REG_RSP]);
-       printf("RIP=%#" PRIxREGISTER "\n", r.regs[_REG_RIP]);
+       DPRINTF("RSP=%#" PRIxREGISTER "\n", r.regs[_REG_RSP]);
+       DPRINTF("RIP=%#" PRIxREGISTER "\n", r.regs[_REG_RIP]);
 
-       printf("RFLAGS=%#" PRIxREGISTER "\n", r.regs[_REG_RFLAGS]);
+       DPRINTF("RFLAGS=%#" PRIxREGISTER "\n", r.regs[_REG_RFLAGS]);
 
-       printf("R8=%#" PRIxREGISTER "\n", r.regs[_REG_R8]);
-       printf("R9=%#" PRIxREGISTER "\n", r.regs[_REG_R9]);
-       printf("R10=%#" PRIxREGISTER "\n", r.regs[_REG_R10]);
-       printf("R11=%#" PRIxREGISTER "\n", r.regs[_REG_R11]);
-       printf("R12=%#" PRIxREGISTER "\n", r.regs[_REG_R12]);
-       printf("R13=%#" PRIxREGISTER "\n", r.regs[_REG_R13]);
-       printf("R14=%#" PRIxREGISTER "\n", r.regs[_REG_R14]);
-       printf("R15=%#" PRIxREGISTER "\n", r.regs[_REG_R15]);
+       DPRINTF("R8=%#" PRIxREGISTER "\n", r.regs[_REG_R8]);
+       DPRINTF("R9=%#" PRIxREGISTER "\n", r.regs[_REG_R9]);
+       DPRINTF("R10=%#" PRIxREGISTER "\n", r.regs[_REG_R10]);
+       DPRINTF("R11=%#" PRIxREGISTER "\n", r.regs[_REG_R11]);
+       DPRINTF("R12=%#" PRIxREGISTER "\n", r.regs[_REG_R12]);
+       DPRINTF("R13=%#" PRIxREGISTER "\n", r.regs[_REG_R13]);
+       DPRINTF("R14=%#" PRIxREGISTER "\n", r.regs[_REG_R14]);
+       DPRINTF("R15=%#" PRIxREGISTER "\n", r.regs[_REG_R15]);
 
-       printf("Before resuming the child process where it left off and "
+       DPRINTF("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);
+       SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 
-       printf("Before calling %s() for the child\n", TWAIT_FNAME);
+       DPRINTF("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);
+       DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
        TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
 }
 #define ATF_TP_ADD_TCS_PTRACE_WAIT_AMD64() \
diff -r df43c27059e6 -r f3b610de4076 tests/lib/libc/sys/t_ptrace_i386_wait.h
--- a/tests/lib/libc/sys/t_ptrace_i386_wait.h   Thu Dec 14 18:34:41 2017 +0000
+++ b/tests/lib/libc/sys/t_ptrace_i386_wait.h   Thu Dec 14 22:06:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_i386_wait.h,v 1.1 2017/04/02 21:44:00 kamil Exp $     */
+/*     $NetBSD: t_ptrace_i386_wait.h,v 1.2 2017/12/14 22:06:54 christos Exp $  */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -44,60 +44,60 @@
 #endif
        struct reg r;
 
-       printf("Before forking process PID=%d\n", getpid());
-       ATF_REQUIRE((child = fork()) != -1);
+       DPRINTF("Before forking process PID=%d\n", getpid());
+       SYSCALL_REQUIRE((child = fork()) != -1);
        if (child == 0) {
-               printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+               DPRINTF("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));
+               DPRINTF("Before raising %s from child\n", strsignal(sigval));
                FORKEE_ASSERT(raise(sigval) == 0);
 
-               printf("Before exiting of the child process\n");
+               DPRINTF("Before exiting of the child process\n");
                _exit(exitval);
        }
-       printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+       DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
 
-       printf("Before calling %s() for the child\n", TWAIT_FNAME);
+       DPRINTF("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 GETREGS for the child process\n");
-       ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
+       DPRINTF("Call GETREGS for the child process\n");
+       SYSCALL_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
 
-       printf("EAX=%#" PRIxREGISTER "\n", r.r_eax);
-       printf("EBX=%#" PRIxREGISTER "\n", r.r_ebx);
-       printf("ECX=%#" PRIxREGISTER "\n", r.r_ecx);
-       printf("EDX=%#" PRIxREGISTER "\n", r.r_edx);
+       DPRINTF("EAX=%#" PRIxREGISTER "\n", r.r_eax);
+       DPRINTF("EBX=%#" PRIxREGISTER "\n", r.r_ebx);
+       DPRINTF("ECX=%#" PRIxREGISTER "\n", r.r_ecx);
+       DPRINTF("EDX=%#" PRIxREGISTER "\n", r.r_edx);
 
-       printf("ESP=%#" PRIxREGISTER "\n", r.r_esp);
-       printf("EBP=%#" PRIxREGISTER "\n", r.r_ebp);
+       DPRINTF("ESP=%#" PRIxREGISTER "\n", r.r_esp);
+       DPRINTF("EBP=%#" PRIxREGISTER "\n", r.r_ebp);
 
-       printf("ESI=%#" PRIxREGISTER "\n", r.r_esi);
-       printf("EDI=%#" PRIxREGISTER "\n", r.r_edi);
+       DPRINTF("ESI=%#" PRIxREGISTER "\n", r.r_esi);
+       DPRINTF("EDI=%#" PRIxREGISTER "\n", r.r_edi);
 
-       printf("EIP=%#" PRIxREGISTER "\n", r.r_eip);
+       DPRINTF("EIP=%#" PRIxREGISTER "\n", r.r_eip);
 
-       printf("EFLAGS=%#" PRIxREGISTER "\n", r.r_eflags);
+       DPRINTF("EFLAGS=%#" PRIxREGISTER "\n", r.r_eflags);
 
-       printf("CS=%#" PRIxREGISTER "\n", r.r_cs);
-       printf("SS=%#" PRIxREGISTER "\n", r.r_ss);
-       printf("DS=%#" PRIxREGISTER "\n", r.r_ds);
-       printf("ES=%#" PRIxREGISTER "\n", r.r_es);
-       printf("FS=%#" PRIxREGISTER "\n", r.r_fs);
-       printf("GS=%#" PRIxREGISTER "\n", r.r_gs);
+       DPRINTF("CS=%#" PRIxREGISTER "\n", r.r_cs);
+       DPRINTF("SS=%#" PRIxREGISTER "\n", r.r_ss);
+       DPRINTF("DS=%#" PRIxREGISTER "\n", r.r_ds);
+       DPRINTF("ES=%#" PRIxREGISTER "\n", r.r_es);
+       DPRINTF("FS=%#" PRIxREGISTER "\n", r.r_fs);
+       DPRINTF("GS=%#" PRIxREGISTER "\n", r.r_gs);
 
-       printf("Before resuming the child process where it left off and "
+       DPRINTF("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);
+       SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 
-       printf("Before calling %s() for the child\n", TWAIT_FNAME);
+       DPRINTF("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);
+       DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
        TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
 }
 #define ATF_TP_ADD_TCS_PTRACE_WAIT_I386() \
diff -r df43c27059e6 -r f3b610de4076 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c        Thu Dec 14 18:34:41 2017 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c        Thu Dec 14 22:06:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.c,v 1.12 2017/12/10 14:09:42 christos Exp $      */
+/*     $NetBSD: t_ptrace_wait.c,v 1.13 2017/12/14 22:06:54 christos Exp $      */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.12 2017/12/10 14:09:42 christos Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.13 2017/12/14 22:06:54 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -58,7 +58,7 @@
 #include "msg.h"
 
 #define PARENT_TO_CHILD(info, fds, msg) \
-    ATF_REQUIRE(msg_write_child(info " to child " # fds, &fds, &msg, sizeof(msg)) == 0)
+    SYSCALL_REQUIRE(msg_write_child(info " to child " # fds, &fds, &msg, sizeof(msg)) == 0)
 
 #define CHILD_FROM_PARENT(info, fds, msg) \
     FORKEE_ASSERT(msg_read_parent(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0)
@@ -67,7 +67,16 @@
     FORKEE_ASSERT(msg_write_parent(info " to parent " # fds, &fds, &msg, sizeof(msg)) == 0)
 
 #define PARENT_FROM_CHILD(info, fds, msg) \
-    ATF_REQUIRE(msg_read_child(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0)
+    SYSCALL_REQUIRE(msg_read_child(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0)
+
+#define SYSCALL_REQUIRE(expr) ATF_REQUIRE_MSG(expr, "%s: %s", # expr, \
+    strerror(errno))
+
+static int debug = 0;
+
+#define DPRINTF(a, ...)        do  \
+       if (debug) printf(a,  ##__VA_ARGS__); \
+    while (/*CONSTCOND*/0)
 
 
 ATF_TC(traceme1);
@@ -86,35 +95,35 @@
        int status;
 #endif
 
-       printf("Before forking process PID=%d\n", getpid());
-       ATF_REQUIRE((child = fork()) != -1);
+       DPRINTF("Before forking process PID=%d\n", getpid());
+       SYSCALL_REQUIRE((child = fork()) != -1);
        if (child == 0) {
-               printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+               DPRINTF("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));
+               DPRINTF("Before raising %s from child\n", strsignal(sigval));
                FORKEE_ASSERT(raise(sigval) == 0);
 
-               printf("Before exiting of the child process\n");
+               DPRINTF("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);
+       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_stopped(status, sigval);
 
-       printf("Before resuming the child process where it left off and "
+       DPRINTF("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);
+       SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+       DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
        TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
 
        validate_status_exited(status, exitval);



Home | Main Index | Thread Index | Old Index