aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Bachmeyer <jcb62281+dev@gmail.com>2020-07-20 21:39:21 -0500
committerJacob Bachmeyer <jcb62281+dev@gmail.com>2020-07-20 21:39:21 -0500
commit89f58b27832f8fc7b443988d02e56cfaba12eb5a (patch)
tree162fedc62b2a815722180f3e8adc8e2c4b6ff8c9
parentcafd85defe299956b18c75c2439e74bd19652388 (diff)
Add regression test for PR42399
-rw-r--r--ChangeLog18
-rw-r--r--Makefile.am3
-rw-r--r--lib/dejagnu.exp17
-rw-r--r--testsuite/runtest.main/nested/testsuite/bug.test/pr42399-sub.exp25
-rwxr-xr-xtestsuite/runtest.main/nested/testsuite/bug.test/pr42399.awk35
-rw-r--r--testsuite/runtest.main/pr42399.exp60
6 files changed, 151 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 5eda122..19461af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2020-07-20 Jacob Bachmeyer <jcb62281+dev@gmail.com>
+ PR42399
+
+ * Makefile.am (TESTSUITE_FILES): Update.
+
+ * lib/dejagnu.exp (host_execute): Allow the executable to be
+ specified with an absolute file name.
+ (host_execute): Fix argument handling to allow passing more than
+ one argument to the executable. Return early if given no
+ arguments at all instead of trying to execute "./".
+
+ * testsuite/runtest.main/pr42399.exp: New file.
+ * testsuite/runtest.main/nested/testsuite/bug.test/pr42399.awk:
+ New file.
+ * testsuite/runtest.main/nested/testsuite/bug.test/pr42399-sub.exp:
+ New file.
+
+2020-07-20 Jacob Bachmeyer <jcb62281+dev@gmail.com>
+
* Makefile.am (CLEANFILES): Update.
(TESTSUITE_FILES): Update to reflect testsuite reorganization.
diff --git a/Makefile.am b/Makefile.am
index a64d9a4..bbf6fc5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -190,6 +190,9 @@ TESTSUITE_FILES = \
testsuite/runtest.main/nested/testsuite/null.test/null.exp \
testsuite/runtest.main/stats.exp \
testsuite/runtest.main/nested/testsuite/stat.test/stats-sub.exp \
+ testsuite/runtest.main/pr42399.exp \
+ testsuite/runtest.main/nested/testsuite/bug.test/pr42399.awk \
+ testsuite/runtest.main/nested/testsuite/bug.test/pr42399-sub.exp \
testsuite/lib/bohman_ssd.exp \
testsuite/lib/launcher.exp \
testsuite/lib/libdejagnu.exp \
diff --git a/lib/dejagnu.exp b/lib/dejagnu.exp
index ea363a9..e1060ae 100644
--- a/lib/dejagnu.exp
+++ b/lib/dejagnu.exp
@@ -112,16 +112,19 @@ proc host_execute {args} {
set timetol 0
set arguments ""
- if { [llength $args] == 0} {
- set executable $args
+ if { [llength $args] == 0 } {
+ return "No executable specified."
} else {
- set executable [string trimleft [lindex [split $args " "] 0] "\{"]
- set params [string trimleft [lindex [split $args " "] 1] "\{"]
- set params [string trimright $params "\}"]
+ set executable [lindex $args 0]
+ set arguments [lrange $args 1 end]
}
verbose "The executable is $executable" 2
- if {![file exists $executable]} {
+ verbose "The arguments are $arguments" 2
+ if { [file exists "./${executable}"] } {
+ set executable "./${executable}"
+ }
+ if { ![file exists $executable] } {
perror "The executable, \"$executable\" is missing" 0
return "No source file found"
}
@@ -129,7 +132,7 @@ proc host_execute {args} {
# spawn the executable and look for the DejaGnu output messages from the
# test case.
# spawn -noecho -open [open "|./${executable}" "r"]
- spawn -noecho "./${executable}" $params
+ eval [list spawn -noecho $executable] $arguments
set prefix "\[^\r\n\]*"
expect {
-re "^$prefix\[0-9\]\[0-9\]:..:..:${text}*\r\n" {
diff --git a/testsuite/runtest.main/nested/testsuite/bug.test/pr42399-sub.exp b/testsuite/runtest.main/nested/testsuite/bug.test/pr42399-sub.exp
new file mode 100644
index 0000000..331e043
--- /dev/null
+++ b/testsuite/runtest.main/nested/testsuite/bug.test/pr42399-sub.exp
@@ -0,0 +1,25 @@
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of DejaGnu.
+#
+# DejaGnu is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# DejaGnu is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with DejaGnu; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Regression test for PR42399; inner runtest component.
+
+load_lib dejagnu.exp
+
+if {[info exists N]} {
+ host_execute [which awk] -f [testsuite file -source -test pr42399.awk] N=$N
+}
diff --git a/testsuite/runtest.main/nested/testsuite/bug.test/pr42399.awk b/testsuite/runtest.main/nested/testsuite/bug.test/pr42399.awk
new file mode 100755
index 0000000..c460508
--- /dev/null
+++ b/testsuite/runtest.main/nested/testsuite/bug.test/pr42399.awk
@@ -0,0 +1,35 @@
+#!/usr/bin/awk -f
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of DejaGnu.
+#
+# DejaGnu is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# DejaGnu is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with DejaGnu; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Return a large number of unit test results to test buffer handling and
+# synchronization. This is part of a regression test for PR42399.
+
+BEGIN {
+ # Provide a useful default value.
+ N = 1
+ # Avoid reading stdin if no files were given on the command line.
+ ARGV[ARGC++] = "/dev/null"
+}
+
+END {
+ for (i = 1; i <= N; i++)
+ print "\tPASSED: sample test "i
+}
+
+# EOF \ No newline at end of file
diff --git a/testsuite/runtest.main/pr42399.exp b/testsuite/runtest.main/pr42399.exp
new file mode 100644
index 0000000..1782231
--- /dev/null
+++ b/testsuite/runtest.main/pr42399.exp
@@ -0,0 +1,60 @@
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This file is part of DejaGnu.
+#
+# DejaGnu is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# DejaGnu is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with DejaGnu; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
+# This file is a regression test for PR42399, where timing variations can
+# cause test names to be truncated under certain conditions.
+
+# The bug was originally reported using a C test case, but GNU Awk is
+# sufficiently fast for a simple Awk script to also trigger the bug.
+
+# The bug was originally reported as only affecting long test names, but
+# the underlying issue applies equally to shorter names, as long as the
+# unit test program produces output faster than DejaGnu can read it.
+
+runtest_setup_nested_testsuite
+
+proc test_pr42399 {} {
+ global RUNTEST
+
+ foreach test_count {5 5000} {
+ set result pass
+ set failures [list]
+ set want_num 1
+ set cmd_args [list --local_init nested-init.exp --tool bug \
+ -a pr42399-sub.exp N=$test_count]
+ verbose "Spawning $RUNTEST $cmd_args ..."
+ eval [list spawn $RUNTEST] $cmd_args
+ expect {
+ -re {PASS:[[:space:]]+([^\r\n]*)[\r\n]+} {
+ if { [regexp {sample test ([0-9]+)} \
+ $expect_out(1,string) -> read_num] } {
+ if { $read_num != $want_num } { set result fail }
+ } else { set result fail }
+ incr want_num
+ exp_continue
+ }
+ eof {
+ $result "PR42399 test with $test_count inner tests"
+ }
+ }
+ }
+}
+
+test_pr42399
+
+runtest_cleanup_nested_testsuite