From 0a6155a0722349087167d8489ed878a6f60bc360 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 1 Dec 2020 15:07:08 -0500 Subject: [PATCH] gdb/testsuite: use foreach_with_prefix in gdb.threads/non-ldr-exc-*.exp Replace the manual with_test_prefix in the do_test proc with using foreach_with_prefix at the top-level. This helps reduce the indentation level of the code a bit, and makes the test names in sync with the variable names used in the code. gdb/testsuite/ChangeLog: * gdb.threads/non-ldr-exc-1.exp: Use foreach_with_prefix. (do_test): Don't use with_test_prefix. * gdb.threads/non-ldr-exc-2.exp: Use foreach_with_prefix. (do_test): Don't use with_test_prefix. * gdb.threads/non-ldr-exc-3.exp: Use foreach_with_prefix. (do_test): Don't use with_test_prefix. * gdb.threads/non-ldr-exc-4.exp: Use foreach_with_prefix. (do_test): Don't use with_test_prefix. Change-Id: I3af1df2eee1a8add427a67b6048bb6dede41cbeb --- gdb/testsuite/ChangeLog | 11 ++++ gdb/testsuite/gdb.threads/non-ldr-exc-1.exp | 61 +++++++++---------- gdb/testsuite/gdb.threads/non-ldr-exc-2.exp | 67 ++++++++++----------- gdb/testsuite/gdb.threads/non-ldr-exc-3.exp | 61 +++++++++---------- gdb/testsuite/gdb.threads/non-ldr-exc-4.exp | 61 +++++++++---------- 5 files changed, 134 insertions(+), 127 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index d123b44068d..d3f0f885b2d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2020-12-01 Simon Marchi + + * gdb.threads/non-ldr-exc-1.exp: Use foreach_with_prefix. + (do_test): Don't use with_test_prefix. + * gdb.threads/non-ldr-exc-2.exp: Use foreach_with_prefix. + (do_test): Don't use with_test_prefix. + * gdb.threads/non-ldr-exc-3.exp: Use foreach_with_prefix. + (do_test): Don't use with_test_prefix. + * gdb.threads/non-ldr-exc-4.exp: Use foreach_with_prefix. + (do_test): Don't use with_test_prefix. + 2020-12-01 Simon Marchi * gdb.threads/non-ldr-exit.exp: Fix comment. diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp index 3a20653f746..78280e5bd2b 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp @@ -24,44 +24,43 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab } proc do_test { lock_sched nonstop } { - with_test_prefix "lock-sched=$lock_sched,non-stop=$nonstop" { - global executable + global executable - save_vars { GDBFLAGS } { - append GDBFLAGS " -ex \"set non-stop $nonstop\"" - clean_restart ${executable} - } - - if ![runto_main] { - return -1 - } + save_vars { GDBFLAGS } { + append GDBFLAGS " -ex \"set non-stop $nonstop\"" + clean_restart ${executable} + } - gdb_breakpoint [gdb_get_line_number "break-here"] - gdb_continue_to_breakpoint "break-here" ".* break-here .*" + if ![runto_main] { + return -1 + } - # Also test with sched-lock to make sure we can follow the - # non-leader thread execing even though the main thread wasn't - # resumed before the exec. - if { $lock_sched } { - gdb_test_no_output "set scheduler-locking on" - } + gdb_breakpoint [gdb_get_line_number "break-here"] + gdb_continue_to_breakpoint "break-here" ".* break-here .*" - if { $nonstop == "on" } { - gdb_test "thread 2" "Switching.*" - } + # Also test with sched-lock to make sure we can follow the + # non-leader thread execing even though the main thread wasn't + # resumed before the exec. + if { $lock_sched } { + gdb_test_no_output "set scheduler-locking on" + } - gdb_test "continue" \ - ".*is executing new program.*Breakpoint 1, main.* at .*" \ - "continue over exec" + if { $nonstop == "on" } { + gdb_test "thread 2" "Switching.*" } + + gdb_test "continue" \ + ".*is executing new program.*Breakpoint 1, main.* at .*" \ + "continue over exec" } -foreach nonstop {"on" "off"} { - foreach schedlock {"on" "off"} { - if {$schedlock == "on" && $nonstop == "on"} { - # Schedule locking has no effect in nonstop mode. - continue +foreach_with_prefix nonstop {"on" "off"} { + foreach_with_prefix schedlock {"on" "off"} { + if {$schedlock == "on" && $nonstop == "on"} { + # Schedule locking has no effect in nonstop mode. + continue + } + + do_test $schedlock $nonstop } - do_test $schedlock $nonstop - } } diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp index a2eb546089f..194c1510290 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp @@ -25,48 +25,47 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab } proc do_test { lock_sched nonstop } { - with_test_prefix "lock-sched=$lock_sched,non-stop=$nonstop" { - global executable + global executable - save_vars { GDBFLAGS } { - append GDBFLAGS " -ex \"set non-stop $nonstop\"" - clean_restart ${executable} - } - - if ![runto_main] { - return -1 - } + save_vars { GDBFLAGS } { + append GDBFLAGS " -ex \"set non-stop $nonstop\"" + clean_restart ${executable} + } - gdb_breakpoint [gdb_get_line_number "break-here"] - gdb_continue_to_breakpoint "break-here" ".* break-here .*" + if ![runto_main] { + return -1 + } - if { $nonstop == "on" } { - gdb_test "thread 2" "Switching.*" - } + gdb_breakpoint [gdb_get_line_number "break-here"] + gdb_continue_to_breakpoint "break-here" ".* break-here .*" - gdb_test "info threads" \ - "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \ - "single thread left" + if { $nonstop == "on" } { + gdb_test "thread 2" "Switching.*" + } - # Also test with sched-lock to make sure we can follow the - # non-leader thread execing even though the main thread wasn't - # resumed before the exec. - if { $lock_sched } { - gdb_test_no_output "set scheduler-locking on" - } + gdb_test "info threads" \ + "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \ + "single thread left" - gdb_test "continue" \ - ".*is executing new program.*Breakpoint 1, main.* at .*" \ - "continue over exec" + # Also test with sched-lock to make sure we can follow the + # non-leader thread execing even though the main thread wasn't + # resumed before the exec. + if { $lock_sched } { + gdb_test_no_output "set scheduler-locking on" } + + gdb_test "continue" \ + ".*is executing new program.*Breakpoint 1, main.* at .*" \ + "continue over exec" } -foreach nonstop {"on" "off"} { - foreach schedlock {"on" "off"} { - if {$schedlock == "on" && $nonstop == "on"} { - # Schedule locking has no effect in nonstop mode. - continue +foreach_with_prefix nonstop {"on" "off"} { + foreach_with_prefix schedlock {"on" "off"} { + if {$schedlock == "on" && $nonstop == "on"} { + # Schedule locking has no effect in nonstop mode. + continue + } + + do_test $schedlock $nonstop } - do_test $schedlock $nonstop - } } diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp index c4de2e748cb..50350e9f6d8 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp @@ -27,44 +27,43 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab } proc do_test { lock_sched nonstop } { - with_test_prefix "lock-sched=$lock_sched,non-stop=$nonstop" { - global executable + global executable - save_vars { GDBFLAGS } { - append GDBFLAGS " -ex \"set non-stop $nonstop\"" - clean_restart ${executable} - } - - if ![runto_main] { - return -1 - } + save_vars { GDBFLAGS } { + append GDBFLAGS " -ex \"set non-stop $nonstop\"" + clean_restart ${executable} + } - gdb_breakpoint [gdb_get_line_number "break-here"] - gdb_continue_to_breakpoint "break-here" ".* break-here .*" + if ![runto_main] { + return -1 + } - # Also test with sched-lock to make sure we can follow the - # non-leader thread execing even though the main thread wasn't - # resumed before the exec. - if { $lock_sched } { - gdb_test_no_output "set scheduler-locking on" - } + gdb_breakpoint [gdb_get_line_number "break-here"] + gdb_continue_to_breakpoint "break-here" ".* break-here .*" - if { $nonstop == "on" } { - gdb_test "thread 2" "Switching.*" - } + # Also test with sched-lock to make sure we can follow the + # non-leader thread execing even though the main thread wasn't + # resumed before the exec. + if { $lock_sched } { + gdb_test_no_output "set scheduler-locking on" + } - gdb_test "continue" \ - ".*is executing new program.*Breakpoint 1, main.* at .*" \ - "continue over exec" + if { $nonstop == "on" } { + gdb_test "thread 2" "Switching.*" } + + gdb_test "continue" \ + ".*is executing new program.*Breakpoint 1, main.* at .*" \ + "continue over exec" } -foreach nonstop {"on" "off"} { - foreach schedlock {"on" "off"} { - if {$schedlock == "on" && $nonstop == "on"} { - # Schedule locking has no effect in nonstop mode. - continue +foreach_with_prefix nonstop {"on" "off"} { + foreach_with_prefix schedlock {"on" "off"} { + if {$schedlock == "on" && $nonstop == "on"} { + # Schedule locking has no effect in nonstop mode. + continue + } + + do_test $schedlock $nonstop } - do_test $schedlock $nonstop - } } diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp index 7de266b8b94..0838eace415 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp @@ -26,44 +26,43 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab } proc do_test { lock_sched nonstop } { - with_test_prefix "lock-sched=$lock_sched,non-stop=$nonstop" { - global executable + global executable - save_vars { GDBFLAGS } { - append GDBFLAGS " -ex \"set non-stop $nonstop\"" - clean_restart ${executable} - } - - if ![runto_main] { - return -1 - } + save_vars { GDBFLAGS } { + append GDBFLAGS " -ex \"set non-stop $nonstop\"" + clean_restart ${executable} + } - gdb_breakpoint [gdb_get_line_number "break-here"] - gdb_continue_to_breakpoint "break-here" ".* break-here .*" + if ![runto_main] { + return -1 + } - # Also test with sched-lock to make sure we can follow the - # non-leader thread execing even though the main thread wasn't - # resumed before the exec. - if { $lock_sched } { - gdb_test_no_output "set scheduler-locking on" - } + gdb_breakpoint [gdb_get_line_number "break-here"] + gdb_continue_to_breakpoint "break-here" ".* break-here .*" - if { $nonstop == "on" } { - gdb_test "thread 2" "Switching.*" - } + # Also test with sched-lock to make sure we can follow the + # non-leader thread execing even though the main thread wasn't + # resumed before the exec. + if { $lock_sched } { + gdb_test_no_output "set scheduler-locking on" + } - gdb_test "continue" \ - ".*is executing new program.*Breakpoint 1, main.* at .*" \ - "continue over exec" + if { $nonstop == "on" } { + gdb_test "thread 2" "Switching.*" } + + gdb_test "continue" \ + ".*is executing new program.*Breakpoint 1, main.* at .*" \ + "continue over exec" } -foreach nonstop {"on" "off"} { - foreach schedlock {"on" "off"} { - if {$schedlock == "on" && $nonstop == "on"} { - # Schedule locking has no effect in nonstop mode. - continue +foreach_with_prefix nonstop {"on" "off"} { + foreach_with_prefix schedlock {"on" "off"} { + if {$schedlock == "on" && $nonstop == "on"} { + # Schedule locking has no effect in nonstop mode. + continue + } + + do_test $schedlock $nonstop } - do_test $schedlock $nonstop - } } -- 2.39.5