diff options
author | Maciej W. Rozycki <macro@embecosm.com> | 2022-10-21 08:54:18 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@embecosm.com> | 2022-10-21 08:54:18 +0100 |
commit | e7e1f2034567207e5e01cb75ea2ffd568a64e84d (patch) | |
tree | 4fc2d54271f02a84b7846600d319d3d20d4e6913 /gdb/testsuite/gdb.python | |
parent | 90319cefe398bb6c5130b48d1c0e4df5e65eb194 (diff) | |
download | gdb-e7e1f2034567207e5e01cb75ea2ffd568a64e84d.zip gdb-e7e1f2034567207e5e01cb75ea2ffd568a64e84d.tar.gz gdb-e7e1f2034567207e5e01cb75ea2ffd568a64e84d.tar.bz2 |
GDB/testsuite: Expand Python integer parameter coverage across all types
Also verify PARAM_UINTEGER, PARAM_INTEGER, and PARAM_ZINTEGER parameter
types, in addition to PARAM_ZUINTEGER and PARAM_ZUINTEGER_UNLIMITED
already covered, and verify a choice of existing GDB parameters. Add
verification for reading parameters via `<parameter>.value' in addition
to `gdb.parameter('<parameter>')' as this covers different code paths.
Approved-By: Simon Marchi <simon.marchi@polymtl.ca>
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r-- | gdb/testsuite/gdb.python/py-parameter.exp | 197 |
1 files changed, 181 insertions, 16 deletions
diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp index 4aa3e96..3476d43 100644 --- a/gdb/testsuite/gdb.python/py-parameter.exp +++ b/gdb/testsuite/gdb.python/py-parameter.exp @@ -24,6 +24,14 @@ clean_restart # Skip all tests if Python scripting is not enabled. if { [skip_python_tests] } { continue } +proc py_param_test_maybe_no_output { command pattern args } { + if [string length $pattern] { + gdb_test $command $pattern $args + } else { + gdb_test_no_output $command $args + } +} + proc_with_prefix test_directories { } { # We use "." here instead of ":" so that this works on win32 too. if { [is_remote host] } { @@ -325,8 +333,80 @@ proc_with_prefix test_deprecated_api_parameter { } { "test general help" } +proc_with_prefix test_gdb_parameter { } { + foreach_with_prefix param { + "listsize" + "print elements" + "max-completions" + } { + clean_restart + + set param_range_error ".*gdb.error: integer -1 out of range.*" + switch -- $param { + "listsize" { + set param_get_zero None + set param_get_minus_one -1 + set param_get_unlimited None + set param_set_minus_one "" + } + "print elements" { + set param_get_zero None + set param_get_minus_one None + set param_get_unlimited None + set param_set_minus_one $param_range_error + } + "max-completions" { + set param_get_zero 0 + set param_get_minus_one -1 + set param_get_unlimited -1 + set param_set_minus_one "" + } + default { + error "invalid param: $param" + } + } + + gdb_test_no_output "python gdb.set_parameter('$param', 1)" \ + "test set to 1" + + gdb_test "python print(gdb.parameter('$param'))" \ + 1 "test value of 1" + + gdb_test_no_output "python gdb.set_parameter('$param', 0)" \ + "test set to 0" + + gdb_test "python print(gdb.parameter('$param'))" \ + $param_get_zero "test value of 0" + + py_param_test_maybe_no_output \ + "python gdb.set_parameter('$param', -1)" \ + $param_set_minus_one "test set to -1" + + gdb_test "python print(gdb.parameter('$param'))" \ + $param_get_minus_one "test value of -1" + + gdb_test_no_output "python gdb.set_parameter('$param', 'unlimited')" \ + "test set to 'unlimited'" + + gdb_test "python print(gdb.parameter('$param'))" \ + $param_get_unlimited "test value of 'unlimited'" + } + + clean_restart + + # This caused a gdb crash. + gdb_test "python print(gdb.parameter('endian'))" "auto" \ + "print endian parameter" +} + proc_with_prefix test_integer_parameter { } { - foreach_with_prefix kind {PARAM_ZUINTEGER PARAM_ZUINTEGER_UNLIMITED} { + foreach_with_prefix kind { + PARAM_UINTEGER + PARAM_INTEGER + PARAM_ZINTEGER + PARAM_ZUINTEGER + PARAM_ZUINTEGER_UNLIMITED + } { clean_restart gdb_test_multiline "create parameter" \ @@ -338,20 +418,106 @@ proc_with_prefix test_integer_parameter { } { "test_param_$kind = TestNodocParam ('test-$kind')" "" \ "end" - gdb_test "python print(gdb.parameter('test-$kind'))" "0" + set param_range_error "RuntimeError: Range exceeded.*" + set param_integer_error "RuntimeError: The value must be integer.*" + switch -- $kind { + PARAM_UINTEGER { + set param_get_zero None + set param_get_minus_one None + set param_get_minus_five 1 + set param_get_none 5 + set param_set_minus_one $param_range_error + set param_set_minus_five $param_range_error + set param_set_none $param_integer_error + } + PARAM_INTEGER { + set param_get_zero None + set param_get_minus_one -1 + set param_get_minus_five -5 + set param_get_none 5 + set param_set_minus_one -1 + set param_set_minus_five -5 + set param_set_none $param_integer_error + } + PARAM_ZINTEGER { + set param_get_zero 0 + set param_get_minus_one -1 + set param_get_minus_five -5 + set param_get_none 5 + set param_set_minus_one "" + set param_set_minus_five "" + set param_set_none $param_integer_error + } + PARAM_ZUINTEGER { + set param_get_zero 0 + set param_get_minus_one 0 + set param_get_minus_five 1 + set param_get_none 5 + set param_set_minus_one $param_range_error + set param_set_minus_five $param_range_error + set param_set_none $param_integer_error + } + PARAM_ZUINTEGER_UNLIMITED { + set param_get_zero 0 + set param_get_minus_one -1 + set param_get_minus_five 1 + set param_get_none 5 + set param_set_minus_one "" + set param_set_minus_five $param_range_error + set param_set_none $param_integer_error + } + default { + error "invalid kind: $kind" + } + } + + gdb_test "python print(test_param_$kind.value)" \ + $param_get_zero "test default value" - gdb_test "python test_param_$kind.value = -5" "RuntimeError: Range exceeded.*" + gdb_test "python print(gdb.parameter('test-$kind'))" \ + $param_get_zero "test default value via gdb.parameter" - if {$kind == "PARAM_ZUINTEGER"} { - gdb_test "python test_param_$kind.value = -1" "RuntimeError: Range exceeded.*" - } elseif {$kind == "PARAM_ZUINTEGER_UNLIMITED"} { - gdb_test_no_output "python test_param_$kind.value = -1" \ - "check that PARAM_ZUINTEGER_UNLIMITED value can be set to -1" - gdb_test "python print(gdb.parameter('test-$kind'))" "-1" \ - "check that PARAM_ZUINTEGER_UNLIMITED value is -1 after setting" - } else { - error "invalid kind: $kind" - } + py_param_test_maybe_no_output "python test_param_$kind.value = -1" \ + $param_set_minus_one "test set to -1" + + gdb_test "python print(test_param_$kind.value)" \ + $param_get_minus_one "test value of -1" + + gdb_test "python print(gdb.parameter('test-$kind'))" \ + $param_get_minus_one "test value of -1 via gdb.parameter" + + gdb_test_no_output "python test_param_$kind.value = 1" "test set to 1" + + gdb_test "python print(test_param_$kind.value)" 1 "test value of 1" + + gdb_test "python print(gdb.parameter('test-$kind'))" \ + 1 "test value of 1 via gdb.parameter" + + py_param_test_maybe_no_output "python test_param_$kind.value = -5" \ + $param_set_minus_five "test set to -5" + + gdb_test "python print(gdb.parameter('test-$kind'))" \ + $param_get_minus_five "test value of -5 via gdb.parameter" + + gdb_test_no_output "python test_param_$kind.value = 5" "test set to 5" + + gdb_test "python print(gdb.parameter('test-$kind'))" \ + 5 "test value of 5 via gdb.parameter" + + py_param_test_maybe_no_output "python test_param_$kind.value = None" \ + $param_set_none "test set to None" + + gdb_test "python print(test_param_$kind.value)" \ + $param_get_none "test value of None" + + gdb_test "python print(gdb.parameter('test-$kind'))" \ + $param_get_none "test value of None via gdb.parameter" + + gdb_test_no_output "python test_param_$kind.value = 0" \ + "test set to 0" + + gdb_test "python print(gdb.parameter('test-$kind'))" \ + $param_get_zero "test value of 0 via gdb.parameter" } } @@ -395,10 +561,9 @@ test_file_parameter test_undocumented_parameter test_really_undocumented_parameter test_deprecated_api_parameter +test_gdb_parameter test_integer_parameter test_throwing_parameter test_language -# This caused a gdb crash. -gdb_test "python print(gdb.parameter('endian'))" "auto" \ - "print endian parameter" +rename py_param_test_maybe_no_output "" |