gdb/testsuite: Fix runtime-core.exp wave ordering dependency#196
Conversation
lancesix
left a comment
There was a problem hiding this comment.
I am quite surprised that when having
gdb_test_multiple "foo" "foo" -lbl {
-re "$a" {
exp_continue
}
-re "$b" {
exp_continue
}
}
In our case, $b does not cover $a and vice and versa, and expect that the -lbl should make it so we consume line by line, so should not match $b first if $a could have matched a previous line.
@palves any idea?
Anyway, given some comments, the alternative approach from this patch should be OK.
| -re "($::decimal) *AMDGPU Wave \[^\r\n\]* aux_kernel \[^\\n\]*" { | ||
| set aux_wave $expect_out(1,string) | ||
| -re "($::decimal) *AMDGPU Wave \[^\r\n\]*($fault_loc|aux_kernel)\[^\\n\]*" { | ||
| if {[string match "*$fault_loc*" $expect_out(0,string)]} { |
There was a problem hiding this comment.
you could probably extract $expect_out(1,string) first, then match it against $fault_loc or aux_kernel.
| } | ||
| -re "($::decimal) *AMDGPU Wave \[^\r\n\]* aux_kernel \[^\\n\]*" { | ||
| set aux_wave $expect_out(1,string) | ||
| -re "($::decimal) *AMDGPU Wave \[^\r\n\]*($fault_loc|aux_kernel)\[^\\n\]*" { |
There was a problem hiding this comment.
still has the \[^\\n\], should be \[^\r\n\].
I think the best approach for such cases is to use diff --git a/gdb/testsuite/gdb.rocm/runtime-core.exp b/gdb/testsuite/gdb.rocm/runtime-core.exp
index 7a4cf7036f1..4c8d6506744 100644
--- a/gdb/testsuite/gdb.rocm/runtime-core.exp
+++ b/gdb/testsuite/gdb.rocm/runtime-core.exp
@@ -86,15 +86,15 @@ proc do_test { fault core_type output_type } {
set faulty_wave 0
set aux_wave 0
gdb_test_multiple "info thread" "identify waves" -lbl {
- -re "($::decimal) *AMDGPU Wave \[^\r\n\]*$fault_loc \[^\\n\]*" {
+ -re "^\r\n\[^\r\n\]+($::decimal) *AMDGPU Wave \[^\r\n\]*$fault_loc \[^\r\n\]*(?=\r\n)" {
set faulty_wave $expect_out(1,string)
exp_continue
}
- -re "($::decimal) *AMDGPU Wave \[^\r\n\]* aux_kernel \[^\\n\]*" {
+ -re "^\r\n\[^\r\n\]+($::decimal) *AMDGPU Wave \[^\r\n\]* aux_kernel \[^\r\n\]*(?=\r\n)" {
set aux_wave $expect_out(1,string)
exp_continue
}
- -re "$::gdb_prompt $" {
+ -re "^\r\n$::gdb_prompt $" {
gdb_assert {($faulty_wave != 0) && ($aux_wave != 0)} $gdb_test_name
}
} |
|
indeed @aktemur, I missed to the ^ bit in the match, and that was the important part… Thanks. |
|
@amd-bfilipov, can you confirm the diff I gave above works for you? |
The "identify waves" test was failing when waves appeared in different order because the patterns were not anchored to line boundaries, causing expect to match patterns out of order even with -lbl mode. Problem: The test uses gdb_test_multiple with -lbl (line-by-line mode) expecting each pattern to match complete lines in sequence. However, without proper anchoring, expect could match a later pattern before an earlier one if the later pattern's text appeared first in the buffer, consuming the buffer incorrectly. When aux_kernel wave appeared before pagefault_kernel wave: - pagefault_kernel pattern matched its line first (even though it appeared later in output) - Buffer was consumed up to that match - aux_kernel line (which appeared earlier) was already consumed - Second pattern failed to match → test FAIL Solution: Anchor patterns to line boundaries using: - `^\r\n` - enforce beginning of line after previous line ending - `[^\r\n]+` - match line prefix before the wave info - `(?=\r\n)` - lookahead to ensure pattern matches up to line ending This ensures each pattern matches a complete line from start to finish, making the test properly order-independent as -lbl mode intended. The same anchoring is applied to the gdb_prompt pattern for consistency.
922f75c to
47ef9da
Compare
Works, I amended the commit to use your diff. Thanks. |
The "identify waves" test was failing when waves appeared in different
order because the patterns were not anchored to line boundaries, causing
expect to match patterns out of order even with -lbl mode.
Problem:
The test uses gdb_test_multiple with -lbl (line-by-line mode) expecting
each pattern to match complete lines in sequence. However, without proper
anchoring, expect could match a later pattern before an earlier one if
the later pattern's text appeared first in the buffer, consuming the
buffer incorrectly.
When aux_kernel wave appeared before pagefault_kernel wave:
later in output)
Solution:
Anchor patterns to line boundaries using:
^\r\n- enforce beginning of line after previous line ending[^\r\n]+- match line prefix before the wave info(?=\r\n)- lookahead to ensure pattern matches up to line endingThis ensures each pattern matches a complete line from start to finish,
making the test properly order-independent as -lbl mode intended.
The same anchoring is applied to the gdb_prompt pattern for consistency.