1"""Test that a dSYM can be found when a binary is in a deep bundle with multiple pathname components.""" 2 3 4#import unittest2 5from time import sleep 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13exe_name = 'deep-bundle' # must match Makefile 14 15class DeepBundleTestCase(TestBase): 16 17 mydir = TestBase.compute_mydir(__file__) 18 19 @skipIfRemote 20 @skipUnlessDarwin 21 # This test is explicitly a dSYM test, it doesn't need to run for any other config, but 22 # the following doesn't work, fixme. 23 # @skipIf(debug_info=no_match(["dsym"]), bugnumber="This test is looking explicitly for a dSYM") 24 25 def setUp(self): 26 TestBase.setUp(self) 27 self.source = 'main.c' 28 29 def tearDown(self): 30 # Destroy process before TestBase.tearDown() 31 self.dbg.GetSelectedTarget().GetProcess().Destroy() 32 33 # Call super's tearDown(). 34 TestBase.tearDown(self) 35 36 def test_attach_and_check_dsyms(self): 37 """Test attach to binary, see if the framework dSYM is found""" 38 exe = self.getBuildArtifact(exe_name) 39 self.build() 40 popen = self.spawnSubprocess(exe, [self.getBuildDir()]) 41 self.addTearDownHook(self.cleanupSubprocesses) 42 43 # Give the inferior time to start up, dlopen a bundle, remove the bundle it linked in 44 sleep(5) 45 46 # Since the library that was dlopen()'ed is now removed, lldb will need to find the 47 # binary & dSYM via target.exec-search-paths 48 settings_str = "settings set target.exec-search-paths " + self.get_process_working_directory() + "/hide.app" 49 self.runCmd(settings_str) 50 self.runCmd("process attach -p " + str(popen.pid)) 51 52 target = self.dbg.GetSelectedTarget() 53 self.assertTrue(target.IsValid(), 'Should have a valid Target after attaching to process') 54 55 setup_complete = target.FindFirstGlobalVariable("setup_is_complete") 56 self.assertEquals(setup_complete.GetValueAsUnsigned(), 1, 'Check that inferior process has completed setup') 57 58 # Find the bundle module, see if we found the dSYM too (they're both in "hide.app") 59 i = 0 60 found_module = False 61 while i < target.GetNumModules(): 62 mod = target.GetModuleAtIndex(i) 63 if mod.GetFileSpec().GetFilename() == 'MyFramework': 64 found_module = True 65 dsym_name = mod.GetSymbolFileSpec().GetFilename() 66 self.assertTrue (dsym_name == 'MyFramework', "Check that we found the dSYM for the bundle that was loaded") 67 i=i+1 68 69 self.assertTrue(found_module, "Check that we found the framework loaded in lldb's image list") 70 71if __name__ == '__main__': 72 unittest.main() 73