Re: Dejagnu testing issue

Jan Kratochvil
2011-10-21T08:33:03Z

On Fri, 21 Oct 2011 10:14:42 +0200, Kevin Pouget wrote:
> for the record, here is the way to get the pid based on "expect_out":
>
> gdb_test_multiple "info inferior" "list inferiors" {
> -re ".* \* 1.*process (\[0-9\]*).*$gdb_prompt $" {
> set pid $expect_out(1,string)
> pass "list inferiors"
> }
> }

While it works to make it working as was intended it could be for example:

gdb_test_multiple "info inferior" "list inferiors" {
-re "\r\n\\* 1 *process (\[0-9\]*) .*\r\n$gdb_prompt $" {
set pid $expect_out(1,string)
pass "list inferiors"
}
}

Initial .* is redundant, start of the expect string is not anchored.

\* is equal to * as the first level of backslashes is parsed by TCL
interpreter, not by the regex compiler.

If one fixes \* -> \\* to really match an asterisk it no longer matches.
The asterisk is preceded by a newline, not by a space as in your regex string.

Regards,
Jan