aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Bachmeyer <jcb@gnu.org>2022-11-26 22:05:45 -0600
committerJacob Bachmeyer <jcb@gnu.org>2022-11-26 22:05:45 -0600
commit999b7c0475d5f31c9fc29be58a97078bf6f0f2ec (patch)
tree35b3f9c43abfbda98f898ff23e189fa56a4015bb
parentd747eee6ec891425846ea9c21819d9c2ea48ed34 (diff)
Add explicit end-of-test marker to DejaGnu unit test protocol
-rw-r--r--ChangeLog14
-rw-r--r--dejagnu.h2
-rw-r--r--doc/dejagnu.texi8
-rw-r--r--lib/dejagnu.exp13
4 files changed, 29 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 25102ea..d7ea8c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2022-11-26 Jacob Bachmeyer <jcb@gnu.org>
+
+ * doc/dejagnu.texi (DejaGnu unit test protocol): Add end marker
+ line using "END" to allow detecting tests that exit prematurely.
+ The "Totals:" line was previously used for this purpose, but it
+ does not match the pattern documented as reserved for carrying
+ unit test results and information.
+
+ * lib/dejagnu.exp (host_execute): Remove test for "Totals" line.
+ (host_execute): Add corresponding support for the new line types.
+
+ * dejagnu.h (totals): Add end marker.
+ (TestState::totals): Likewise.
+
2022-10-04 Jacob Bachmeyer <jcb@gnu.org>
PR58065
diff --git a/dejagnu.h b/dejagnu.h
index bd0dcc3..df23890 100644
--- a/dejagnu.h
+++ b/dejagnu.h
@@ -161,6 +161,7 @@ totals (void)
printf ("\t#untested:\t\t%d\n", untest);
if (unresolve)
printf ("\t#unresolved:\t\t%d\n", unresolve);
+ printf ("\tEND: done\n");
}
#ifdef __cplusplus
@@ -263,6 +264,7 @@ class TestState {
std::cout << "\t#untested:\t\t" << untest << std::endl;
if (unresolve)
std::cout << "\t#unresolved:\t\t" << unresolve << std::endl;
+ std::cout << "\tEND: done" << std::endl;
}
// This is so this class can be printed in an ostream.
diff --git a/doc/dejagnu.texi b/doc/dejagnu.texi
index c2b791f..62207b7 100644
--- a/doc/dejagnu.texi
+++ b/doc/dejagnu.texi
@@ -10,7 +10,7 @@
@copying
@c man begin COPYRIGHT
-Copyright @copyright{} 1992-2020 Free Software Foundation, Inc.
+Copyright @copyright{} 1992-2020, 2022 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -2538,6 +2538,12 @@ This will cause @i{text} to be printed at verbose levels 2 and higher.
These indicate simple test results.
+@print{}@t{@ @ @ @ @ @ @ @ END: }@i{text}
+
+This indicates that the test case is complete. All subsequent output
+from the test is ignored. A warning is produced if the test case
+closes its output without producing this line.
+
Note that all output from a unit test program, including the lines
recognized and interpreted by DejaGnu, appears in the log.
diff --git a/lib/dejagnu.exp b/lib/dejagnu.exp
index 3fdca76..2489cc1 100644
--- a/lib/dejagnu.exp
+++ b/lib/dejagnu.exp
@@ -140,18 +140,16 @@ proc host_execute {args} {
XFAILED { xfail $output }
UNTESTED { untested $output }
UNRESOLVED { unresolved $output }
+ END {
+ expect -re {.+} { exp_continue }
+ verbose "All done" 2
+ }
default {
unresolved "unknown unit test token $expect_out(1,string)"
}
}
set timetol 0
- exp_continue
- }
- -re {^Totals} {
- # Flush the stream to allow the child process to finish writing
- # logs or other information, instead of sending SIGPIPE.
- expect -re {.+} { exp_continue }
- verbose "All done" 2
+ if { $expect_out(1,string) ne "END" } { exp_continue }
}
-re {^[^\r\n]*([0-9][0-9]:..:..:[^\n]*)\n} {
# No one seems to know why this pattern is here or what it is
@@ -170,6 +168,7 @@ proc host_execute {args} {
$executable $arguments"
}
eof {
+ warning "Test case did not emit an end marker"
}
timeout {
warning "Timed out executing test case"