TestUniversal.py revision 8bd8e425ca5b1bcd3a2624d3964361a96f9fa39e
1"""Test aspects of lldb commands on universal binaries."""
2
3import os, time
4import unittest2
5import lldb
6from lldbtest import *
7
8class TestUniversal(TestBase):
9
10    mydir = "macosx/universal"
11
12    def test_process_launch_for_universal(self):
13        """Test process launch of a universal binary."""
14
15        # Note that "testit" is a universal binary.
16        exe = os.path.join(os.getcwd(), "testit")
17
18        # By default, x86_64 is assumed if no architecture is specified.
19        self.expect("file " + exe, CURRENT_EXECUTABLE_SET,
20            startstr = "Current executable set to ",
21            substrs = ["testit' (x86_64)."])
22
23        # Break inside the main.
24        self.expect("breakpoint set -f main.c -l 5", BREAKPOINT_CREATED,
25            startstr = "Breakpoint created: 1: file ='main.c', line = 5, locations = 1")
26
27        # We should be able to launch the x86_64 executable.
28        self.runCmd("run", RUN_STOPPED)
29        self.runCmd("continue")
30
31        # Now specify i386 as the architecture for "testit".
32        self.expect("file " + exe + " -a i386", CURRENT_EXECUTABLE_SET,
33            startstr = "Current executable set to ",
34            substrs = ["testit' (i386)."])
35
36        # Break inside the main.
37        self.expect("breakpoint set -f main.c -l 5", BREAKPOINT_CREATED,
38            startstr = "Breakpoint created: 1: file ='main.c', line = 5, locations = 1")
39
40        # We should be able to launch the i386 executable as well.
41        self.runCmd("run", RUN_STOPPED)
42        self.runCmd("continue")
43
44
45if __name__ == '__main__':
46    import atexit
47    lldb.SBDebugger.Initialize()
48    atexit.register(lambda: lldb.SBDebugger.Terminate())
49    unittest2.main()
50