On Mon, Nov 22, 2021 at 02:13:59PM +0000, Pedro Alves wrote: > On 2021-11-21 17:56, Lancelot SIX via Gdb-patches wrote: > > # Regression test for crash when an exception occurs in mi_parse. > > -gdb_test_multiple "interpreter-exec mi \"-break-insert --thread a\"" \ > > - "regression test for mi_parse crash" { > > +set cmd "interpreter-exec mi \"-break-insert --thread a\"" > > +gdb_test_multiple $cmd "regression test for mi_parse crash" { > > This "regression test for mi_parse crash" message is used if this > gdb_test_multiple detects an internal error, a timeout, etc. > > > -re ".error,msg=.Invalid value for the '--thread' option.\r\n$gdb_prompt " { > > pass "$cmd" > > ... while here we use $cmd. > > This means that this test can have its result oscillate like this: > > -FAIL: regression test for mi_parse crash" > +PASS: interpreter-exec mi "-break-insert --thread a" > ... > +PASS: interpreter-exec mi "-break-insert --thread a" > -FAIL: regression test for mi_parse crash" > > > The "modern" pattern would be to not have a $cmd variable at all, pass an empty > string as second argument to gdb_test_multiple, and then passing $gdb_test_name > to "pass". Like: > > gdb_test_multiple "interpreter-exec mi \"-break-insert --thread a\"" "" { > -re .... { > pass $gdb_test_multiple > } > } > > > Though simplest is to pass $cmd as second argument too like other > gdb_test_multiple invocations in the file: > > gdb_test_multiple $cmd $cmd { > ... > > > > Could you take care of this while at it? > > Pedro Alves Hi, Thanks for the inputs. I have updated the patch as follows. This could maybe be split into two independent patches (one to fix the DUPLICATE, which is a one-liner, and to refactor the various uses of gdb_test_multiple), but I stayed with one which does the fix and enforces consistency across the file. Lancelot. --- gdb/testsuite: Remove duplicates from gdb.base/interp.exp When running the testsuite I have: Running .../gdb/testsuite/gdb.base/interp.exp ... DUPLICATE: gdb.base/interp.exp: interpreter-exec mi "-var-update *" This is due to the fact that multiple successive instances of gdb_test_multiple use 'pass $cmd', but one of them forgets to reset $cmd to a new test name. Fix by using 'pass $gdb_test_name', given that the gdb_test_name is set by gdb_test_multiple. While fixing this, this patch refactors all occurrences of the following pattern: set cmd foo gdb_test_multiple $cmd $cmd { -re ... { pass $cmd } } into gdb_test_multiple foo "" { -re ... { pass $gdb_test_name } } This makes this test file coherent in its use of $gdb_test_name. Tested on x86_64-linux. --- gdb/testsuite/gdb.base/interp.exp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/gdb/testsuite/gdb.base/interp.exp b/gdb/testsuite/gdb.base/interp.exp index fc95ee113c2..1f2bde250fc 100644 --- a/gdb/testsuite/gdb.base/interp.exp +++ b/gdb/testsuite/gdb.base/interp.exp @@ -22,10 +22,9 @@ if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile {debug}] } { } # Do not use gdb_test for this test, since it has two prompts. -set cmd "interpreter-exec mi \"-var-update *\"" -gdb_test_multiple $cmd $cmd { +gdb_test_multiple "interpreter-exec mi \"-var-update *\"" "" { -re "\\^done,changelist=\\\[\\\]\r\n$gdb_prompt " { - pass "$cmd" + pass $gdb_test_name gdb_expect 1 { -re "\r\n$gdb_prompt $" { } } @@ -37,47 +36,43 @@ gdb_test "interpreter-exec console \"show version\"" "GNU gdb .*" gdb_test_multiple "interpreter-exec mi \"-break-insert --thread a\"" \ "regression test for mi_parse crash" { -re ".error,msg=.Invalid value for the '--thread' option.\r\n$gdb_prompt " { - pass "$cmd" + pass $gdb_test_name gdb_expect 1 { -re "\r\n$gdb_prompt $" { } } } } -set cmd "interpreter-exec mi \"-stack-info-frame\"" -gdb_test_multiple $cmd $cmd { +gdb_test_multiple "interpreter-exec mi \"-stack-info-frame\"" "" { -re ".error,msg=.No registers\..\r\n$gdb_prompt " { - pass "$cmd" + pass $gdb_test_name gdb_expect 1 { -re "\r\n$gdb_prompt $" { } } } } -set cmd "interpreter-exec mi1 \"-break-insert main\"" -gdb_test_multiple $cmd $cmd { +gdb_test_multiple "interpreter-exec mi1 \"-break-insert main\"" "" { -re ".done.bkpt=.number=.\[0-9\]\[^\n\]+\r\n$gdb_prompt " { - pass "$cmd" + pass $gdb_test_name gdb_expect 1 { -re "\r\n$gdb_prompt $" { } } } } -set cmd "interpreter-exec mi2 \"-break-insert main\"" -gdb_test_multiple $cmd $cmd { +gdb_test_multiple "interpreter-exec mi2 \"-break-insert main\"" "" { -re ".done.bkpt=.number=.\[0-9\]\[^\n\]+\r\n$gdb_prompt " { - pass "$cmd" + pass $gdb_test_name gdb_expect 1 { -re "\r\n$gdb_prompt $" { } } } } -set cmd "interpreter-exec mi3 \"-break-insert main\"" -gdb_test_multiple $cmd $cmd { +gdb_test_multiple "interpreter-exec mi3 \"-break-insert main\"" "" { -re ".done.bkpt=.number=.\[0-9\]\[^\n\]+\r\n$gdb_prompt " { - pass "$cmd" + pass $gdb_test_name gdb_expect 1 { -re "\r\n$gdb_prompt $" { } } -- 2.33.1