PATCH: Eureka! The testsuite can now test individual tools.

Jacob Bachmeyer <[email protected]> Tue, 30 Oct 2018 20:24:00 -0500
Newsgroups gmane.comp.sysutils.dejagnu.bugs
Message-ID <[email protected]>
This fixes the problem with running the DejaGnu testsuite for each tool 
and adjusts the testsuite to run in that way.  The expected results are 
now 5 expected passes for libdejagnu and 77 expected passes for runtest.

The expect error mentioned before was due to the use of "close" in 
runtest_exit despite having never used "spawn".  If spawn_id is not 
defined, "close" closes the terminal.

This was isolated after considering what is different between a run for 
libdejagnu and for runtest, and the first difference I noticed was that 
the libdejagnu tests run "unit" using "host_execute", which uses "spawn" 
internally, so I added a simple "spawn echo ok; expect ok"-like sequence 
to the runtest tool init file.  When that caused a Tcl error due to 
closing an invalid spawn descriptor in runtest_exit, I knew I had found 
the problem.

---
 ChangeLog                                         |   11 +++++++++++
 Makefile.am                                       |    5 ++++-
 testsuite/lib/libdejagnu.exp                      |    1 +
 testsuite/{config/default.exp => lib/runtest.exp} |    1 -
 4 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 testsuite/lib/libdejagnu.exp
 rename testsuite/{config/default.exp => lib/runtest.exp} (99%)

diff --git a/ChangeLog b/ChangeLog
index 20957c1..b95963b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,17 @@
 
        * configure.ac (DEJAGNU): Add comments.
 
+       * Makefile.am (DEJATOOL): List tools in testsuite.
+       (RUNTESTDEFAULTFLAGS): Adjust to support per-tool testing.
+       * testsuite/config/default.exp: Rename from this ...
+       * testsuite/lib/runtest.exp: ... to this.
+       (runtest_exit): Remove spurious "close".
+       This was causing per-tool testing to fail, since the testsuite for
+       "runtest" never actually uses "spawn", so "close" ends up closing
+       exp0, which is the terminal.  The ${tool}_exit proc is not called
+       if the --tool option is not given, so this had no effect earlier.
+       * testsuite/lib/libdejagnu.exp: New empty file.
+
 2018-10-30  Ben Elliston  <[email protected]>
 
        * Makefile.am (DISTCLEANFILES): Add testrun.xml.
diff --git a/Makefile.am b/Makefile.am
index 93323af..91d58e2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -163,8 +163,11 @@ TESTSUITE_FILES = \
        testsuite/lib/util-defs.exp \
        testsuite/libdejagnu/tunit.exp
 
+DEJATOOL = libdejagnu runtest
+
 RUNTEST = ${top_srcdir}/runtest
-RUNTESTDEFAULTFLAGS = --srcdir $(srcdir)/testsuite RUNTEST=$(RUNTEST)
+RUNTESTDEFAULTFLAGS = --tool $${tool} --srcdir $${srcdir}/testsuite
+RUNTESTDEFAULTFLAGS += RUNTEST=$(RUNTEST)
 
 AM_CXXFLAGS = -I$(top_srcdir) -g
 check_PROGRAMS = unit
diff --git a/testsuite/lib/libdejagnu.exp b/testsuite/lib/libdejagnu.exp
new file mode 100644
index 0000000..fa81ada
--- /dev/null
+++ b/testsuite/lib/libdejagnu.exp
@@ -0,0 +1 @@
+# empty file
diff --git a/testsuite/config/default.exp b/testsuite/lib/runtest.exp
similarity index 99%
rename from testsuite/config/default.exp
rename to testsuite/lib/runtest.exp
index 86d2b5e..bd20b5a 100644
--- a/testsuite/config/default.exp
+++ b/testsuite/lib/runtest.exp
@@ -55,7 +55,6 @@ proc runtest_load { arg } {
 # runtest_exit -- exit the test driver for expect
 #
 proc runtest_exit { } {
-    close
 }
 
 #
-- 


-- Jacob