[binutils-gdb] [gdb/testsuite] Fix gdb.python/py-selected-context.exp regexp
Tom de Vries via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5ac46e0aa6f18bb265fb4df3a3c9d1d15f2813d1 commit 5ac46e0aa6f18bb265fb4df3a3c9d1d15f2813d1 Author: Tom de Vries <[email protected]> Date: Wed Aug 19 10:35:20 2026 +0200 [gdb/testsuite] Fix gdb.python/py-selected-context.exp regexp On ppc64-linux, with test-case gdb.python/py-selected-context.exp I run into: ... (gdb) info inferiors^M Num Description Connection Executable ^M 1 <null> ^M * 2 <null> ^M (gdb) FAIL: $exp: check inferior 2 was selected ... In contrast, on x86_64-linux, I get: ... (gdb) info inferiors^M Num Description Connection Executable ^M 1 <null> ^M * 2 <null> ^M (gdb) PASS: $exp: check inferior 2 was selected ... The output is identical, so it's surprising that there's a different outcome. The proc doing the check is: ... proc check_inferior { inf testname } { gdb_test "info inferiors" \ "\r\n\\*\\s+[string_to_regexp $inf]\\s+\[^\r\n\]*(?=\r\n)" \ $testname } ... The problem seems to be triggered by the lookahead part '(?=\r\n)': removing it makes the test pass. By switching on some debugging in gdb_test_multiple, we get this info: ... Looking to match ""(?:\r\n\*\s+2\s+[^\r\n]*(?=\r\n))\r\n\(gdb\) $"" ... which shows that the lookahead '(?=\r\n)' is immediately followed by a '\r\n', making the lookahead superfluous. Still, the test should not fail. It fails due to an expect bug [1][2]. But, there's another problem with the regexp. If we use the same proc to try to match inferior 1, we get a FAIL on both setups: ... (gdb) info inferiors^M Num Description Connection Executable ^M * 1 <null> ^M 2 <null> ^M (gdb) FAIL: $exp: check inferior 1 was selected ... The problem is that the regexp doesn't allow a line after the matching line. Fix this this by appending '.*' to the regexp. Doing so also has the effect that we no longer run into the expect problem. While we're at it, rewrite the regexp to a more modern form, and drop the unnecessary string_to_regexp: ... [multi_line \ "" \ [subst_vars {[*]\s+$inf\s+[^\r\n]*(?=\r\n).*}]] ... Tested on x86_64-linux and ppc64-linux. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=34471 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1143513 Diff: --- gdb/testsuite/gdb.python/py-selected-context.exp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.python/py-selected-context.exp b/gdb/testsuite/gdb.python/py-selected-context.exp index 28b9b456003..07ace151f26 100644 --- a/gdb/testsuite/gdb.python/py-selected-context.exp +++ b/gdb/testsuite/gdb.python/py-selected-context.exp @@ -46,7 +46,9 @@ proc event_regexp { inferior {thread "None"} {frame "None"}} { # inferior. INF should be an inferior number, e.g. '1', '2', etc. proc check_inferior { inf testname } { gdb_test "info inferiors" \ - "\r\n\\*\\s+[string_to_regexp $inf]\\s+\[^\r\n\]*(?=\r\n)" \ + [multi_line \ + "" \ + [subst_vars {[*]\s+$inf\s+[^\r\n]*(?=\r\n).*}]] \ $testname }