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 80 column police. Some KNF and whitespa...



details:   https://anonhg.NetBSD.org/src/rev/777484d292f2
branches:  trunk
changeset: 323120:777484d292f2
user:      kre <kre%NetBSD.org@localhost>
date:      Fri Jun 01 05:48:29 2018 +0000

description:
80 column police.   Some KNF and whitespace corrections (until I got bored...)
NFCI.

diffstat:

 tests/lib/libc/sys/t_ptrace_wait.c |  615 +++++++++++++++++++-----------------
 1 files changed, 323 insertions(+), 292 deletions(-)

diffs (truncated from 1176 to 300 lines):

diff -r 3ebcc0d481fe -r 777484d292f2 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c        Fri Jun 01 01:21:02 2018 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c        Fri Jun 01 05:48:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.c,v 1.60 2018/05/30 05:09:11 kre Exp $   */
+/*     $NetBSD: t_ptrace_wait.c,v 1.61 2018/06/01 05:48:29 kre 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 2018/05/30 05:09:11 kre Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.61 2018/06/01 05:48:29 kre Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -60,16 +60,20 @@
 #include "msg.h"
 
 #define PARENT_TO_CHILD(info, fds, msg) \
-    SYSCALL_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)
+    FORKEE_ASSERT(msg_read_parent(info " from parent " # fds, &fds, &msg, \
+       sizeof(msg)) == 0)
 
 #define CHILD_TO_PARENT(info, fds, msg) \
-    FORKEE_ASSERT(msg_write_parent(info " to parent " # fds, &fds, &msg, sizeof(msg)) == 0)
+    FORKEE_ASSERT(msg_write_parent(info " to parent " # fds, &fds, &msg, \
+       sizeof(msg)) == 0)
 
 #define PARENT_FROM_CHILD(info, fds, msg) \
-    SYSCALL_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))
@@ -127,15 +131,15 @@
                validate_status_stopped(status, sigval);
 
                DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for "
-                       "child\n");
+                       "child\n");
                SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info,
-                                      sizeof(info)) != -1);
+                       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);
+                       "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);
@@ -146,7 +150,7 @@
 
                DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
                TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
-                                     child);
+                   child);
                break;
        }
 
@@ -154,18 +158,18 @@
        TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
 }
 
-#define TRACEME_RAISE(test, sig)                                               \
-ATF_TC(test);                                                                  \
-ATF_TC_HEAD(test, tc)                                                          \
-{                                                                              \
-       atf_tc_set_md_var(tc, "descr",                                          \
-           "Verify " #sig " followed by _exit(2) in a child");                 \
-}                                                                              \
-                                                                               \
-ATF_TC_BODY(test, tc)                                                          \
-{                                                                              \
-                                                                               \
-       traceme_raise(sig);                                                     \
+#define TRACEME_RAISE(test, sig)                                       \
+ATF_TC(test);                                                          \
+ATF_TC_HEAD(test, tc)                                                  \
+{                                                                      \
+       atf_tc_set_md_var(tc, "descr",                                  \
+           "Verify " #sig " followed by _exit(2) in a child");         \
+}                                                                      \
+                                                                       \
+ATF_TC_BODY(test, tc)                                                  \
+{                                                                      \
+                                                                       \
+       traceme_raise(sig);                                             \
 }
 
 TRACEME_RAISE(traceme_raise1, SIGKILL) /* non-maskable */
@@ -184,6 +188,7 @@
        int status;
 #endif
        struct ptrace_siginfo info;
+
        memset(&info, 0, sizeof(info));
 
        DPRINTF("Before forking process PID=%d\n", getpid());
@@ -225,12 +230,13 @@
        validate_status_stopped(status, sig);
 
        DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child");
-       SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+       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);
+           info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+           info.psi_siginfo.si_errno);
 
        ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sig);
        switch (sig) {
@@ -262,18 +268,18 @@
        TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
 }
 
