Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/kernel - Add a 3 way handshake between the tracer and ...



details:   https://anonhg.NetBSD.org/src/rev/7356218de7f2
branches:  trunk
changeset: 819011:7356218de7f2
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Nov 12 16:23:36 2016 +0000

description:
- Add a 3 way handshake between the tracer and the tracee to make sure the
  tracer got a chance to run before we trace it.
- Unbuffer stdout and stderr, because the tracee ends up with with the tracers
  unflushed buffers, and that confuses things.

diffstat:

 tests/kernel/t_ptrace_wait.c |  22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (57 lines):

diff -r b431256a7db2 -r 7356218de7f2 tests/kernel/t_ptrace_wait.c
--- a/tests/kernel/t_ptrace_wait.c      Sat Nov 12 16:06:04 2016 +0000
+++ b/tests/kernel/t_ptrace_wait.c      Sat Nov 12 16:23:36 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.c,v 1.6 2016/11/12 14:48:55 kamil Exp $  */
+/*     $NetBSD: t_ptrace_wait.c,v 1.7 2016/11/12 16:23:36 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.6 2016/11/12 14:48:55 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.7 2016/11/12 16:23:36 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -839,7 +839,13 @@
                FORKEE_ASSERT(close(fds_totracee[1]) == 0);
                FORKEE_ASSERT(close(fds_fromtracee[0]) == 0);
 
-               /* Wait for message from the parent */
+               /* Wait for message 1 from the parent */
+               rv = read(fds_totracee[0], &msg, sizeof(msg));
+               FORKEE_ASSERT(rv == sizeof(msg));
+               /* Send response to parent */
+               rv = write(fds_fromtracee[1], &msg, sizeof(msg));
+               FORKEE_ASSERT(rv == sizeof(msg));
+               /* Wait for message 2 from the parent */
                rv = read(fds_totracee[0], &msg, sizeof(msg));
                FORKEE_ASSERT(rv == sizeof(msg));
 
@@ -854,7 +860,13 @@
        ATF_REQUIRE(close(fds_totracee[0]) == 0);
        ATF_REQUIRE(close(fds_fromtracee[1]) == 0);
 
-       printf("Wait for the tracee to become ready\n");
+       printf("Send message 1 to tracee\n");
+       rv = write(fds_totracee[1], &msg, sizeof(msg));
+       ATF_REQUIRE(rv == sizeof(msg));
+       printf("Wait for response from tracee\n");
+       rv = read(fds_fromtracee[0], &msg, sizeof(msg));
+       ATF_REQUIRE(rv == sizeof(msg));
+       printf("Send message 2 to tracee\n");
        rv = write(fds_totracee[1], &msg, sizeof(msg));
        ATF_REQUIRE(rv == sizeof(msg));
 
@@ -1127,6 +1139,8 @@
 
 ATF_TP_ADD_TCS(tp)
 {
+       setvbuf(stdout, NULL, _IONBF, 0);
+       setvbuf(stderr, NULL, _IONBF, 0);
        ATF_TP_ADD_TC(tp, traceme1);
        ATF_TP_ADD_TC(tp, traceme2);
        ATF_TP_ADD_TC(tp, traceme3);



Home | Main Index | Thread Index | Old Index