* [RFC][gdb/testsuite] Remove read1 timeout factor from gdb.base/info-macros.exp
@ 2021-06-24 15:34 Tom de Vries
2021-06-25 14:46 ` Simon Marchi via Gdb-patches
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2021-06-24 15:34 UTC (permalink / raw)
To: gdb-patches
Hi,
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 currently implemented 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"
...
Only removing one use of gdb_test_multiple_with_read1_timeout_factor in the
test-case for now.
Tested on x86_64-linux, which make targets check and check-read1.
Any comments?
Thanks,
- Tom
[gdb/testsuite] Remove read1 timeout factor from gdb.base/info-macros.exp
gdb/testsuite/ChangeLog:
2021-06-24 Tom de Vries <tdevries@suse.de>
* gdb.base/info-macros.exp: Replace
gdb_test_multiple_with_read1_timeout_factor with gdb_test_lines.
* lib/gdb.exp (gdb_test_lines): Add handling or -re-not <regexp>.
---
gdb/testsuite/gdb.base/info-macros.exp | 24 +++++++-----------------
gdb/testsuite/lib/gdb.exp | 31 ++++++++++++++++++++++++++++---
2 files changed, 35 insertions(+), 20 deletions(-)
diff --git a/gdb/testsuite/gdb.base/info-macros.exp b/gdb/testsuite/gdb.base/info-macros.exp
index 19f16814374..6af34ff77cb 100644
--- a/gdb/testsuite/gdb.base/info-macros.exp
+++ b/gdb/testsuite/gdb.base/info-macros.exp
@@ -125,24 +125,14 @@ proc gdb_test_multiple_with_read1_timeout_factor { factor command message \
}
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 \" \""
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 02b65617ea4..543a7dc6b06 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC][gdb/testsuite] Remove read1 timeout factor from gdb.base/info-macros.exp
2021-06-24 15:34 [RFC][gdb/testsuite] Remove read1 timeout factor from gdb.base/info-macros.exp Tom de Vries
@ 2021-06-25 14:46 ` Simon Marchi via Gdb-patches
2021-07-06 10:06 ` Tom de Vries
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi via Gdb-patches @ 2021-06-25 14:46 UTC (permalink / raw)
To: Tom de Vries, gdb-patches
On 2021-06-24 11:34 a.m., Tom de Vries wrote:
> Hi,
>
> 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 currently implemented 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"
> ...
>
> Only removing one use of gdb_test_multiple_with_read1_timeout_factor in the
> test-case for now.
>
> Tested on x86_64-linux, which make targets check and check-read1.
>
> Any comments?
I don't see anything wrong with the patch, seems useful.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC][gdb/testsuite] Remove read1 timeout factor from gdb.base/info-macros.exp
2021-06-25 14:46 ` Simon Marchi via Gdb-patches
@ 2021-07-06 10:06 ` Tom de Vries
0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2021-07-06 10:06 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1397 bytes --]
On 6/25/21 4:46 PM, Simon Marchi wrote:
> On 2021-06-24 11:34 a.m., Tom de Vries wrote:
>> Hi,
>>
>> 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 currently implemented 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"
>> ...
>>
>> Only removing one use of gdb_test_multiple_with_read1_timeout_factor in the
>> test-case for now.
>>
>> Tested on x86_64-linux, which make targets check and check-read1.
>>
>> Any comments?
>
> I don't see anything wrong with the patch, seems useful.
Thanks for the review.
I've now applied this to the whole test-case, and committed as attached.
Thanks,
- Tom
[-- Attachment #2: 0001-gdb-testsuite-Remove-read1-timeout-factor-from-gdb.base-info-macros.exp.patch --]
[-- Type: text/x-patch, Size: 8529 bytes --]
[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-06-24 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>.
---
gdb/testsuite/gdb.base/info-macros.exp | 179 +++++++++------------------------
gdb/testsuite/lib/gdb.exp | 31 +++++-
2 files changed, 74 insertions(+), 136 deletions(-)
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 } {
# '<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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-06 10:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 15:34 [RFC][gdb/testsuite] Remove read1 timeout factor from gdb.base/info-macros.exp Tom de Vries
2021-06-25 14:46 ` Simon Marchi via Gdb-patches
2021-07-06 10:06 ` Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox