From: Tom de Vries Date: Tue, 6 Jul 2021 10:05:37 +0000 (+0200) Subject: [gdb/testsuite] Remove read1 timeout factor from gdb.base/info-macros.exp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0d4e283965dae2c05cf0c85dccea6144a2c6293e;p=binutils-gdb.git [gdb/testsuite] Remove read1 timeout factor from gdb.base/info-macros.exp At the moment some check-read1 timeouts are handled like this in gdb.base/info-macros.exp: ... gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { -re "$r1$r2$r3" { pass $testname } -re ".*#define TWO.*\r\n$gdb_prompt" { fail $testname } -re ".*#define THREE.*\r\n$gdb_prompt" { fail $testname } -re ".*#define FOUR.*\r\n$gdb_prompt" { fail $testname } } ... which is not ideal. We could use gdb_test_lines, but it currently doesn't support verifying the absence of regexps, which is done using the clauses above calling fail. Fix this by using gdb_test_lines and adding a -re-not syntax to gdb_test_lines, such that we can do: ... gdb_test_lines $test $testname $r1.*$r2 \ -re-not "#define TWO" \ -re-not "#define THREE" \ -re-not "#define FOUR" ... Tested on x86_64-linux, whith make targets check and check-read1. Also observed that check-read1 execution time is reduced from 6m35s to 13s. gdb/testsuite/ChangeLog: 2021-07-06 Tom de Vries * gdb.base/info-macros.exp: Replace use of gdb_test_multiple_with_read1_timeout_factor with gdb_test_lines. (gdb_test_multiple_with_read1_timeout_factor): Remove. * lib/gdb.exp (gdb_test_lines): Add handling or -re-not . --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a6171ade8a9..a7fa58d769a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2021-07-06 Tom de Vries + + * gdb.base/info-macros.exp: Replace use of + gdb_test_multiple_with_read1_timeout_factor with gdb_test_lines. + (gdb_test_multiple_with_read1_timeout_factor): Remove. + * lib/gdb.exp (gdb_test_lines): Add handling or -re-not . + 2021-07-05 Tom de Vries * gdb.fortran/ptype-on-functions.exp: Allow both $integer8 and diff --git a/gdb/testsuite/gdb.base/info-macros.exp b/gdb/testsuite/gdb.base/info-macros.exp index 19f16814374..538279fd309 100644 --- a/gdb/testsuite/gdb.base/info-macros.exp +++ b/gdb/testsuite/gdb.base/info-macros.exp @@ -117,161 +117,74 @@ gdb_test "$test" "$r1$r2$r3$r4" set test "info macro -a -- FOO" gdb_test "$test" "$r1$r2$r3$r4" -proc gdb_test_multiple_with_read1_timeout_factor { factor command message \ - user_code } { - with_read1_timeout_factor $factor { - uplevel [list gdb_test_multiple $command $message $user_code] - } -} - set test "info macros" -set r1 ".*#define FOO \"hello\"" -set r2 ".*#define ONE" -set r3 ".*\r\n$gdb_prompt" +set r1 "#define FOO \"hello\"" +set r2 "#define ONE" set testname "$test 2" -gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { - -re "$r1$r2$r3" { - pass $testname - } - -re ".*#define TWO.*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define THREE.*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define FOUR.*\r\n$gdb_prompt" { - fail $testname - } -} +gdb_test_lines $test $testname $r1.*$r2 \ + -re-not "#define TWO" \ + -re-not "#define THREE" \ + -re-not "#define FOUR" + gdb_test "next" ".*" "" -set r1 ".*#define FOO \" \"" -set r2 ".*#define ONE" -set r3 ".*#define TWO" -set r4 ".*\r\n$gdb_prompt" +set r1 "#define FOO \" \"" +set r2 "#define ONE" +set r3 "#define TWO" set testname "$test 3" -gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { - -re ".*#define THREE.*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define FOUR.*\r\n$gdb_prompt" { - fail $testname - } - -re "$r1$r2$r3$r4" { - pass $testname - } -} +gdb_test_lines $test $testname $r1.*$r2.*$r3 \ + -re-not "#define THREE" \ + -re-not "#define FOUR" + gdb_test "next" ".*" "" # in alpabetical order... -set r1 ".*#define FOO \"world\"" -set r2 ".*#define ONE" -set r3 ".*#define THREE" -set r4 ".*#define TWO" -set r5 ".*\r\n$gdb_prompt" +set r1 "#define FOO \"world\"" +set r2 "#define ONE" +set r3 "#define THREE" +set r4 "#define TWO" set testname "$test 4" -gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { - -re ".*#define FOUR.*\r\n$gdb_prompt" { - fail $testname - } - -re "$r1$r2$r3$r4$r5" { - pass $testname - } -} +gdb_test_lines $test $testname $r1.*$r2.*$r3.*$r4 \ + -re-not "#define FOUR" + # same as above with a linespec. set test "info macros *\$pc" -gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test { - -re ".*#define FOUR.*\r\n$gdb_prompt" { - fail $test - } - -re "$r1$r2$r3$r4$r5" { - pass $test - } -} +gdb_test_lines $test "" $r1.*$r2.*$r3.*$r4 \ + -re-not "#define FOUR" gdb_test "next" ".*" "" -set r1 ".*#define FOO \" \"" -set r2 ".*#define ONE" -set r3 ".*#define TWO." -set r4 ".*\r\n$gdb_prompt" +set r1 "#define FOO \" \"" +set r2 "#define ONE" +set r3 "#define TWO." set test "info macros" set testname "$test 5" -gdb_test_multiple_with_read1_timeout_factor 10 "$test" $test { - -re ".*#define THREE.*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define FOUR.*\r\n$gdb_prompt" { - fail $testname - } - -re "$r1$r2$r3$r4" { - pass $testname - } -} +gdb_test_lines $test $testname $r1.*$r2.*$r3 \ + -re-not "#define THREE" \ + -re-not "#define FOUR" gdb_test "next" ".*" "" gdb_test "next" ".*" "" -set r1 ".*#define DEF_MACROS" -set r2 ".*\r\n$gdb_prompt" +set r1 "#define DEF_MACROS" set testname "$test 6" -gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { - -re ".*#define FOO \" \".*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define FOO \"world\".*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define FOO\\(a\\) foo = a.*" { - fail $testname - } - -re ".*#define ONE.*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define TWO.*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define THREE.*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define FOUR.*\r\n$gdb_prompt" { - fail $testname - } - -re "$r1$r2" { - pass $testname - } -} +gdb_test_lines $test $testname $r1 \ + -re-not "#define FOO" \ + -re-not "#define ONE" \ + -re-not "#define TWO" \ + -re-not "#define THREE" \ + -re-not "#define FOUR" gdb_test "next" ".*" "" -set r1 ".*#define DEF_MACROS" -set r2 ".*#define FOO\\(a\\) foo = a" -set r3 ".*#define FOUR" -set r4 ".*\r\n$gdb_prompt" +set r1 "#define DEF_MACROS" +set r2 "#define FOO\\(a\\) foo = a" +set r3 "#define FOUR" set testname "$test 7" -gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname { - -re ".*#define FOO \" \".*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define FOO \"hello\".*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define FOO \"world\".*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define ONE.*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define TWO.*\r\n$gdb_prompt" { - fail $testname - } - -re ".*#define THREE.*\r\n$gdb_prompt" { - fail $testname - } - -re "$r1$r2$r3$r4" { - pass $testname - } -} +gdb_test_lines $test $testname $r1.*$r2.*$r3 \ + -re-not "#define FOO \" \"" \ + -re-not "#define FOO \"hello\"" \ + -re-not "#define FOO \"world\"" \ + -re-not "#define ONE" \ + -re-not "#define TWO" \ + -re-not "#define THREE" set test "info macros info-macros.c:42" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 38f40fdddb5..6b6a70a89b0 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1443,13 +1443,34 @@ proc gdb_test_sequence { args } { # '^M # ^M # ' +# +# Optionally, additional -re-not arguments can be specified, to +# ensure that a regexp is not match by the COMMAND output. +# Such an additional argument generates an additional PASS/FAIL of the form: +# PASS: test-case.exp: $message: pattern not matched: + +proc gdb_test_lines { command message re args } { + set re_not [list] + + for {set i 0} {$i < [llength $args]} {incr i} { + set arg [lindex $args $i] + if { $arg == "-re-not" } { + incr i + if { [llength $args] == $i } { + error "Missing argument for -re-not" + break + } + set arg [lindex $args $i] + lappend re_not $arg + } else { + error "Unhandled argument: $arg" + } + } -proc gdb_test_lines { command message re } { - set found 0 - set idx 0 if { $message == ""} { set message $command } + set lines "" gdb_test_multiple $command $message { -re "\r\n(\[^\r\n\]*)(?=\r\n)" { @@ -1467,6 +1488,10 @@ proc gdb_test_lines { command message re } { } gdb_assert { [regexp $re $lines] } $message + + foreach re $re_not { + gdb_assert { ![regexp $re $lines] } "$message: pattern not matched: $re" + } } # Test that a command gives an error. For pass or fail, return