[PATCH v4 1/1] Introduce new --log_dialog option to emit expect output to stdout

Filipe Brandenburger <[email protected]>
Newsgroups gmane.comp.sysutils.dejagnu.general
Message-ID <[email protected]>
    * runtest.exp (runtest): Introduce new --log_dialog option.

This option is useful when running dejagnu tests on an automated
environment where only test stdout is accessible after a test run.

The expect output (usually saved in *.log files) is useful to debug test
failures which often are not apparent from the *.sum contents which are
the only ones orinarily included in the output.

There is already a way to include the useful expect log_user output, but
that is only accomplished by increasing verbosity to at least 3, which
then creates quite a bit of noise in the output related to debugging
runtest itself (looking for *.exp files, etc.) and is not that useful
for troubleshooting failure of tests themselves.

In order to fix this, introduce a new --log_dialog option to emit expect
output to stdout, without having to otherwise increase verbosity.

Tested by running `make check RUNTESTFLAGS="--all --log_dialog"` in
procps-ng package while troubleshooting an issue with a broken regexp in
one of the test cases.

v2: Update man page and docbook/texinfo documentation.

Tested `man doc/runtest.1` and `info doc/dejagnu.info` and confirmed
that the documentation for the --log_dialog option is now present in
both.

v3: Renamed option from --log_user to --log_dialog.

v4: Added a ChangeLog entry, minor reformatting.

Signed-off-by: Filipe Brandenburger <[email protected]>
---
 ChangeLog        |  5 +++++
 doc/dejagnu.texi |  7 +++++++
 doc/runtest.1    |  5 +++++
 doc/user.xml     |  9 +++++++++
 runtest.exp      | 11 ++++++++++-
 5 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index d578e23dfd38..11c106c4e75a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-14  Filipe Brandenburger  <[email protected]>
+
+	* runtest.exp (runtest): Introduce new --log_dialog option to
+	emit expect output to stdout.
+
 2015-05-14  Steve Ellcey  <[email protected]>
 
 	* baseboards/multi-sim.exp (get_library_dirlist): New.
diff --git a/doc/dejagnu.texi b/doc/dejagnu.texi
index fc788d5111db..788258e1ad7b 100644
--- a/doc/dejagnu.texi
+++ b/doc/dejagnu.texi
@@ -1488,6 +1488,13 @@ and the detailed log files
 log @file{dbg.log} always appears (when requested) in
 the local directory.
 
+@item @code{--log_dialog}
+Also emit @emph{expect} output to
+stdout.  The @emph{expect} output is usually only
+written to @file{tool.log}.  By enabling this option,
+they are also be printed to the stdout of the
+@emph{runtest} invocation.
+
 @item @code{--reboot [name]}
 Reboot the target board when
 @emph{runtest} initializes. Usually, when running tests
diff --git a/doc/runtest.1 b/doc/runtest.1
index 5b87096649c1..4dd98fe22679 100644
--- a/doc/runtest.1
+++ b/doc/runtest.1
@@ -53,6 +53,11 @@ The network HOSTNAME of the target board.
 .BI --outdir \ DIRECTORY
 The name of a DIRECTORY for test log output.
 .TP
+.B --log_dialog
+Also emit
+.B expect
+output to stdout.
+.TP
 .B --reboot
 Reboot the target board when \fBruntest\fR initializes
 (if supported).
diff --git a/doc/user.xml b/doc/user.xml
index f7e55c02ed7c..60b05eb4a108 100644
--- a/doc/user.xml
+++ b/doc/user.xml
@@ -1041,6 +1041,15 @@ powerpc-linux-gcc -g -O2 -o calc calc.o
 	</varlistentry>
 
         <varlistentry>
+          <term><option>--log_dialog</option></term>
+	  <listitem><para>Also emit <emphasis>expect</emphasis> output to
+	  stdout.  The <emphasis>expect</emphasis> output is usually only
+	  written to <filename>tool.log</filename>.  By enabling this option,
+	  they are also be printed to the stdout of the
+	  <emphasis>runtest</emphasis> invocation.</para></listitem>
+	</varlistentry>
+
+        <varlistentry>
           <term><option>--reboot [name]</option></term>
 	  <listitem><para>Reboot the target board when
 	  <emphasis>runtest</emphasis> initializes. Usually, when running tests
diff --git a/runtest.exp b/runtest.exp
index ad4db193cfdc..831cf294cb98 100644
--- a/runtest.exp
+++ b/runtest.exp
@@ -133,6 +133,9 @@ if {![info exists tracelevel]} {
 if {![info exists verbose]} {
     set verbose 0
 }
+if {![info exists log_dialog]} {
+    set log_dialog 0
+}
 
 #
 # verbose [-n] [-log] [--] message [level]
@@ -385,6 +388,7 @@ proc usage { } {
     send_user "\t--ignore \[name(s)\]\tThe names of specific tests to ignore\n"
     send_user "\t--objdir \[name\]\t\tThe test suite binary directory\n"
     send_user "\t--outdir \[name\]\t\tThe directory to put logs in\n"
+    send_user "\t--log_dialog\t\tAlso emit expect output to stdout\n"
     send_user "\t--reboot \[name\]\t\tReboot the target (if supported)\n"
     send_user "\t--srcdir \[name\]\t\tThe test suite source code directory\n"
     send_user "\t--strace \[number\]\tSet expect tracing ON\n"
@@ -1111,6 +1115,11 @@ for { set i 0 } { $i < $argc } { incr i } {
 	    continue
 	}
 
+	"--log_dialog*" {
+	    incr log_dialog
+	    continue
+	}
+
 	"*.exp" {			#  specify test names to run
 	    set all_runtests($option) ""
 	    verbose "Running only tests $option"
@@ -1214,7 +1223,7 @@ if {![info exists tool]} {
 #
 # initialize a few Tcl variables to something other than their default
 #
-if { $verbose > 2 } {
+if { $verbose > 2 || $log_dialog } {
     log_user 1
 } else {
     log_user 0
-- 
2.2.0.rc0.207.ga3a616c
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.