[Top][All Lists]

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

DejaGnu Unit Test Protocol (with minor patch for discussion)

From: Jacob Bachmeyer
Subject: DejaGnu Unit Test Protocol (with minor patch for discussion)
Date: Sat, 10 Nov 2018 22:51:03 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20090807 MultiZilla/ SeaMonkey/1.1.17 Mnenhy/

While working on the DejaGnu testsuite, I noticed that DejaGnu actually has a few Expect unit tests, but they report results differently from the method used by host_execute. I would like to document a "DejaGnu Standard Unit Test Protocol" for this and a future patch will include splitting host_execute into one procedure for starting a process and one for reading "DejaGnu Unit Test" results from the current expect channel. That will then allow the DejaGnu tests to use the same code.

Some time ago, I ran into a problem with host_execute that I did not understand at the time, but now recognize. I was using gcov(1) to verify unit test coverage, but some tests were clearly producing output, yet gcov reported that those functions had never been called. Worse, this was an intermittent failure -- some runs correctly updated the coverage data and some did not. I now know that the problem was due to DejaGnu closing the spawn channel upon matching {^Totals}, which may cause SIGPIPE to be delivered to the child process, depending upon the whim of the scheduler. I worked around the problem by duplicating most of the functionality of host_execute in my testsuite and using the equivalent of the below patch. (Which led to some other interesting bugs, but those do not affect DejaGnu, unlike this issue.)

I offer this patch for discussion or merge because the DejaGnu unit testing protocol is not documented, so unit tests could simply be expected to catch SIGPIPE if they care, or this patch can solve the problem:

ChangeLog entry:
        * lib/dejagnu.exp (host_execute): Flush stream from child when
        "Totals" line is reached.  This avoids sending the child SIGPIPE.

lib/dejagnu.exp |    2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/lib/dejagnu.exp b/lib/dejagnu.exp
index 8ca241a..8085cd6 100644
--- a/lib/dejagnu.exp
+++ b/lib/dejagnu.exp
@@ -175,6 +175,8 @@ proc host_execute {args} {
       -re "^Totals" {
           verbose "All done" 2
+           # Flush input to avoid sending SIGPIPE to child.
+           expect -re {.+} { exp_continue }
       eof {
           #       unresolved "${executable} died prematurely"

If unit test programs are not expected to handle SIGPIPE, please apply the above patch.

-- Jacob

reply via email to

[Prev in Thread] Current Thread [Next in Thread]