diff options
author | Pavel Labath <pavel@labath.sk> | 2019-08-14 08:11:20 +0000 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2019-08-14 08:11:20 +0000 |
commit | 72ef113d40ef57d9dd4cf7ba6819e2048df99fc6 (patch) | |
tree | 2f9a8ca0bdf41f0e1f550713d67aced265fc8616 /lldb/packages/Python/lldbsuite/test/python_api/interpreter | |
parent | 1427226fe8c363b454a06ead02b041b1f658fe8f (diff) | |
download | bcm5719-llvm-72ef113d40ef57d9dd4cf7ba6819e2048df99fc6.tar.gz bcm5719-llvm-72ef113d40ef57d9dd4cf7ba6819e2048df99fc6.zip |
[API] Have SBCommandReturnObject::GetOutput/Error return "" instead of nullptr
Summary:
It seems this was an unintended side-effect of D26698. AFAICT, these
functions did return an empty string before that patch, and the patch
contained code which attempted to ensure that, but those efforts were
negated by ConstString::AsCString, which by default returns a nullptr
even for empty strings.
This patch:
- fixes the GetOutput/Error methods to really return empty strings
- adds and explicit test for that
- removes a workaround in lldbtest.py, which was masking this problem
from our other tests
Reviewers: jingham, clayborg
Subscribers: zturner, lldb-commits
Differential Revision: https://reviews.llvm.org/D65739
llvm-svn: 368806
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/python_api/interpreter')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py b/lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py index 7703d20ed41..a920ce845b8 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py @@ -12,6 +12,7 @@ from lldbsuite.test import lldbutil class CommandInterpreterAPICase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). @@ -72,3 +73,19 @@ class CommandInterpreterAPICase(TestBase): if self.TraceOn(): lldbutil.print_stacktraces(process) + + @add_test_categories(['pyapi']) + def test_command_output(self): + """Test command output handling.""" + ci = self.dbg.GetCommandInterpreter() + self.assertTrue(ci, VALID_COMMAND_INTERPRETER) + + # Test that a command which produces no output returns "" instead of + # None. + res = lldb.SBCommandReturnObject() + ci.HandleCommand("settings set use-color false", res) + self.assertTrue(res.Succeeded()) + self.assertIsNotNone(res.GetOutput()) + self.assertEquals(res.GetOutput(), "") + self.assertIsNotNone(res.GetError()) + self.assertEquals(res.GetError(), "") |