[03/29] gdb/testsuite: Remove duplicates from gdb.base/interp.exp

Message ID 20211121175636.779325-4-lsix@lancelotsix.com
State New
Headers show
Series
  • Remove DUPLICATEs from testsuite/gdb.base/*.exp
Related show

Commit Message

Mike Frysinger via Gdb-patches Nov. 21, 2021, 5:56 p.m.
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 two successive instances of
gdb_test_multiple use 'pass $cmd', but the second test forgets to reset
$cmd.

Fix by updating the value of cmd where appropriate.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.base/interp.exp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.33.1

Comments

Pedro Alves Nov. 22, 2021, 2:13 p.m. | #1
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
Mike Frysinger via Gdb-patches Nov. 22, 2021, 5:33 p.m. | #2
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
From 318524ca1ac8fe3eeb2555f59f0b15fe88edcd74 Mon Sep 17 00:00:00 2001
From: Lancelot SIX <lsix@lancelotsix.com>

Date: Fri, 19 Nov 2021 19:55:05 +0000
Subject: [PATCH v2] 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

Patch

diff --git a/gdb/testsuite/gdb.base/interp.exp b/gdb/testsuite/gdb.base/interp.exp
index fc95ee113c2..3d28232c522 100644
--- a/gdb/testsuite/gdb.base/interp.exp
+++ b/gdb/testsuite/gdb.base/interp.exp
@@ -34,8 +34,8 @@  gdb_test_multiple $cmd $cmd {
 gdb_test "interpreter-exec console \"show version\"" "GNU gdb .*"
 
 # 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" {
 	-re ".error,msg=.Invalid value for the '--thread' option.\r\n$gdb_prompt " {
 	    pass "$cmd"
 	    gdb_expect 1 {