From 89f58b27832f8fc7b443988d02e56cfaba12eb5a Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Mon, 20 Jul 2020 21:39:21 -0500 Subject: Add regression test for PR42399 --- lib/dejagnu.exp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lib') 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" { -- cgit v1.1 From 264bd34c28a16e18860dbc69a21a96c1be130b08 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Wed, 22 Jul 2020 21:28:24 -0500 Subject: Revise host_execute to fix PR42399 --- lib/dejagnu.exp | 71 +++++++++++++++++++++++---------------------------------- 1 file changed, 29 insertions(+), 42 deletions(-) (limited to 'lib') diff --git a/lib/dejagnu.exp b/lib/dejagnu.exp index e1060ae..7b2e5c4 100644 --- a/lib/dejagnu.exp +++ b/lib/dejagnu.exp @@ -104,8 +104,6 @@ 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 @@ -129,55 +127,47 @@ proc host_execute {args} { 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 the executable and look for the DejaGnu output messages. eval [list spawn -noecho $executable] $arguments - set prefix "\[^\r\n\]*" 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 { } @@ -191,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. -- cgit v1.1