[v4,2/6] gdb/testsuite: Fix gdb.threads/threadcrash.exp with check-readmore
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
With check-readmore, I run into:
...
FAIL: gdb.threads/threadcrash.exp: test_corefile: \
$thread_count == [llength $test_list]
...
The problem is that the clauses in the gdb_test_multiple for
"thread apply all backtrace" intent to match one line, but actually can
match more than one line, and consequently a match for one type of thread can
consume a line that was supposed to match another thread.
For instance, there's this regexp:
...
-re "\[^\n\]*syscall_task .location=SIGNAL_ALT_STACK\[^\n\]*" {
...
It's limited at the end by \[^\n\]*, meaning the match stops at the end of the
line.
But it doesn't start with a ^, and consequently can match more than one line.
The "\[^\n\]*" at the start doesn't prevent this, there's an implicit .* at
the start of each pattern, unless it's anchored using a ^.
Fix this by rewriting the regexps in a "^\r\n$hs$regexp$hs$eol" style, where:
- hs is: \[^\n\]* (horizontal space), and
- eol is (?=\r\n) (look-ahead end-of-line).
It also turned out to be necessary to drop the -lbl switch, and introduce a
corresponding explicit clause. The -lbl clause is placed ALAP, and
consequently allowed the default fail clause to trigger.
Tested on arm-linux and x86_64-linux.
---
gdb/testsuite/gdb.threads/threadcrash.exp | 29 +++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
Comments
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> Fix this by rewriting the regexps in a "^\r\n$hs$regexp$hs$eol" style, where:
Tom> - hs is: \[^\n\]* (horizontal space), and
Tom> - eol is (?=\r\n) (look-ahead end-of-line).
Tom> It also turned out to be necessary to drop the -lbl switch, and introduce a
Tom> corresponding explicit clause. The -lbl clause is placed ALAP, and
Tom> consequently allowed the default fail clause to trigger.
I feel like often we'd like tests to work "line by line" in the sense
that each pattern is matched against each line in isolation. Maybe
someday we should add a new proc that works this way.
Tom
@@ -53,13 +53,19 @@ proc thread_apply_all {} {
set unwind_fail false
+ set eol "(?=\r\n)"
+ set hs "\[^\r\n\]*"
+
set cmd "thread apply all backtrace"
- gdb_test_multiple $cmd "Get thread information" -lbl {
- -re "#\[0-9\]+\\\?\\\?\[^\n\]*" {
+ gdb_test_multiple $cmd "Get thread information" {
+ -re "^$cmd$eol" {
+ exp_continue
+ }
+ -re "^\r\n#$::decimal\\\?\\\?$hs$eol" {
set unwind_fail true
exp_continue
}
- -re "\[^\n\]*syscall_task .location=SIGNAL_ALT_STACK\[^\n\]*" {
+ -re "^\r\n${hs}syscall_task .location=SIGNAL_ALT_STACK$hs$eol" {
lappend test_list [multi_line ".*sleep.*" \
".*do_syscall_task .location=SIGNAL_ALT_STACK.*" \
".*signal_handler.*" \
@@ -68,7 +74,7 @@ proc thread_apply_all {} {
".*thread_function.*"]
exp_continue
}
- -re "\[^\n\]*syscall_task .location=SIGNAL_HANDLER\[^\n\]*" {
+ -re "^\r\n${hs}syscall_task .location=SIGNAL_HANDLER$hs$eol" {
lappend test_list [multi_line ".*sleep.*" \
".*do_syscall_task .location=SIGNAL_HANDLER.*" \
".*signal_handler.*" \
@@ -77,13 +83,13 @@ proc thread_apply_all {} {
".*thread_function.*"]
exp_continue
}
- -re "\[^\n\]*syscall_task .location=NORMAL\[^\n\]*" {
+ -re "^\r\n${hs}syscall_task .location=NORMAL$hs$eol" {
lappend test_list [multi_line ".*sleep.*" \
".*do_syscall_task .location=NORMAL.*" \
".*thread_function.*"]
exp_continue
}
- -re "\[^\n\]*spin_task .location=SIGNAL_ALT_STACK\[^\n\]*" {
+ -re "^\r\n${hs}spin_task .location=SIGNAL_ALT_STACK$hs$eol" {
lappend test_list [multi_line ".*do_spin_task .location=SIGNAL_ALT_STACK.*" \
".*signal_handler.*" \
".*signal handler called.*" \
@@ -91,7 +97,7 @@ proc thread_apply_all {} {
".*thread_function.*"]
exp_continue
}
- -re "\[^\n\]*spin_task .location=SIGNAL_HANDLER\[^\n\]*" {
+ -re "^\r\n${hs}spin_task .location=SIGNAL_HANDLER$hs$eol" {
lappend test_list [multi_line ".*do_spin_task .location=SIGNAL_HANDLER.*" \
".*signal_handler.*" \
".*signal handler called.*" \
@@ -99,16 +105,19 @@ proc thread_apply_all {} {
".*thread_function.*"]
exp_continue
}
- -re "\[^\n\]*spin_task .location=NORMAL\[^\n\]*" {
+ -re "^\r\n${hs}spin_task .location=NORMAL$hs$eol" {
lappend test_list [multi_line ".*do_spin_task .location=NORMAL..*" \
".*thread_function.*"]
exp_continue
}
- -re "\[^\n\]*main\[^\n\]*" {
+ -re "^\r\n${hs}main$hs$eol" {
lappend test_list ".*main.*"
exp_continue
}
- -re "$::gdb_prompt " {
+ -re "^\r\n$hs$eol" {
+ exp_continue
+ }
+ -re "^\r\n$::gdb_prompt $" {
pass $gdb_test_name
}
}