-#define TRACEME_CRASH(test, sig)                                               \
-ATF_TC(test);                                                                  \
-ATF_TC_HEAD(test, tc)                                                          \
-{                                                                              \
-       atf_tc_set_md_var(tc, "descr",                                          \
-           "Verify crash signal " #sig " in a child after PT_TRACE_ME");       \
-}                                                                              \
-                                                                               \
-ATF_TC_BODY(test, tc)                                                          \
-{                                                                              \
-                                                                               \
-       traceme_crash(sig);                                                     \
+#define TRACEME_CRASH(test, sig)                                       \
+ATF_TC(test);                                                          \
+ATF_TC_HEAD(test, tc)                                                  \
+{                                                                      \
+       atf_tc_set_md_var(tc, "descr",                                  \
+           "Verify crash signal " #sig " in a child after PT_TRACE_ME"); \
+}                                                                      \
+                                                                       \
+ATF_TC_BODY(test, tc)                                                  \
+{                                                                      \
+                                                                       \
+       traceme_crash(sig);                                             \
 }
 
 TRACEME_CRASH(traceme_crash_trap, SIGTRAP)
@@ -294,8 +300,8 @@
 #if defined(TWAIT_HAVE_STATUS)
        int status;
 #endif
-
        struct ptrace_siginfo info;
+
        memset(&info, 0, sizeof(info));
 
        DPRINTF("Before forking process PID=%d\n", getpid());
@@ -326,8 +332,8 @@
        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);
+       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",
@@ -350,29 +356,29 @@
        TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
 }
 
-#define TRACEME_SENDSIGNAL_HANDLE(test, sig)                                   \
-ATF_TC(test);                                                                  \
-ATF_TC_HEAD(test, tc)                                                          \
-{                                                                              \
-       atf_tc_set_md_var(tc, "descr",                                          \
-           "Verify that a signal " #sig " emitted by a tracer to a child is "  \
-           "handled correctly and caught by a signal handler");                \
-}                                                                              \
-                                                                               \
-static int test##_caught = 0;                                                  \
-                                                                               \
-static void                                                                    \
-test##_sighandler(int arg)                                                     \
-{                                                                              \
-       FORKEE_ASSERT_EQ(arg, sig);                                             \
-                                                                               \
-       ++ test##_caught;                                                       \
-}                                                                              \
-                                                                               \
-ATF_TC_BODY(test, tc)                                                          \
-{                                                                              \
-                                                                               \
-       traceme_sendsignal_handle(sig, test##_sighandler, & test##_caught);     \
+#define TRACEME_SENDSIGNAL_HANDLE(test, sig)                           \
+ATF_TC(test);                                                          \
+ATF_TC_HEAD(test, tc)                                                  \
+{                                                                      \
+       atf_tc_set_md_var(tc, "descr",                                  \
+           "Verify that a signal " #sig " emitted by a tracer to a child is " \
+           "handled correctly and caught by a signal handler");        \
+}                                                                      \
+                                                                       \
+static int test##_caught = 0;                                          \
+                                                                       \
+static void                                                            \
+test##_sighandler(int arg)                                             \
+{                                                                      \
+       FORKEE_ASSERT_EQ(arg, sig);                                     \
+                                                                       \
+       ++ test##_caught;                                               \
+}                                                                      \
+                                                                       \
+ATF_TC_BODY(test, tc)                                                  \
+{                                                                      \
+                                                                       \
+       traceme_sendsignal_handle(sig, test##_sighandler, & test##_caught); \
 }
 
 // A signal handler for SIGKILL and SIGSTOP cannot be registered.
@@ -392,8 +398,8 @@
 #if defined(TWAIT_HAVE_STATUS)
        int status;
 #endif
-
        struct ptrace_siginfo info;
+
        memset(&info, 0, sizeof(info));
 
        DPRINTF("Before forking process PID=%d\n", getpid());
@@ -419,8 +425,8 @@
        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);
+       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",
@@ -443,19 +449,19 @@
        TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
 }
 
-#define TRACEME_SENDSIGNAL_MASKED(test, sig)                                   \
-ATF_TC(test);                                                                  \
-ATF_TC_HEAD(test, tc)                                                          \
-{                                                                              \
-       atf_tc_set_md_var(tc, "descr",                                          \
-           "Verify that a signal " #sig " emitted by a tracer to a child is "  \
-           "handled correctly and the signal is masked by SIG_BLOCK");         \
-}                                                                              \
-                                                                               \
-ATF_TC_BODY(test, tc)                                                          \
-{                                                                              \
-                                                                               \
-       traceme_sendsignal_masked(sig);                                         \
+#define TRACEME_SENDSIGNAL_MASKED(test, sig)                           \
+ATF_TC(test);                                                          \
+ATF_TC_HEAD(test, tc)                                                  \
+{                                                                      \
+       atf_tc_set_md_var(tc, "descr",                                  \
+           "Verify that a signal " #sig " emitted by a tracer to a child is " \
+           "handled correctly and the signal is masked by SIG_BLOCK"); \
+}                                                                      \
+                                                                       \
+ATF_TC_BODY(test, tc)                                                  \
+{                                                                      \
+                                                                       \
+       traceme_sendsignal_masked(sig);                                 \
 }
 
 // A signal handler for SIGKILL and SIGSTOP cannot be masked.
@@ -475,14 +481,15 @@
 #if defined(TWAIT_HAVE_STATUS)
        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) {



Home | Main Index | Thread Index | Old Index