Re: [PATCH v2] of [PATCH v2 42/47] gdb_test_multiple: Anchor prompt match if -lbl

Pedro Alves
2025-06-05T16:38:41Z

Hi!

On 2025-05-28 12:59, Pedro Alves wrote:

> +gdb_test_multiple "command" "" -lbl {
> + -re "^command(?=\r\n)" {
> + verbose -log <COMMAND>
> + incr saw_command
> + exp_continue
> + }
> + -re "^\r\nprefix foo(?=\r\n)" {
> + verbose -log <PREFIX-FOO>
> + incr saw_prefix_foo
> + exp_continue
> + }
> + -re "^\r\nprefix bar(?=\r\n)" {
> + verbose -log <PREFIX-BAR>
> + incr saw_prefix_bar
> + exp_continue
> + }
> + -re "^\r\nprefix (?=\r\n)" {
> + verbose -log <PREFIX>
> + incr saw_prefix
> + exp_continue
> + }

Reading back, I realized that this example looks a bit silly as is, because you could fix it by
just moving the "prefix " case earlier than the "prefix foo/bar" cases. I should make the command output
something after "prefix", like "prefix xxx", and then the regexp should match something like:

-re "^\r\nprefix [^\r\n]*(?=\r\n)" {

That's more like what the original testcase that exposed the issue does.

I'll send an updated patch soon.