From: Tom de Vries <tdevries@suse.de>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/testsuite] Add -cooked pattern flag to gdb_test_multiple
Date: Sun, 06 Oct 2019 08:29:00 -0000 [thread overview]
Message-ID: <f2289ccd-f442-1ed5-7d17-53b3c03300a2@suse.de> (raw)
In-Reply-To: <20191005153835.GL4962@embecosm.com>
[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]
On 05-10-19 17:38, Andrew Burgess wrote:
> * Tom de Vries <tdevries@suse.de> [2019-10-05 08:05:03 +0200]:
>
>> [ was: Re: [PATCH][gdb/testsuite] Introduce gdb_test_ext ]
>>
>> On 19-09-19 21:24, Andrew Burgess wrote:
>>> On further thought, I actually think there's no need for an extra
>>> function at all, we can get all the benefit (as I see it) by possibly
>>> updating gdb_test_multiple. I'm travelling right now so can't code
>>> this up, but I think a solution that does something like this:
>>>
>>> gdb_test_multiple "command" "test name" {
>>> -re "full regexp here$gdb_prompt" {
>>> pass $gdb_test_multiple_name
>>> }
>>> -output "pattern without prompt" {
>>> fail $gdb_test_multiple_name
>>> }
>>> }
>>>
>>> So using '-re' and '-output' to specialise the behaviour of
>>> gdb_test_multiple, and adding in the $gdb_test_multiple_name variable.
>>>
>>> When I get back to my desk I'll try to code this up.
>>
>> Hi,
>>
>> I took a stab at this. I'm not sure about the naming though.
>>
>> For the pattern flag I used the name -cooked. Perhaps -wrap is better?
>> Any better suggestions?
>>
>> I used gdb_test_multiple_message (using the 'message' postfix because it
>> matched the name of the gdb_test_multiple argument) for the convenience
>> variable, but it's a tad long, perhaps we could abbreviate to
>> 'gtm_message'?
>
> This duplicates work in this patch:
>
> https://sourceware.org/ml/gdb-patches/2019-10/msg00023.html
>
I've rebased on top of that patch (with gdb_test_multiple_name ->
gdb_test_name applied).
Thanks,
- Tom
[-- Attachment #2: 0002-gdb-testsuite-Add-cooked-pattern-flag-to-gdb_test_multiple.patch --]
[-- Type: text/x-patch, Size: 3387 bytes --]
[gdb/testsuite] Add -cooked pattern flag to gdb_test_multiple
Currently, in order to rewrite:
...
gdb_test <command> <pattern> <message>
...
using gdb_test_multiple, we get:
...
gdb_test_multiple <command> <message> {
-re "\[\r\n\]*(?:<pattern>)\[\r\n\]+$gdb_prompt $" {
pass $gdb_test_name
}
}
...
Add a '-cooked' pattern flag to gdb_test_multiple, that wraps the regexp
pattern as gdb_test wraps its message argument.
This allows us to rewrite into the more compact:
...
gdb_test_multiple <command> <message> {
-re -cooked <pattern> {
pass $gdb_test_name
}
}
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-10-04 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_test_multiple): Add -cooked pattern flag.
* gdb.reverse/step-precsave.exp: Rewrite gdb_test_multiple containing
kfail using -cooked pattern flag and convenience variable
gdb_test_name.
---
gdb/testsuite/gdb.reverse/step-precsave.exp | 13 +++++--------
gdb/testsuite/lib/gdb.exp | 14 +++++++++++++-
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp
index 2073b8a1542..3ce786fc4c9 100644
--- a/gdb/testsuite/gdb.reverse/step-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/step-precsave.exp
@@ -46,15 +46,12 @@ gdb_test "break $end_of_main" \
# This can take awhile.
with_timeout_factor 20 {
- set test "run to end of main"
- set pass_pattern "Breakpoint .* end of main .*"
- set kfail_pattern "Process record does not support instruction 0xc5 at.*"
- gdb_test_multiple "continue" $test {
- -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" {
- pass $test
+ gdb_test_multiple "continue" "run to end of main" {
+ -re -cooked "Breakpoint .* end of main .*" {
+ pass $gdb_test_name
}
- -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" {
- kfail "record/23188" $test
+ -re -cooked "Process record does not support instruction 0xc5 at.*" {
+ kfail "record/23188" $gdb_test_name
}
}
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index d23d51572cc..f73313f1cb0 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -821,6 +821,7 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } {
set patterns ""
set expecting_action 0
set expecting_arg 0
+ set cooked 0
foreach item $user_code subst_item $subst_code {
if { $item == "-n" || $item == "-notransfer" || $item == "-nocase" } {
lappend processed_code $item
@@ -835,6 +836,10 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } {
lappend processed_code $item
continue
}
+ if { $item == "-cooked" } {
+ set cooked 1
+ continue
+ }
if { $expecting_arg } {
set expecting_arg 0
lappend processed_code $subst_item
@@ -848,7 +853,14 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } {
continue
}
set expecting_action 1
- lappend processed_code $subst_item
+ if { $cooked } {
+ # Wrap subst_item as is done for the gdb_test PATTERN argument.
+ lappend processed_code \
+ "\[\r\n\]*(?:$subst_item)\[\r\n\]+$gdb_prompt $"
+ set cooked 0
+ } else {
+ lappend processed_code $subst_item
+ }
if {$patterns != ""} {
append patterns "; "
}
prev parent reply other threads:[~2019-10-06 8:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 11:13 [PATCH][gdb/testsuite] Introduce gdb_test_ext Tom de Vries
2019-09-19 16:18 ` Andrew Burgess
2019-09-19 19:01 ` Tom de Vries
2019-09-19 19:24 ` Andrew Burgess
2019-09-19 21:50 ` Tom de Vries
2019-10-05 6:05 ` [PATCH][gdb/testsuite] Add -cooked pattern flag to gdb_test_multiple Tom de Vries
2019-10-05 15:38 ` Andrew Burgess
2019-10-06 6:37 ` Tom de Vries
2019-10-07 10:30 ` Andrew Burgess
2019-10-06 8:29 ` Tom de Vries [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f2289ccd-f442-1ed5-7d17-53b3c03300a2@suse.de \
--to=tdevries@suse.de \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox