* gdb.python/py-breakpoint.exp: Split up into several functions,

each with their own test prefix.
This commit is contained in:
Doug Evans
2013-11-14 22:23:16 -08:00
parent 4f65b40ee0
commit 330a7fce4a
2 changed files with 332 additions and 278 deletions

View File

@ -1,3 +1,8 @@
2013-11-15 Doug Evans <xdje42@gmail.com>
* gdb.python/py-breakpoint.exp: Split up into several functions,
each with their own test prefix.
2013-11-15 Joel Brobecker <brobecker@adacore.com>
* gdb.ada/O2_float_param: New testcase.

View File

@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file is part of the GDB testsuite. It tests the mechanism
# exposing values to Python.
# exposing breakpoints to Python.
load_lib gdb-python.exp
@ -27,15 +27,19 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
proc test_bkpt_basic { } {
global srcfile testfile hex decimal
with_test_prefix "test_bkpt_basic" {
# Start with a fresh gdb.
clean_restart ${testfile}
if ![runto_main] then {
fail "Cannot run to main."
return 0
}
global hex decimal
# Initially there should be one breakpoint: main.
gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" "Get Breakpoint List" 0
gdb_test "python print (blist\[0\])" "<gdb.Breakpoint object at $hex>" "Check obj exists"
gdb_test "python print (blist\[0\].location)" "main." "Check breakpoint location"
@ -78,7 +82,13 @@ gdb_test "python print (blist\[1\].type == gdb.BP_BREAKPOINT)" "True" "Check bre
gdb_test "python print (blist\[0\].number)" "1" "Check breakpoint number"
gdb_test "python print (blist\[1\].number)" "2" "Check breakpoint number"
gdb_test "python print (blist\[2\].number)" "3" "Check breakpoint number"
}
}
proc test_bkpt_deletion { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_deletion {
# Start with a fresh gdb.
clean_restart ${testfile}
@ -100,8 +110,13 @@ gdb_test "python print (dp1.number)" "RuntimeError: Breakpoint 2 is invalid.*" "
gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" "Get Breakpoint List" 0
gdb_test "python print (len(del_list))" "2" "Number of breakpoints after delete"
gdb_continue_to_breakpoint "Break at end." ".*/$srcfile:$end_location.*"
}
}
proc test_bkpt_cond_and_cmds { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_cond_and_cmds {
# Start with a fresh gdb.
clean_restart ${testfile}
@ -135,7 +150,13 @@ gdb_test "end"
gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" "Get Breakpoint List" 0
gdb_test "python print (blist\[len(blist)-1\].commands)" "print \"Command for breakpoint has been executed.\".*print result"
}
}
proc test_bkpt_invisible { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_invisible {
# Start with a fresh gdb.
clean_restart ${testfile}
@ -144,7 +165,6 @@ if ![runto_main] then {
return 0
}
# Test invisible breakpoints.
delete_breakpoints
set ibp_location [gdb_get_line_number "Break at multiply."]
gdb_py_test_silent_cmd "python ibp = gdb.Breakpoint(\"$ibp_location\", internal=False)" "Set invisible breakpoint" 0
@ -161,9 +181,13 @@ gdb_test "python print (ilist\[0\].location)" "py-breakpoint\.c:$ibp_location*"
gdb_test "python print (ilist\[0\].visible)" "False" "Check breakpoint visibility"
gdb_test "info breakpoints" "No breakpoints or watchpoints.*" "Check info breakpoints does not show invisible breakpoints"
gdb_test "maint info breakpoints" "py-breakpoint\.c:$ibp_location.*" "Check maint info breakpoints shows invisible breakpoints"
}
}
proc test_watchpoints { } {
global srcfile testfile hex decimal
# Watchpoints
with_test_prefix test_watchpoints {
# Start with a fresh gdb.
clean_restart ${testfile}
@ -179,9 +203,13 @@ if ![runto_main] then {
gdb_py_test_silent_cmd "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE )" "Set watchpoint" 0
gdb_test "continue" ".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*main.*" "Test watchpoint write"
}
}
# Internal breakpoints.
proc test_bkpt_internal { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_internal {
# Start with a fresh gdb.
clean_restart ${testfile}
@ -198,9 +226,13 @@ gdb_py_test_silent_cmd "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WA
gdb_test "info breakpoints" "No breakpoints or watchpoints.*" "Check info breakpoints does not show invisible breakpoints"
gdb_test "maint info breakpoints" ".*watchpoint.*result.*" "Check maint info breakpoints shows invisible breakpoints"
gdb_test "continue" ".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*" "Test watchpoint write"
}
}
# Breakpoints that have an evaluation function.
proc test_bkpt_eval_funcs { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_eval_funcs {
# Start with a fresh gdb.
clean_restart ${testfile}
@ -300,9 +332,13 @@ gdb_py_test_silent_cmd "python wp1 = wp_eval (\"result\", type=gdb.BP_WATCHPOIN
gdb_test "continue" ".*\[Ww\]atchpoint.*result.*Old value =.*New value = 788.*" "Test watchpoint write"
gdb_test "python print (never_eval_bp1.count)" "0" \
"Check that this unrelated breakpoints eval function was never called."
}
}
# Test temporary breakpoint
proc test_bkpt_temporary { } {
global srcfile testfile hex decimal
with_test_prefix test_bkpt_temporary {
# Start with a fresh gdb.
clean_restart ${testfile}
@ -311,6 +347,7 @@ if ![runto_main] then {
return 0
}
delete_breakpoints
gdb_py_test_multiple "Sub-class and check temporary breakpoint" \
"python" "" \
"class temp_bp (gdb.Breakpoint):" "" \
@ -319,6 +356,7 @@ gdb_py_test_multiple "Sub-class and check temporary breakpoint" \
" self.count = self.count + 1" "" \
" return True" "" \
"end" ""
set ibp_location [gdb_get_line_number "Break at multiply."]
gdb_py_test_silent_cmd "python ibp = temp_bp(\"$ibp_location\", temporary=True)" \
"Set temporary breakpoint" 0
gdb_test "info breakpoints" "2.*breakpoint.*del.*py-breakpoint\.c:$ibp_location.*" \
@ -334,3 +372,14 @@ gdb_test "python print (ibp.temporary)" "RuntimeError: Breakpoint 2 is invalid.*
"Check temporary breakpoint is deleted after being hit"
gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \
"Check info breakpoints shows temporary breakpoint is deleted"
}
}
test_bkpt_basic
test_bkpt_deletion
test_bkpt_cond_and_cmds
test_bkpt_invisible
test_watchpoints
test_bkpt_internal
test_bkpt_eval_funcs
test_bkpt_temporary