TestUniversal.py revision 61eb4f1a4361cc4774016acf66b40cd1d188ba83
1"""Test aspects of lldb commands on universal binaries.""" 2 3import os, time 4import unittest2 5import lldb 6from lldbtest import * 7 8class UniversalTestCase(TestBase): 9 10 mydir = os.path.join("macosx", "universal") 11 12 def setUp(self): 13 # Call super's setUp(). 14 TestBase.setUp(self) 15 # Find the line number to break inside main(). 16 self.line = line_number('main.c', '// Set break point at this line.') 17 18 @unittest2.expectedFailure 19 # rdar://problem/8689814 test failure: test/macosx/universal (the i386 slice does not break?) 20 @unittest2.skipUnless(sys.platform.startswith("darwin") and os.uname()[4]=='i386', 21 "requires Darwin & i386") 22 def test_process_launch_for_universal(self): 23 """Test process launch of a universal binary.""" 24 25 # Invoke the default build rule. 26 self.buildDefault() 27 28 # Note that "testit" is a universal binary. 29 exe = os.path.join(os.getcwd(), "testit") 30 31 # By default, x86_64 is assumed if no architecture is specified. 32 self.expect("file " + exe, CURRENT_EXECUTABLE_SET, 33 startstr = "Current executable set to ", 34 substrs = ["testit' (x86_64)."]) 35 36 # Break inside the main. 37 self.expect("breakpoint set -f main.c -l %d" % self.line, 38 BREAKPOINT_CREATED, 39 startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" % 40 self.line) 41 42 # We should be able to launch the x86_64 executable. 43 self.runCmd("run", RUN_SUCCEEDED) 44 45 # Check whether we have a 64-bit process launched. 46 target = self.dbg.GetSelectedTarget() 47 process = target.GetProcess() 48 self.assertTrue(target.IsValid() and process.IsValid() and 49 self.invoke(process, 'GetAddressByteSize') == 8, 50 "64-bit process launched") 51 52 self.runCmd("continue") 53 54 # Now specify i386 as the architecture for "testit". 55 self.expect("file " + exe + " -a i386", CURRENT_EXECUTABLE_SET, 56 startstr = "Current executable set to ", 57 substrs = ["testit' (i386)."]) 58 59 # Break inside the main. 60 self.expect("breakpoint set -f main.c -l %d" % self.line, 61 BREAKPOINT_CREATED, 62 startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" % 63 self.line) 64 65 # We should be able to launch the i386 executable as well. 66 self.runCmd("run", RUN_SUCCEEDED) 67 68 # Check whether we have a 32-bit process launched. 69 target = self.dbg.GetSelectedTarget() 70 process = target.GetProcess() 71 self.assertTrue(target.IsValid() and process.IsValid() and 72 self.invoke(process, 'GetAddressByteSize') == 4, 73 "32-bit process launched") 74 75 self.runCmd("continue") 76 77 78if __name__ == '__main__': 79 import atexit 80 lldb.SBDebugger.Initialize() 81 atexit.register(lambda: lldb.SBDebugger.Terminate()) 82 unittest2.main() 83