diff options
author | Phil Muldoon <pmuldoon@redhat.com> | 2011-03-10 12:29:08 +0000 |
---|---|---|
committer | Phil Muldoon <pmuldoon@redhat.com> | 2011-03-10 12:29:08 +0000 |
commit | ecec24e64a26014ab55b1796c4027026b0b5659c (patch) | |
tree | 7712f689eb503f8e805662c5666cba7b976d2c30 /gdb/testsuite | |
parent | 6d6c6b1f5589004c390d66c18647656d87c9ae22 (diff) | |
download | gdb-ecec24e64a26014ab55b1796c4027026b0b5659c.zip gdb-ecec24e64a26014ab55b1796c4027026b0b5659c.tar.gz gdb-ecec24e64a26014ab55b1796c4027026b0b5659c.tar.bz2 |
2011-03-10 Phil Muldoon <pmuldoon@redhat.com>
* python/py-param.c (add_setshow_generic): Add set/show callback
parameters. Register Python object context.
(get_show_value): New function.
(get_set_value): New function.
(call_doc_function): New function.
(get_doc_string): Move behind get_show_value/get_set_value.
2011-03-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Parameters In Python): Document get_set_string and
get_show_string methods.
2011-03-10 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-parameter.exp: Update tests to the new Python
parameter API. Add "no documentation" test. Add deprecated API
backward compatibility test.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-parameter.exp | 119 |
2 files changed, 96 insertions, 29 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 86b03cc..0a1949b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-03-10 Phil Muldoon <pmuldoon@redhat.com> + + * gdb.python/py-parameter.exp: Update tests to the new Python + parameter API. Add "no documentation" test. Add deprecated API + backward compatibility test. + 2011-03-09 Tom Tromey <tromey@redhat.com> * gdb.ada/catch_ex.exp: Use explicit gdb_test rather than diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp index 261c0d5..63f4ff2 100644 --- a/gdb/testsuite/gdb.python/py-parameter.exp +++ b/gdb/testsuite/gdb.python/py-parameter.exp @@ -38,8 +38,15 @@ gdb_py_test_multiple "Simple gdb booleanparameter" \ "python" "" \ "class TestParam (gdb.Parameter):" "" \ " \"\"\"When enabled, test param does something useful. When disabled, does nothing.\"\"\"" "" \ - " show_doc = \"Show whether the state of the Test Parameter does something useful\"" ""\ - " set_doc = \"Set whether the state of the Test Parameter does something useful\"" "" \ + " show_doc = \"Show the state of the boolean test-param\"" ""\ + " set_doc = \"Set the state of the boolean test-param\"" "" \ + " def get_show_string (self, pvalue):" ""\ + " return \"The state of the Test Parameter is \" + pvalue" ""\ + " def get_set_string (self):" ""\ + " val = \"on\"" ""\ + " if (self.value == False):" ""\ + " val = \"off\"" ""\ + " return \"Test Parameter has been set to \" + val" ""\ " def __init__ (self, name):" "" \ " super (TestParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_BOOLEAN)" "" \ " self.value = True" "" \ @@ -47,13 +54,14 @@ gdb_py_test_multiple "Simple gdb booleanparameter" \ "end" gdb_test "python print test_param.value" "True" "Test parameter value" -gdb_test "show print test-param" "Whether the state of the Test Parameter does something useful is on.*" "Show parameter on" -gdb_py_test_silent_cmd "set print test-param off" "Turn off parameter" 1 -gdb_test "show print test-param" "Whether the state of the Test Parameter does something useful is off.*" "Show parameter off" +gdb_test "show print test-param" "The state of the Test Parameter is on.*" "Show parameter on" +gdb_test "set print test-param off" "Test Parameter has been set to off" "Turn off parameter" +gdb_test "show print test-param" "The state of the Test Parameter is off.*" "Show parameter off" gdb_test "python print test_param.value" "False" "Test parameter value" -gdb_test "help show print test-param" "Show whether the state of the Test Parameter does something useful.*" "Test show help" -gdb_test "help set print test-param" "Set whether the state of the Test Parameter does something useful.*" "Test set help" -gdb_test "help set print" "set print test-param -- Set whether the state of the Test Parameter.*" "Test general help" +gdb_test "help show print test-param" "Show the state of the boolean test-param.*" "Test show help" +gdb_test "help set print test-param" "Set the state of the boolean test-param.*" "Test set help" +gdb_test "help set print" "set print test-param -- Set the state of the boolean test-param.*" "Test general help" + # Test an enum parameter. gdb_py_test_multiple "enum gdb parameter" \ @@ -62,6 +70,10 @@ gdb_py_test_multiple "enum gdb parameter" \ " \"\"\"When set, test param does something useful. When disabled, does nothing.\"\"\"" "" \ " show_doc = \"Show the state of the enum\"" ""\ " set_doc = \"Set the state of the enum\"" "" \ + " def get_show_string (self, pvalue):" ""\ + " return \"The state of the enum is \" + pvalue" ""\ + " def get_set_string (self):" ""\ + " return \"The state of the enum has been set to \" + self.value" ""\ " def __init__ (self, name):" "" \ " super (TestEnumParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_ENUM, \[\"one\", \"two\"\])" "" \ " self.value = \"one\"" "" \ @@ -69,9 +81,9 @@ gdb_py_test_multiple "enum gdb parameter" \ "end" gdb_test "python print test_enum_param.value" "one" "Test enum parameter value" -gdb_test "show print test-enum-param" "The state of the enum is \"one\".*" "Show parameter is initial value" -gdb_py_test_silent_cmd "set print test-enum-param two" "Set parameter to enum value" 1 -gdb_test "show print test-enum-param" "The state of the enum is \"two\".*" "Show parameter is new value" +gdb_test "show print test-enum-param" "The state of the enum is one.*" "Show parameter is initial value" +gdb_test "set print test-enum-param two" "The state of the enum has been set to two" "Set enum to two" +gdb_test "show print test-enum-param" "The state of the enum is two.*" "Show parameter is new value" gdb_test "python print test_enum_param.value" "two" "Test enum parameter value" gdb_test "set print test-enum-param three" "Undefined item: \"three\".*" "Set invalid enum parameter" @@ -82,6 +94,10 @@ gdb_py_test_multiple "file gdb parameter" \ " \"\"\"When set, test param does something useful. When disabled, does nothing.\"\"\"" "" \ " show_doc = \"Show the name of the file\"" ""\ " set_doc = \"Set the name of the file\"" "" \ + " def get_show_string (self, pvalue):" ""\ + " return \"The name of the file is \" + pvalue" ""\ + " def get_set_string (self):" ""\ + " return \"The name of the file has been changed to \" + self.value" ""\ " def __init__ (self, name):" "" \ " super (TestFileParam, self).__init__ (name, gdb.COMMAND_FILES, gdb.PARAM_FILENAME)" "" \ " self.value = \"foo.txt\"" "" \ @@ -89,28 +105,73 @@ gdb_py_test_multiple "file gdb parameter" \ "end" gdb_test "python print test_file_param.value" "foo.txt" "Test file parameter value" -gdb_test "show test-file-param" "The name of the file is \"foo.txt\".*" "Show initial file value" -gdb_py_test_silent_cmd "set test-file-param bar.txt" "Set new file parameter" 1 -gdb_test "show test-file-param" "The name of the file is \"bar.txt\".*" "Show new file value" +gdb_test "show test-file-param" "The name of the file is foo.txt.*" "Show initial file value" +gdb_test "set test-file-param bar.txt" "The name of the file has been changed to bar.txt" "Set new file parameter" 1 +gdb_test "show test-file-param" "The name of the file is bar.txt.*" "Show new file value" gdb_test "python print test_file_param.value" "bar.txt" "Test new file parameter value" gdb_test "set test-file-param" "Argument required.*" -# Test a file parameter. -gdb_py_test_multiple "file gdb parameter" \ +# Test a parameter that is not documented. +gdb_py_test_multiple "Simple gdb booleanparameter" \ "python" "" \ - "class TestFileParam (gdb.Parameter):" "" \ - " \"\"\"When set, test param does something useful. When disabled, does nothing.\"\"\"" "" \ - " show_doc = \"Show the name of the file\"" ""\ - " set_doc = \"Set the name of the file\"" "" \ + "class TestUndocParam (gdb.Parameter):" "" \ + " def get_show_string (self, pvalue):" ""\ + " return \"The state of the Test Parameter is \" + pvalue" ""\ + " def get_set_string (self):" ""\ + " val = \"on\"" ""\ + " if (self.value == False):" ""\ + " val = \"off\"" ""\ + " return \"Test Parameter has been set to \" + val" ""\ " def __init__ (self, name):" "" \ - " super (TestFileParam, self).__init__ (name, gdb.COMMAND_FILES, gdb.PARAM_FILENAME)" "" \ - " self.value = \"foo.txt\"" "" \ - "test_file_param = TestFileParam ('test-file-param')" ""\ + " super (TestUndocParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_BOOLEAN)" "" \ + " self.value = True" "" \ + "test_undoc_param = TestUndocParam ('print test-undoc-param')" ""\ "end" -gdb_test "python print test_file_param.value" "foo.txt" "Test parameter value" -gdb_test "show test-file-param" "The name of the file is \"foo.txt\".*" "Show parameter on" -gdb_py_test_silent_cmd "set test-file-param bar.txt" "Turn off parameter" 1 -gdb_test "show test-file-param" "The name of the file is \"bar.txt\".*" "Show parameter on" -gdb_test "python print test_file_param.value" "bar.txt" "Test parameter value" -gdb_test "set test-file-param" "Argument required.*" +gdb_test "show print test-undoc-param" "The state of the Test Parameter is on.*" "Show parameter on" +gdb_test "set print test-undoc-param off" "Test Parameter has been set to off" "Turn off parameter" +gdb_test "show print test-undoc-param" "The state of the Test Parameter is off.*" "Show parameter off" +gdb_test "python print test_undoc_param.value" "False" "Test parameter value" +gdb_test "help show print test-undoc-param" "This command is not documented.*" "Test show help" +gdb_test "help set print test-undoc-param" "This command is not documented.*" "Test set help" +gdb_test "help set print" "set print test-undoc-param -- This command is not documented.*" "Test general help" + +# Test a parameter that is not documented in any way.. +gdb_py_test_multiple "Simple gdb booleanparameter" \ + "python" "" \ + "class TestNodocParam (gdb.Parameter):" "" \ + " def __init__ (self, name):" "" \ + " super (TestNodocParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_BOOLEAN)" "" \ + " self.value = True" "" \ + "test_nodoc_param = TestNodocParam ('print test-nodoc-param')" ""\ + "end" + +gdb_test "show print test-nodoc-param" "This command is not documented.*" "Show parameter on" +gdb_test "set print test-nodoc-param off" "This command is not documented.*" "Turn off parameter" +gdb_test "show print test-nodoc-param" "This command is not documented.*.*" "Show parameter off" +gdb_test "python print test_nodoc_param.value" "False" "Test parameter value" +gdb_test "help show print test-nodoc-param" "This command is not documented.*" "Test show help" +gdb_test "help set print test-nodoc-param" "This command is not documented.*" "Test set help" +gdb_test "help set print" "set print test-nodoc-param -- This command is not documented.*" "Test general help" + +# Test deprecated API. Do not use in your own implementations. +gdb_py_test_multiple "Simple gdb booleanparameter" \ + "python" "" \ + "class TestParam (gdb.Parameter):" "" \ + " \"\"\"When enabled, test param does something useful. When disabled, does nothing.\"\"\"" "" \ + " show_doc = \"State of the Test Parameter\"" ""\ + " set_doc = \"Set the state of the Test Parameter\"" "" \ + " def __init__ (self, name):" "" \ + " super (TestParam, self).__init__ (name, gdb.COMMAND_DATA, gdb.PARAM_BOOLEAN)" "" \ + " self.value = True" "" \ + "test_param = TestParam ('print test-param')" ""\ + "end" + +gdb_test "python print test_param.value" "True" "Test parameter value" +gdb_test "show print test-param" "State of the Test Parameter on.*" "Show parameter on" +gdb_test "set print test-param off" "Set the state of the Test Parameter.*" "Turn off parameter" +gdb_test "show print test-param" "State of the Test Parameter off.*" "Show parameter off" +gdb_test "python print test_param.value" "False" "Test parameter value" +gdb_test "help show print test-param" "State of the Test Parameter.*" "Test show help" +gdb_test "help set print test-param" "Set the state of the Test Parameter.*" "Test set help" +gdb_test "help set print" "set print test-param -- Set the state of the Test Parameter.*" "Test general help" |