diff options
20 files changed, 407 insertions, 140 deletions
@@ -1,3 +1,88 @@ +2020-07-22 Jacob Bachmeyer <jcb62281+dev@gmail.com> + + PR42399 + + * NEWS: Document changes to host_execute. + + * lib/dejagnu.exp (host_execute): Revise expect matching to + combine all unit test protocol lines into one pattern. + (host_execute): Rework other expect patterns. + (host_execute): Ensure that all output from child process is read + until the child closes its output to avoid sending early SIGPIPE. + (host_execute): Report an ERROR (and cause the next test to be + recorded as UNRESOLVED) if the Expect matching buffer overflows. + (host_execute): Remove dependency on global "text" variable. + + * Makefile.am (TESTSUITE_FILES): Update. + + * testsuite/runtest.main/stats.exp: Generalize infrastructure and + add tests for DejaGnu unit testing support. + * testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.exp: + New file. + * testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk: + New file. + +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. + + * testsuite/lib/runtest.exp (runtest_setup_nested_testsuite): New + procedure. + (runtest_cleanup_nested_testsuite): New procedure. + + * testsuite/runtest.main/error.exp: Use the tool name "error" to + select the proper subset of the nested testsuite. Use new + procedures for handling nested testsuite. Use common + nested-init.exp local init file for nested testsuite. Let local + init file nested-init.exp handle setting "outdir" variable. + * testsuite/runtest.main/options.exp: Likewise; "null" tool. + * testsuite/runtest.main/stats.exp: Likewise; "stat" tool. + + * testsuite/runtest.main/nested/: Combine nested testsuites. + * testsuite/runtest.main/error/testsuite/error.test/error-al-dbz.exp: + Move from here... + * testsuite/runtest.main/nested/testsuite/error.test/error-al-dbz.exp: + ...to here. + * testsuite/runtest.main/error/testsuite/error.test/error-dbz.exp: + Move from here... + * testsuite/runtest.main/nested/testsuite/error.test/error-dbz.exp: + ...to here. + * testsuite/runtest.main/error/testsuite/error.test/error-undef.exp: + Move from here... + * testsuite/runtest.main/nested/testsuite/error.test/error-undef.exp: + ...to here. + * testsuite/runtest.main/error/testsuite/error.test/simple.exp: + Move from here... + * testsuite/runtest.main/nested/testsuite/error.test/simple.exp: + ...to here. + * testsuite/runtest.main/options/testsuite/null.test/null.exp: + Move from here... + * testsuite/runtest.main/nested/testsuite/null.test/null.exp: + ...to here. + * testsuite/runtest.main/stats/testsuite/stat.test/stats-sub.exp: + Move from here... + * testsuite/runtest.main/nested/testsuite/stat.test/stats-sub.exp: + ...to here. + 2020-07-16 Rob Savoye <rob@senecass.com> * baseboards/qemu.exp: Works now with qemu instead of sim. diff --git a/Makefile.am b/Makefile.am index 999b25b..92158e1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,7 @@ EXTRA_DIST = ChangeLog-1992 MAINTAINERS dejagnu runtest \ $(commands_DATA) $(TESTSUITE_FILES) $(TEXINFO_TEX)\ $(CONTRIB) -CLEANFILES = error-init.exp options-init.exp stats-init.exp +CLEANFILES = dbg.log nested-init.exp clean-local: clean-local-check .PHONY: clean-local-check @@ -182,14 +182,19 @@ TESTSUITE_FILES = \ testsuite/runtest.libs/target.test \ testsuite/runtest.libs/utils.test \ testsuite/runtest.main/error.exp \ - testsuite/runtest.main/error/testsuite/error.test/error-al-dbz.exp \ - testsuite/runtest.main/error/testsuite/error.test/error-dbz.exp \ - testsuite/runtest.main/error/testsuite/error.test/error-undef.exp \ - testsuite/runtest.main/error/testsuite/error.test/simple.exp \ + testsuite/runtest.main/nested/testsuite/error.test/error-al-dbz.exp \ + testsuite/runtest.main/nested/testsuite/error.test/error-dbz.exp \ + testsuite/runtest.main/nested/testsuite/error.test/error-undef.exp \ + testsuite/runtest.main/nested/testsuite/error.test/simple.exp \ testsuite/runtest.main/options.exp \ - testsuite/runtest.main/options/testsuite/null.test/null.exp \ + testsuite/runtest.main/nested/testsuite/null.test/null.exp \ testsuite/runtest.main/stats.exp \ - testsuite/runtest.main/stats/testsuite/stat.test/stats-sub.exp \ + testsuite/runtest.main/nested/testsuite/stat.test/stats-sub.exp \ + testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk \ + testsuite/runtest.main/nested/testsuite/stat.test/unit-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/Makefile.in b/Makefile.in index fb19047..673a072 100644 --- a/Makefile.in +++ b/Makefile.in @@ -383,7 +383,7 @@ EXTRA_DIST = ChangeLog-1992 MAINTAINERS dejagnu runtest \ $(commands_DATA) $(TESTSUITE_FILES) $(TEXINFO_TEX)\ $(CONTRIB) -CLEANFILES = error-init.exp options-init.exp stats-init.exp +CLEANFILES = dbg.log nested-init.exp bin_SCRIPTS = dejagnu runtest include_HEADERS = dejagnu.h pkgdata_DATA = \ @@ -22,6 +22,15 @@ X. The target_compile procedure now accepts a "linker=" option that overrides the compiler selection when producing an executable. X. The internal default_target_compile procedure now supports compiling sources in Go (using GCC Go) and Rust. +X. The host_execute procedure no longer insists that the executable be in + the current directory if the file exists under the given name. +X. The host_execute procedure now reads input to end-of-file, to ensure + that the child process will be able to complete instead of being cut + short by a SIGPIPE under unpredictable unfavorable timing scenarios. +X. The match patterns in the host_execute procedure have been revised to + fix timing issues causing test names to be truncated. +X. The host_execute procedure is no longer sensitive to the value of the + "text" global variable. 5. A new multiplex procedure "testsuite" is added for commands retrieving or providing information about the current testsuite. 6. A command "testsuite file" is added to replace the use of the diff --git a/lib/dejagnu.exp b/lib/dejagnu.exp index ea363a9..7b2e5c4 100644 --- a/lib/dejagnu.exp +++ b/lib/dejagnu.exp @@ -104,77 +104,70 @@ proc host_compile {compline} { # if there was a problem. # proc host_execute {args} { - global text - set timeoutmsg "Timed out: Never got started, " set timeout 100 set file all 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" } - # spawn the executable and look for the DejaGnu output messages from the - # test case. - # spawn -noecho -open [open "|./${executable}" "r"] - spawn -noecho "./${executable}" $params - set prefix "\[^\r\n\]*" + # Spawn the executable and look for the DejaGnu output messages. + eval [list spawn -noecho $executable] $arguments expect { - -re "^$prefix\[0-9\]\[0-9\]:..:..:${text}*\r\n" { - regsub "\[\n\r\t\]*NOTE: $text\r\n" $expect_out(0,string) "" output - verbose $output 3 - set timetol 0 - exp_continue - } - -re "^$prefix\tNOTE:${text}*" { - regsub "\[\n\r\t\]*NOTE: $text\r\n" $expect_out(0,string) "" output - set output [string range $output 6 end] - verbose $output 2 - set timetol 0 - exp_continue - } - -re "^$prefix\tPASSED:${text}*" { - regsub "\[\n\r\t\]*PASSED: $text\r\n" $expect_out(0,string) "" output - set output [string range $output 8 end] - pass $output + -re {(?:\A|\n)\t([][[:upper:]]+):([^\n]+)\n} { + set output [string trim $expect_out(2,string)] + switch -- $expect_out(1,string) { + NOTE { verbose $output 2 } + PASSED { pass $output } + FAILED { fail $output } + XPASSED { xpass $output } + XFAILED { xfail $output } + UNTESTED { untested $output } + UNRESOLVED { unresolved $output } + default { + unresolved "unknown unit test token $expect_out(1,string)" + } + } set timetol 0 exp_continue } - -re "^$prefix\tFAILED:${text}*" { - regsub "\[\n\r\t\]*FAILED: $text\r\n" $expect_out(0,string) "" output - set output [string range $output 8 end] - fail $output - 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 } - -re "^$prefix\tUNTESTED:${text}*" { - regsub "\[\n\r\t\]*TESTED: $text\r\n" $expect_out(0,string) "" output - set output [string range $output 8 end] - untested $output + -re {^[^\r\n]*([0-9][0-9]:..:..:[^\n]*)\n} { + # No one seems to know why this pattern is here or what it is + # supposed to match. I suspect that it is obsolete. -- jcb, 2020 + verbose [string trim $expect_out(1,string)] 3 set timetol 0 exp_continue } - -re "^$prefix\tUNRESOLVED:${text}*" { - regsub "\[\n\r\t\]*UNRESOLVED: $text\r\n" $expect_out(0,string) "" output - set output [string range $output 8 end] - unresolved $output + -re {^[^\n]*\n} { + # Skip other lines produced by the test program. set timetol 0 exp_continue } - -re "^Totals" { - verbose "All done" 2 + full_buffer { + perror "Expect matching buffer overrun while running\ + $executable $arguments" } eof { } @@ -188,9 +181,6 @@ proc host_execute {args} { return "Timed out executing test case" } } - -re "^$prefix\r\n" { - exp_continue - } } # force a close of the executable to be safe. diff --git a/testsuite/lib/runtest.exp b/testsuite/lib/runtest.exp index 67643b4..bbb541b 100644 --- a/testsuite/lib/runtest.exp +++ b/testsuite/lib/runtest.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1992-2016, 2018 Free Software Foundation, Inc. +# Copyright (C) 1992-2016, 2018, 2020 Free Software Foundation, Inc. # # This file is part of DejaGnu. # @@ -37,6 +37,43 @@ if { [which $EXPECT] == 0 } { } # +# support procedures for running items in a nested testsuite +# +# Note that these procedures establish and use a "tmpdir" variable in the +# caller's context. +proc runtest_setup_nested_testsuite {} { + global host_triplet + upvar 1 tmpdir tmpdir + + if {![info exists tmpdir]} { + set tmpdir [testsuite file -object -top tmpdir] + } + + set fd [open nested-init.exp w] + puts $fd "set host_triplet $host_triplet" + puts $fd "set srcdir [testsuite file -source -test nested]" + puts $fd "set objdir [testsuite file -object -test nested]" + puts $fd "set tmpdir $tmpdir" + puts $fd "set outdir $tmpdir" + close $fd + + if {![file isdirectory $tmpdir]} { + catch {file mkdir $tmpdir} + } + + if {![file isdirectory [testsuite file -object -test nested]]} { + catch {file mkdir [testsuite file -object -test nested]} + } +} + +proc runtest_cleanup_nested_testsuite {} { + upvar 1 tmpdir tmpdir + + file delete -force $tmpdir +} + + +# # runtest_version -- extract and print the version number # proc runtest_version { } { diff --git a/testsuite/runtest.main/error.exp b/testsuite/runtest.main/error.exp index 1473ee1..8d5795f 100644 --- a/testsuite/runtest.main/error.exp +++ b/testsuite/runtest.main/error.exp @@ -22,23 +22,7 @@ load_lib util-defs.exp -if {![info exists tmpdir]} { - set tmpdir [testsuite file -object -top tmpdir] -} - -set fd [open error-init.exp w] -puts $fd "set srcdir [testsuite file -source -test error]" -puts $fd "set objdir [testsuite file -object -test error]" -puts $fd "set tmpdir $tmpdir" -close $fd - -if {![file isdirectory $tmpdir]} { - catch "file mkdir $tmpdir" -} - -if {![file isdirectory [testsuite file -object -test error]]} { - catch {file mkdir [testsuite file -object -test error]} -} +runtest_setup_nested_testsuite set tests { { "run only simple test" @@ -67,8 +51,8 @@ set tests { foreach t $tests { if [util_test $RUNTEST \ - "--local_init error-init.exp\ - --outdir $tmpdir -a [lindex $t 1]" \ + "--local_init nested-init.exp --tool error\ + -a [lindex $t 1]" \ "" \ [lindex $t 2]] { fail [lindex $t 0] @@ -77,5 +61,8 @@ foreach t $tests { } } -file delete -force $tmpdir -file delete -force [testsuite file -object -test error testsuite error.test lib] +runtest_cleanup_nested_testsuite + +# remove the autoload files generated during the test +file delete -force \ + [testsuite file -object -test nested testsuite error.test lib] 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/error/testsuite/error.test/error-al-dbz.exp b/testsuite/runtest.main/nested/testsuite/error.test/error-al-dbz.exp index 52b5bc3..52b5bc3 100644 --- a/testsuite/runtest.main/error/testsuite/error.test/error-al-dbz.exp +++ b/testsuite/runtest.main/nested/testsuite/error.test/error-al-dbz.exp diff --git a/testsuite/runtest.main/error/testsuite/error.test/error-dbz.exp b/testsuite/runtest.main/nested/testsuite/error.test/error-dbz.exp index 463337a..463337a 100644 --- a/testsuite/runtest.main/error/testsuite/error.test/error-dbz.exp +++ b/testsuite/runtest.main/nested/testsuite/error.test/error-dbz.exp diff --git a/testsuite/runtest.main/error/testsuite/error.test/error-undef.exp b/testsuite/runtest.main/nested/testsuite/error.test/error-undef.exp index fa59f4a..fa59f4a 100644 --- a/testsuite/runtest.main/error/testsuite/error.test/error-undef.exp +++ b/testsuite/runtest.main/nested/testsuite/error.test/error-undef.exp diff --git a/testsuite/runtest.main/error/testsuite/error.test/simple.exp b/testsuite/runtest.main/nested/testsuite/error.test/simple.exp index 93a03e7..93a03e7 100644 --- a/testsuite/runtest.main/error/testsuite/error.test/simple.exp +++ b/testsuite/runtest.main/nested/testsuite/error.test/simple.exp diff --git a/testsuite/runtest.main/options/testsuite/null.test/null.exp b/testsuite/runtest.main/nested/testsuite/null.test/null.exp index f6f11af..f6f11af 100644 --- a/testsuite/runtest.main/options/testsuite/null.test/null.exp +++ b/testsuite/runtest.main/nested/testsuite/null.test/null.exp diff --git a/testsuite/runtest.main/stats/testsuite/stat.test/stats-sub.exp b/testsuite/runtest.main/nested/testsuite/stat.test/stats-sub.exp index c797ad1..c797ad1 100644 --- a/testsuite/runtest.main/stats/testsuite/stat.test/stats-sub.exp +++ b/testsuite/runtest.main/nested/testsuite/stat.test/stats-sub.exp diff --git a/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk b/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk new file mode 100644 index 0000000..c02f7ea --- /dev/null +++ b/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.awk @@ -0,0 +1,39 @@ +# 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. + +BEGIN { + # Avoid reading stdin if no files were given on the command line. + ARGV[ARGC++] = "/dev/null" +} + +END { + if (UNIT_RESULT == "pass") + print "\tPASSED: sample unit test" + else if (UNIT_RESULT == "fail") + print "\tFAILED: sample unit test" + else if (UNIT_RESULT == "xpass") + print "\tXPASSED: sample unit test" + else if (UNIT_RESULT == "xfail") + print "\tXFAILED: sample unit test" + else if (UNIT_RESULT == "untested") + print "\tUNTESTED: sample unit test" + else if (UNIT_RESULT == "unresolved") + print "\tUNRESOLVED: sample unit test" +} + +# EOF diff --git a/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.exp b/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.exp new file mode 100644 index 0000000..96f8ac3 --- /dev/null +++ b/testsuite/runtest.main/nested/testsuite/stat.test/unit-sub.exp @@ -0,0 +1,26 @@ +# 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. + +# Functional test for DejaGnu unit testing; inner runtest component. + +load_lib dejagnu.exp + +if { [info exists STATS_TEST] } { + host_execute [which awk] -f [testsuite file -source -test unit-sub.awk] \ + UNIT_RESULT=$STATS_TEST +} diff --git a/testsuite/runtest.main/options.exp b/testsuite/runtest.main/options.exp index abbdc6a..2e2d81c 100644 --- a/testsuite/runtest.main/options.exp +++ b/testsuite/runtest.main/options.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1992-2016, 2018 Free Software Foundation, Inc. +# Copyright (C) 1992-2016, 2018, 2020 Free Software Foundation, Inc. # # This file is part of DejaGnu. # @@ -20,25 +20,7 @@ load_lib util-defs.exp -if {![info exists tmpdir]} { - set tmpdir [testsuite file -object -top tmpdir] -} - -set fd [open options-init.exp w] -puts $fd "set host_triplet $host_triplet" -puts $fd "set srcdir [testsuite file -source -test options]" -puts $fd "set objdir [testsuite file -object -test options]" -puts $fd "set tmpdir $tmpdir" -puts $fd "set outdir [testsuite file -object -test options]" -close $fd - -if {![file isdirectory $tmpdir]} { - catch "file mkdir $tmpdir" -} - -if {![file isdirectory [testsuite file -object -test options]]} { - catch {file mkdir [testsuite file -object -test options]} -} +runtest_setup_nested_testsuite # # Set up the list. @@ -52,7 +34,7 @@ set tests { { "--help" "USAGE:*" "Display help" } { "-v -v -v" "Verbose level is 3" "Verbose set correctly" } { "-v --tool xXx" - "Found.*options-init\..*Loading.*utils\.exp" + "Found.*nested-init\..*Loading.*utils\.exp" "Loading library files" } { "-v --tool xXx" "Expect binary is.*Using.*main test driver" @@ -112,7 +94,7 @@ set tests { foreach t $tests { if [util_test $RUNTEST \ - "[lindex $t 0] --local_init options-init.exp" \ + "[lindex $t 0] --local_init nested-init.exp --tool null" \ "" \ "[lindex $t 1]"] { fail "[lindex $t 2]" @@ -121,8 +103,4 @@ foreach t $tests { } } -# clean up log files left by the child runtest -foreach f [glob [testsuite file -object -test options *]] { - file delete $f -} -file delete -force $tmpdir +runtest_cleanup_nested_testsuite 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 diff --git a/testsuite/runtest.main/stats.exp b/testsuite/runtest.main/stats.exp index a81c8e6..7f4f5be 100644 --- a/testsuite/runtest.main/stats.exp +++ b/testsuite/runtest.main/stats.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1995-2016, 2018 Free Software Foundation, Inc. +# Copyright (C) 1995-2016, 2018, 2020 Free Software Foundation, Inc. # # This file is part of DejaGnu. # @@ -22,46 +22,37 @@ load_lib util-defs.exp -if {![info exists tmpdir]} { - set tmpdir [testsuite file -object -top tmpdir] -} - -set fd [open stats-init.exp w] -puts $fd "set srcdir [testsuite file -source -test stats]" -puts $fd "set objdir [testsuite file -object -test stats]" -puts $fd "set tmpdir $tmpdir" -close $fd - -if {![file isdirectory $tmpdir]} { - catch "file mkdir $tmpdir" -} - -if {![file isdirectory [testsuite file -object -test stats]]} { - catch {file mkdir [testsuite file -object -test stats]} -} +runtest_setup_nested_testsuite set tests { - { pass "expected passes\[ \t\]+1\n" } - { fail "unexpected failures\[ \t\]+1\n" } - { xpass "unexpected successes\[ \t\]+1\n" } - { xfail "expected failures\[ \t\]+1\n" } - { kpass "unknown successes\[ \t\]+1\n" } - { kfail "known failures\[ \t\]+1\n" } - { untested "untested testcases\[ \t\]+1\n" } - { unresolved "unresolved testcases\[ \t\]+1\n" } - { unsupported "unsupported tests\[ \t\]+1\n" } + { stats pass "expected passes\[ \t\]+1\n" } + { stats fail "unexpected failures\[ \t\]+1\n" } + { stats xpass "unexpected successes\[ \t\]+1\n" } + { stats xfail "expected failures\[ \t\]+1\n" } + { stats kpass "unknown successes\[ \t\]+1\n" } + { stats kfail "known failures\[ \t\]+1\n" } + { stats untested "untested testcases\[ \t\]+1\n" } + { stats unresolved "unresolved testcases\[ \t\]+1\n" } + { stats unsupported "unsupported tests\[ \t\]+1\n" } + + { unit pass "expected passes\[ \t\]+1\n" } + { unit fail "unexpected failures\[ \t\]+1\n" } + { unit xpass "unexpected successes\[ \t\]+1\n" } + { unit xfail "expected failures\[ \t\]+1\n" } + { unit untested "untested testcases\[ \t\]+1\n" } + { unit unresolved "unresolved testcases\[ \t\]+1\n" } } foreach t $tests { - if [util_test $RUNTEST \ - "--local_init stats-init.exp\ - --outdir $tmpdir STATS_TEST=[lindex $t 0] stats-sub.exp" \ + if { [util_test $RUNTEST \ + "--local_init nested-init.exp --tool stat\ + STATS_TEST=[lindex $t 1] [lindex $t 0]-sub.exp" \ "" \ - [lindex $t 1]] { - fail [lindex $t 0] + [lindex $t 2]] } { + fail "[lindex $t 0]/[lindex $t 1]" } else { - pass [lindex $t 0] + pass "[lindex $t 0]/[lindex $t 1]" } } -file delete -force $tmpdir +runtest_cleanup_nested_testsuite |