Author: Jim Ingham
Date: 2020-10-29T16:39:35-07:00
New Revision: 32a85b268a010035e81646541ac1c9675da6cb2e

URL: 
https://github.com/llvm/llvm-project/commit/32a85b268a010035e81646541ac1c9675da6cb2e
DIFF: 
https://github.com/llvm/llvm-project/commit/32a85b268a010035e81646541ac1c9675da6cb2e.diff

LOG: This is a preliminary version of the test for 
https://reviews.llvm.org/D88483.

The test can be cleaned up a bit, but this should be good to see why the
Debian bot is failing...

Added: 
    

Modified: 
    lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py

Removed: 
    


################################################################################
diff  --git 
a/lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py 
b/lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
index e6acecc76e17..ccab396455ea 100644
--- a/lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
+++ b/lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
@@ -13,10 +13,56 @@ class TestTypeGetModule(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
+    def find_module(self, target, name):
+        num_modules = target.GetNumModules()
+        index = 0
+        result = lldb.SBModule()
+        
+        while index < num_modules:
+            module = target.GetModuleAtIndex(index)
+            if module.GetFileSpec().GetFilename() == name:
+                result = module
+                break
+                
+            index += 1
+            
+        return result
+
+    def find_comp_unit(self, exe_module, name):
+        num_comp_units = exe_module.GetNumCompileUnits()
+        index = 0
+        result = lldb.SBCompileUnit()
+        
+        while index < num_comp_units:
+            comp_unit = exe_module.GetCompileUnitAtIndex(index)
+            if comp_unit.GetFileSpec().GetFilename() == name:
+                result = comp_unit
+                break
+                
+            index += 1
+            
+        return result
+        
+    def find_type(self, type_list, name):
+        num_types = type_list.GetSize()
+        index = 0
+        result = lldb.SBType()
+        
+        while index < num_types:
+            type = type_list.GetTypeAtIndex(index)
+            if type.GetName() == name:
+                result = type
+                break
+                
+            index += 1
+        
+        return result
+            
     def test(self):
         self.build()
         target  = lldbutil.run_to_breakpoint_make_target(self)
-        exe_module = target.GetModuleAtIndex(0)
+        exe_module = self.find_module(target, 'a.out')
+        self.assertTrue(exe_module.IsValid())
         
         type1_name = 'compile_unit1_type'
         type2_name = 'compile_unit2_type'
@@ -24,13 +70,19 @@ def test(self):
         num_comp_units = exe_module.GetNumCompileUnits()
         self.assertEqual(num_comp_units, 3)
         
-        comp_unit = exe_module.GetCompileUnitAtIndex(1)
-        type_name = comp_unit.GetTypes().GetTypeAtIndex(0).GetName()
-        self.assertEqual(type_name, type1_name)
+        comp_unit = self.find_comp_unit(exe_module, 'compile_unit1.c')
+        self.assertTrue(comp_unit.IsValid())
+        
+        cu_type = self.find_type(comp_unit.GetTypes(), type1_name)
+        self.assertTrue(cu_type.IsValid())
+        self.assertEqual(cu_type.GetName(), type1_name)
+        
+        comp_unit = self.find_comp_unit(exe_module, 'compile_unit2.c')
+        self.assertTrue(comp_unit.IsValid())
         
-        comp_unit = exe_module.GetCompileUnitAtIndex(2)
-        type_name = comp_unit.GetTypes().GetTypeAtIndex(0).GetName()
-        self.assertEqual(type_name, type2_name)
+        cu_type = self.find_type(comp_unit.GetTypes(), type2_name)
+        self.assertTrue(cu_type.IsValid())
+        self.assertEqual(cu_type.GetName(), type2_name)
         
         type1 = target.FindFirstType(type1_name)
         self.assertTrue(type1.IsValid())


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to