forked from OSchip/llvm-project
				
			Fix for TestSharedLib.py (on Linux)
- use lldb 'settings' command to help testcase find shared library - pull up dyldPath variable from TestLoadUnload.py to fixture base class (applicable in multiple cases) llvm-svn: 168612
This commit is contained in:
		
							parent
							
								
									f8b24cf5f7
								
							
						
					
					
						commit
						179ff29811
					
				| 
						 | 
				
			
			@ -31,7 +31,6 @@ class LoadUnloadTestCase(TestBase):
 | 
			
		|||
 | 
			
		||||
        if sys.platform.startswith("darwin"):
 | 
			
		||||
            dylibName = 'libd.dylib'
 | 
			
		||||
            dylibPath = 'DYLD_LIBRARY_PATH'
 | 
			
		||||
 | 
			
		||||
        # The directory with the dynamic library we did not link to.
 | 
			
		||||
        new_dir = os.path.join(os.getcwd(), "hidden")
 | 
			
		||||
| 
						 | 
				
			
			@ -62,13 +61,13 @@ class LoadUnloadTestCase(TestBase):
 | 
			
		|||
        # Obliterate traces of libd from the old location.
 | 
			
		||||
        os.remove(old_dylib)
 | 
			
		||||
        # Inform dyld of the new path, too.
 | 
			
		||||
        env_cmd_string = "settings set target.env-vars " + dylibPath + "=" + new_dir
 | 
			
		||||
        env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir
 | 
			
		||||
        if self.TraceOn():
 | 
			
		||||
            print "Set environment to: ", env_cmd_string
 | 
			
		||||
        self.runCmd(env_cmd_string)
 | 
			
		||||
        self.runCmd("settings show target.env-vars")
 | 
			
		||||
 | 
			
		||||
        remove_dyld_path_cmd = "settings remove target.env-vars " + dylibPath
 | 
			
		||||
        remove_dyld_path_cmd = "settings remove target.env-vars " + self.dylibPath
 | 
			
		||||
        self.addTearDownHook(lambda: self.runCmd(remove_dyld_path_cmd))
 | 
			
		||||
 | 
			
		||||
        self.runCmd("run")
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +88,6 @@ class LoadUnloadTestCase(TestBase):
 | 
			
		|||
        if sys.platform.startswith("darwin"):
 | 
			
		||||
            dylibName = 'libd.dylib'
 | 
			
		||||
            dsymName = 'libd.dylib.dSYM'
 | 
			
		||||
            dylibPath = 'DYLD_LIBRARY_PATH'
 | 
			
		||||
 | 
			
		||||
        # The directory to relocate the dynamic library and its debugging info.
 | 
			
		||||
        special_dir = "hidden"
 | 
			
		||||
| 
						 | 
				
			
			@ -105,13 +103,13 @@ class LoadUnloadTestCase(TestBase):
 | 
			
		|||
        # Try running with the DYLD_LIBRARY_PATH environment variable set, make sure
 | 
			
		||||
        # we pick up the hidden dylib.
 | 
			
		||||
 | 
			
		||||
        env_cmd_string = "settings set target.env-vars " + dylibPath + "=" + new_dir
 | 
			
		||||
        env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir
 | 
			
		||||
        if self.TraceOn():
 | 
			
		||||
            print "Set environment to: ", env_cmd_string
 | 
			
		||||
        self.runCmd(env_cmd_string)
 | 
			
		||||
        self.runCmd("settings show target.env-vars")
 | 
			
		||||
 | 
			
		||||
        remove_dyld_path_cmd = "settings remove target.env-vars " + dylibPath
 | 
			
		||||
        remove_dyld_path_cmd = "settings remove target.env-vars " + self.dylibPath
 | 
			
		||||
        self.addTearDownHook(lambda: self.runCmd(remove_dyld_path_cmd))
 | 
			
		||||
 | 
			
		||||
        lldbutil.run_break_set_by_file_and_line (self, "d.c", self.line_d_function, num_expected_locations=1, loc_exact=True)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,6 +39,9 @@ class SharedLibTestCase(TestBase):
 | 
			
		|||
        TestBase.setUp(self)
 | 
			
		||||
        # Find the line number to break inside main().
 | 
			
		||||
        self.line = line_number('main.c', '// Set breakpoint 0 here.')
 | 
			
		||||
        if sys.platform.startswith("linux"):
 | 
			
		||||
            self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.getcwd())
 | 
			
		||||
            self.addTearDownHook(lambda: self.runCmd("settings remove target.env-vars " + self.dylibPath))
 | 
			
		||||
 | 
			
		||||
    def common_setup(self):
 | 
			
		||||
        exe = os.path.join(os.getcwd(), "a.out")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -621,6 +621,12 @@ class Base(unittest2.TestCase):
 | 
			
		|||
        # See HideStdout(self).
 | 
			
		||||
        self.sys_stdout_hidden = False
 | 
			
		||||
 | 
			
		||||
        # set environment variable names for finding shared libraries
 | 
			
		||||
        if sys.platform.startswith("darwin"):
 | 
			
		||||
            self.dylibPath = 'DYLD_LIBRARY_PATH'
 | 
			
		||||
        elif sys.platform.startswith("linux") or sys.platform.startswith("freebsd"):
 | 
			
		||||
            self.dylibPath = 'LD_LIBRARY_PATH'
 | 
			
		||||
 | 
			
		||||
    def runHooks(self, child=None, child_prompt=None, use_cmd_api=False):
 | 
			
		||||
        """Perform the run hooks to bring lldb debugger to the desired state.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue