[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  <tdevries@suse.de>

	* 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 <regexp>.
This commit is contained in:
Tom de Vries 2021-07-06 12:05:37 +02:00
parent 70a590636b
commit 0d4e283965
3 changed files with 81 additions and 136 deletions

View File

@ -1,3 +1,10 @@
2021-07-06 Tom de Vries <tdevries@suse.de>
* 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 <regexp>.
2021-07-05 Tom de Vries <tdevries@suse.de>
* gdb.fortran/ptype-on-functions.exp: Allow both $integer8 and

View File

@ -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"

View File

@ -1443,13 +1443,34 @@ proc gdb_test_sequence { args } {
# '<line1>^M
# <line2>^M
# '
#
# Optionally, additional -re-not <regexp> 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: <regexp>
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