summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/python_api/module_section
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/python_api/module_section')
-rw-r--r--packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
index 79b988465d7e..65b159974c08 100644
--- a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
+++ b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
@@ -26,7 +26,7 @@ class ModuleAndSectionAPIsTestCase(TestBase):
def test_module_and_section(self):
"""Test module and section APIs."""
self.build()
- exe = os.path.join(os.getcwd(), "a.out")
+ exe = self.getBuildArtifact("a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
@@ -77,7 +77,7 @@ class ModuleAndSectionAPIsTestCase(TestBase):
def test_module_and_section_boundary_condition(self):
"""Test module and section APIs by passing None when it expects a Python string."""
self.build()
- exe = os.path.join(os.getcwd(), "a.out")
+ exe = self.getBuildArtifact("a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
@@ -118,7 +118,7 @@ class ModuleAndSectionAPIsTestCase(TestBase):
def test_module_compile_unit_iter(self):
"""Test module's compile unit iterator APIs."""
self.build()
- exe = os.path.join(os.getcwd(), "a.out")
+ exe = self.getBuildArtifact("a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
@@ -141,3 +141,29 @@ class ModuleAndSectionAPIsTestCase(TestBase):
INDENT2 = INDENT * 2
for cu in exe_module.compile_unit_iter():
print(cu)
+
+ @add_test_categories(['pyapi'])
+ def test_find_compile_units(self):
+ """Exercise SBModule.FindCompileUnits() API."""
+ d = {'EXE': 'b.out'}
+ self.build(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+ self.find_compile_units(self.getBuildArtifact('b.out'))
+
+ def find_compile_units(self, exe):
+ """Exercise SBModule.FindCompileUnits() API."""
+ source_name_list = ["main.cpp", "b.cpp", "c.cpp"]
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ num_modules = target.GetNumModules()
+ for i in range(num_modules):
+ module = target.GetModuleAtIndex(i)
+ for source_name in source_name_list:
+ list = module.FindCompileUnits(lldb.SBFileSpec(source_name, False))
+ for sc in list:
+ self.assertTrue(
+ sc.GetCompileUnit().GetFileSpec().GetFilename() ==
+ source_name)