Re: [PATCH] gdb/testsuite: Add gdb_test_multiple_name variable

Tom de Vries
2019-10-06T08:24:59Z

On 01-10-19 19:28, Andrew Burgess wrote:
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 3a1f053cf8a..a472650cc75 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -719,10 +719,24 @@ proc gdb_internal_error_resync {} {
> #
> # gdb_test_multiple "print foo" "test foo" {
> # -re "expected output 1" {
> -# pass "print foo"
> +# pass "test foo"
> # }
> # -re "expected output 2" {
> -# fail "print foo"
> +# fail "test foo"
> +# }
> +# }
> +#
> +# Within action elements you can also make use of the variable
> +# gdb_test_multiple_name, this variable is setup automatically by
> +# gdb_test_multiple, and contains the value of MESSAGE. You can then
> +# write this, which is equivalent to the above:
> +#

I'd split up the first line, f.i. like so:
...
# Within action elements you can also make use of the variable
# gdb_test_multiple_name. This variable is setup automatically by
# gdb_test_multiple, and contains the value of MESSAGE.
...

> +# gdb_test_multiple "print foo" "test foo" {
> +# -re "expected output 1" {
> +# pass $gdb_test_multiple_name
> +# }
> +# -re "expected output 2" {
> +# fail $gdb_test_multiple_name
> # }
> # }
> #
> @@ -1038,8 +1052,28 @@ proc gdb_test_multiple { command message user_code { prompt_regexp "" } } {
> }
> }
>
> + # Create gdb_test_multiple_name in the parent scope. If this
> + # variable already exists, which is might if we have nested calls

is -> it

> + # to gdb_test_multiple, then preserve the old value, otherwise,
> + # create a new variable in the parent scope.
> + upvar gdb_test_multiple_name gdb_test_multiple_name
> + if { [info exists gdb_test_multiple_name] } {
> + set gdb_test_multiple_name_old "$gdb_test_multiple_name"
> + }
> + set gdb_test_multiple_name "$message"
> +
> set result 0
> set code [catch {gdb_expect $code} string]
> +
> + # Clean up the gdb_test_multiple_name variable. If we had a
> + # previous value then restore it, otherwise, delete the variable
> + # from the parent scope.
> + if { [info exists gdb_test_multiple_name_old] } {
> + set gdb_test_multiple_name "$gdb_test_multiple_name_old"
> + } else {
> + unset gdb_test_multiple_name
> + }
> +
> if {$code == 1} {
> global errorInfo errorCode
> return -code error -errorinfo $errorInfo -errorcode $errorCode $string
>

Other than these nits, looks good to me.

[ FWIW, Pedro's suggestion of using gdb_test_name instead of
gdb_test_multiple_name is fine by me. ]

Thanks,
- Tom