summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorVadim Macagon <vadim.macagon@gmail.com>2017-08-09 09:20:40 +0000
committerVadim Macagon <vadim.macagon@gmail.com>2017-08-09 09:20:40 +0000
commitc10e34d07c90ee0757b6a9aaf7205584ce6d372c (patch)
tree03d99c7744fa07d9d000ac17a170a3f13e3c5b5c /lldb/packages/Python/lldbsuite/test
parent9c3deaa6533ddbf8fa5f44c33202dbb9fe368516 (diff)
downloadbcm5719-llvm-c10e34d07c90ee0757b6a9aaf7205584ce6d372c.tar.gz
bcm5719-llvm-c10e34d07c90ee0757b6a9aaf7205584ce6d372c.zip
Expose active and available platform lists via SBDebugger API
Summary: The available platform list was previously only accessible via the `platform list` command, this patch makes it possible to access that list via the SBDebugger API. The active platform list has likewise been exposed via the SBDebugger API. Differential Revision: https://reviews.llvm.org/D35760 llvm-svn: 310452
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformPython.py70
-rw-r--r--lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_debugger.py4
2 files changed, 74 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformPython.py b/lldb/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformPython.py
new file mode 100644
index 00000000000..8ea18ea5970
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/platform/TestPlatformPython.py
@@ -0,0 +1,70 @@
+"""
+Test the lldb platform Python API.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class PlatformPythonTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @add_test_categories(['pyapi'])
+ @no_debug_info_test
+ def test_platform_list(self):
+ """Test SBDebugger::GetNumPlatforms() & GetPlatformAtIndex() API"""
+ # Verify there's only the host platform present by default.
+ self.assertEqual(self.dbg.GetNumPlatforms(), 1)
+ host_platform = self.dbg.GetPlatformAtIndex(0)
+ self.assertTrue(host_platform.IsValid() and
+ host_platform.GetName() == 'host',
+ 'Only the host platform is available')
+ # Select another platform and verify that the platform is added to
+ # the platform list.
+ platform_idx = self.dbg.GetNumAvailablePlatforms() - 1
+ if platform_idx < 1:
+ self.fail('No platforms other than host are available')
+ platform_data = self.dbg.GetAvailablePlatformInfoAtIndex(platform_idx)
+ platform_name = platform_data.GetValueForKey('name').GetStringValue(100)
+ self.assertNotEqual(platform_name, 'host')
+ self.dbg.SetCurrentPlatform(platform_name)
+ selected_platform = self.dbg.GetSelectedPlatform()
+ self.assertTrue(selected_platform.IsValid())
+ self.assertEqual(selected_platform.GetName(), platform_name)
+ self.assertEqual(self.dbg.GetNumPlatforms(), 2)
+ platform = self.dbg.GetPlatformAtIndex(1)
+ self.assertEqual(platform.GetName(), platform_name)
+
+ @add_test_categories(['pyapi'])
+ @no_debug_info_test
+ def test_available_platform_list(self):
+ """Test SBDebugger::GetNumAvailablePlatforms() and GetAvailablePlatformInfoAtIndex() API"""
+ num_platforms = self.dbg.GetNumAvailablePlatforms()
+ self.assertGreater(
+ num_platforms, 0,
+ 'There should be at least one platform available')
+
+ for i in range(num_platforms):
+ platform_data = self.dbg.GetAvailablePlatformInfoAtIndex(i)
+ name_data = platform_data.GetValueForKey('name')
+ desc_data = platform_data.GetValueForKey('description')
+ self.assertTrue(
+ name_data and name_data.IsValid(),
+ 'Platform has a name')
+ self.assertEqual(
+ name_data.GetType(), lldb.eStructuredDataTypeString,
+ 'Platform name is a string')
+ self.assertTrue(
+ desc_data and desc_data.IsValid(),
+ 'Platform has a description')
+ self.assertEqual(
+ desc_data.GetType(), lldb.eStructuredDataTypeString,
+ 'Platform description is a string')
diff --git a/lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_debugger.py b/lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_debugger.py
index 77e45c861e8..ac0f9a8aeb9 100644
--- a/lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_debugger.py
+++ b/lldb/packages/Python/lldbsuite/test/python_api/default-constructor/sb_debugger.py
@@ -30,6 +30,10 @@ def fuzz_obj(obj):
obj.FindTargetWithFileAndArch("a.out", "arm")
obj.GetNumTargets()
obj.GetSelectedTarget()
+ obj.GetNumPlatforms()
+ obj.GetPlatformAtIndex(0xffffffff)
+ obj.GetNumAvailablePlatforms()
+ obj.GetAvailablePlatformInfoAtIndex(0xffffffff)
obj.GetSourceManager()
obj.SetSelectedTarget(lldb.SBTarget())
obj.SetCurrentPlatformSDKRoot("tmp/sdk-root")
OpenPOWER on IntegriCloud