gdb/testsuite: remove use of then keyword from gdb.python/*.exp

The canonical form of 'if' in modern TCL is 'if {} {}'.  But there's
still a bunch of places in the testsuite where we make use of the
'then' keyword, and sometimes these get copies into new tests, which
just spreads poor practice.

This commit removes all use of the 'then' keyword from the gdb.python/
test script directory.

There should be no changes in what is tested after this commit.
This commit is contained in:
Andrew Burgess 2022-11-14 14:12:07 +00:00
parent 95701caead
commit b0e16ca58d
38 changed files with 66 additions and 66 deletions

View File

@ -27,7 +27,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -47,7 +47,7 @@ proc start_test { breakpoint_comment } {
clean_restart ${binfile}
if { ![runto_main] } then {
if {![runto_main]} {
untested "couldn't run to breakpoint"
return -1
}
@ -66,7 +66,7 @@ proc start_test { breakpoint_comment } {
# Start by testing the "run" command, it can't leverage start_test
with_test_prefix "run to frame" {
if { ![runto_main] } then {
if {![runto_main]} {
untested "couldn't run to main"
}

View File

@ -27,7 +27,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main ] then {
if {![runto_main]} {
return -1
}

View File

@ -27,7 +27,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -46,7 +46,7 @@ proc_with_prefix test_bkpt_basic { } {
# We should start with no breakpoints.
gdb_test "python print (gdb.breakpoints())" "\\(\\)"
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -128,7 +128,7 @@ proc_with_prefix test_bkpt_deletion { } {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -163,7 +163,7 @@ proc_with_prefix test_bkpt_cond_and_cmds { } {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -220,7 +220,7 @@ proc_with_prefix test_bkpt_invisible { } {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -265,7 +265,7 @@ proc_with_prefix test_hardware_breakpoints { } {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -293,7 +293,7 @@ proc_with_prefix test_watchpoints { } {
gdb_test_no_output "set can-use-hw-watchpoints 0" ""
}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -316,7 +316,7 @@ proc_with_prefix test_bkpt_internal { } {
if {$skip_hw_watchpoint_tests_p} {
gdb_test_no_output "set can-use-hw-watchpoints 0" ""
}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
delete_breakpoints
@ -364,7 +364,7 @@ proc_with_prefix test_bkpt_eval_funcs { } {
if {$skip_hw_watchpoint_tests_p} {
gdb_test_no_output "set can-use-hw-watchpoints 0" ""
}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
delete_breakpoints
@ -477,7 +477,7 @@ proc_with_prefix test_bkpt_temporary { } {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
delete_breakpoints
@ -595,7 +595,7 @@ proc_with_prefix test_bkpt_explicit_loc {} {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -680,7 +680,7 @@ proc_with_prefix test_bkpt_qualified {} {
set one_location_re "Breakpoint $decimal at $hex:.*line $decimal."
set two_location_re "Breakpoint $decimal at $hex:.*2 locations."
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -749,7 +749,7 @@ proc_with_prefix test_bkpt_probe {} {
return -1
}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -766,7 +766,7 @@ proc_with_prefix test_catchpoints {} {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -825,7 +825,7 @@ proc_with_prefix test_bkpt_auto_disable { } {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
delete_breakpoints

View File

@ -27,7 +27,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -27,7 +27,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} "debug"] }
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
fail "can't run to main"
return 0
}

View File

@ -317,7 +317,7 @@ with_test_prefix "gdb exiting: normal" {
with_test_prefix "gdb exiting: error" {
clean_restart ${testfile}
if ![runto_main] then {
if {![runto_main]} {
fail "cannot run to main."
return 0
}

View File

@ -50,7 +50,7 @@ with_test_prefix "normal conditions" {
clean_restart ${testfile}
gdb_load_shlib ${lib_sl}
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -102,7 +102,7 @@ with_test_prefix "no debug symbol" {
"import python scripts"
set cond_line [gdb_get_line_number "Condition Break."]
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -129,7 +129,7 @@ with_test_prefix "function returned by longjump" {
gdb_test "source $python_file" "Python script imported.*" \
"import python scripts"
if ![runto call_longjmp_1] then {
if {![runto call_longjmp_1]} {
return
}
@ -157,7 +157,7 @@ with_test_prefix "finish in dummy frame" {
"import python scripts"
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -184,7 +184,7 @@ with_test_prefix "finish in normal frame" {
gdb_test "source $python_file" "Python script imported.*" \
"import python scripts"
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -213,7 +213,7 @@ with_test_prefix "explicit inferior function call" {
gdb_test "source $python_file" "Python script imported.*" \
"import python scripts"
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -240,7 +240,7 @@ with_test_prefix "explicit inferior function call" {
#
with_test_prefix "inferior exit" {
if ![runto "test_exec_exit"] then {
if {![runto "test_exec_exit"]} {
return 0
}
@ -254,7 +254,7 @@ with_test_prefix "inferior exit" {
#
with_test_prefix "inferior exec" {
if ![runto "test_exec_exit"] then {
if {![runto "test_exec_exit"]} {
return 0
}

View File

@ -27,7 +27,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -52,7 +52,7 @@ proc prepare_gdb {exefile} {
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${exefile}
if ![runto_main] then {
if {![runto_main]} {
perror "couldn't run to breakpoint"
return
}

View File

@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -29,7 +29,7 @@ if { [skip_python_tests] } { continue }
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -51,7 +51,7 @@ gdb_load ${binfile}
gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*" \
"Test auto-load had loaded python scripts"
if ![runto_main] then {
if {![runto_main]} {
perror "couldn't run to breakpoint"
return
}

View File

@ -52,7 +52,7 @@ gdb_load ${binfile}
gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*" \
"Test auto-load had loaded python scripts"
if ![runto_main] then {
if {![runto_main]} {
perror "couldn't run to breakpoint"
return
}
@ -310,7 +310,7 @@ gdb_load ${binfile}
# Verify gdb loaded the script.
gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*" \
"Set autoload path for no debug info tests"
if ![runto_main] then {
if {![runto_main]} {
perror "couldn't run to breakpoint"
return
}

View File

@ -37,7 +37,7 @@ switch [get_endianness] {
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -40,7 +40,7 @@ gdb_test_multiline "install new_thread event handler" \
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -34,7 +34,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] } {
return -1
}
if ![runto_main ] then {
if {![runto_main]} {
return -1
}

View File

@ -27,7 +27,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -32,7 +32,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main ] then {
if {![runto_main]} {
return -1
}

View File

@ -42,7 +42,7 @@ proc run_lang_tests {exefile lang} {
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${exefile}
if ![runto_main ] then {
if {![runto_main]} {
perror "couldn't run to breakpoint"
return
}
@ -198,7 +198,7 @@ gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
if ![runto_main ] then {
if {![runto_main]} {
perror "couldn't run to breakpoint"
return
}

View File

@ -27,7 +27,7 @@ if {[prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $srcfile
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -35,7 +35,7 @@ if { [skip_python_tests] } {
return -1
}
if ![runto_main ] then {
if {![runto_main]} {
return -1
}

View File

@ -35,7 +35,7 @@ if { [skip_python_tests] } {
return -1
}
if ![runto_main ] then {
if {![runto_main]} {
return -1
}

View File

@ -40,7 +40,7 @@ gdb_test "source ${pyfile}" "Python script imported" \
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -48,7 +48,7 @@ if { [skip_python_tests] } { continue }
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -104,7 +104,7 @@ gdb_test "python print (gdb.lookup_static_symbol ('nonexistent') is None)" \
gdb_test "python print (gdb.lookup_static_symbol ('qq') is None)" \
"True" "lookup_static_symbol for global var"
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -212,7 +212,7 @@ gdb_test "python print (gdb.lookup_global_symbol ('(anonymous namespace)::anon')
gdb_test "python print (gdb.lookup_static_symbol ('(anonymous namespace)::anon').value ())" \
"10" "print value of anon"
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -240,7 +240,7 @@ gdb_test "python print (cplusfunc.addr_class == gdb.SYMBOL_LOC_BLOCK)" "True" "t
# test as it unloads the object file in GDB.
# Start with a fresh gdb.
clean_restart ${binfile}
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -27,7 +27,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -43,7 +43,7 @@ proc test_template_arg {exefile type} {
return -1
}
gdb_load ${exefile}
if ![runto_main ] then {
if {![runto_main]} {
perror "couldn't run to breakpoint"
return
}

View File

@ -41,7 +41,7 @@ proc restart_gdb {exefile} {
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${exefile}
if ![runto_main ] then {
if {![runto_main]} {
perror "couldn't run to breakpoint"
return
}

View File

@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
if { [skip_python_tests] } { continue }
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -29,7 +29,7 @@ if { [skip_python_tests] } { continue }
set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
if ![runto_main ] then {
if {![runto_main]} {
return -1
}

View File

@ -47,7 +47,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -37,7 +37,7 @@ if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { continue }
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -415,7 +415,7 @@ proc test_subscript_regression {exefile lang} {
# Start with a fresh gdb.
clean_restart ${exefile}
if ![runto_main ] then {
if {![runto_main]} {
perror "couldn't run to breakpoint"
return
}
@ -652,7 +652,7 @@ test_add_to_history
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}

View File

@ -217,7 +217,7 @@ clean_restart ${testfile}
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -431,7 +431,7 @@ clean_restart ${testfile}
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}
@ -486,7 +486,7 @@ clean_restart ${testfile}
# The following tests require execution.
if ![runto_main] then {
if {![runto_main]} {
return 0
}