diff options
author | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
commit | c432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch) | |
tree | 4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py | |
parent | a8a3bd210086b50242903ed95048fe5e53897878 (diff) | |
download | bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip |
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code
structured into a bona-fide Python package. This has a number
of benefits, but most notably the ability to more easily share
Python code between different but related pieces of LLDB's Python
infrastructure (for example, `scripts` can now share code with
`test`).
llvm-svn: 251532
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py b/lldb/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py new file mode 100644 index 00000000000..12e0939224d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/macosx/universal/TestUniversal.py @@ -0,0 +1,107 @@ +"""Test aspects of lldb commands on universal binaries.""" + +from __future__ import print_function + +import use_lldb_suite + +import unittest2 +import os, time +import lldb +from lldbtest import * +import lldbutil + +class UniversalTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break inside main(). + self.line = line_number('main.c', '// Set break point at this line.') + + @add_test_categories(['pyapi']) + @skipUnlessDarwin + @unittest2.skipUnless(hasattr(os, "uname") and os.uname()[4] in ['i386', 'x86_64'], + "requires i386 or x86_64") + def test_sbdebugger_create_target_with_file_and_target_triple(self): + """Test the SBDebugger.CreateTargetWithFileAndTargetTriple() API.""" + # Invoke the default build rule. + self.build() + + # Note that "testit" is a universal binary. + exe = os.path.join(os.getcwd(), "testit") + + # Create a target by the debugger. + target = self.dbg.CreateTargetWithFileAndTargetTriple(exe, "i386-apple-macosx") + self.assertTrue(target, VALID_TARGET) + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple (None, None, self.get_process_working_directory()) + self.assertTrue(process, PROCESS_IS_VALID) + + @skipUnlessDarwin + @unittest2.skipUnless(hasattr(os, "uname") and os.uname()[4] in ['i386', 'x86_64'], + "requires i386 or x86_64") + def test_process_launch_for_universal(self): + """Test process launch of a universal binary.""" + from lldbutil import print_registers + + # Invoke the default build rule. + self.build() + + # Note that "testit" is a universal binary. + exe = os.path.join(os.getcwd(), "testit") + + # By default, x86_64 is assumed if no architecture is specified. + self.expect("file " + exe, CURRENT_EXECUTABLE_SET, + startstr = "Current executable set to ", + substrs = ["testit' (x86_64)."]) + + # Break inside the main. + lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + + # We should be able to launch the x86_64 executable. + self.runCmd("run", RUN_SUCCEEDED) + + # Check whether we have a 64-bit process launched. + target = self.dbg.GetSelectedTarget() + process = target.GetProcess() + self.assertTrue(target and process and + self.invoke(process, 'GetAddressByteSize') == 8, + "64-bit process launched") + + frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0) + registers = print_registers(frame, string_buffer=True) + self.expect(registers, exe=False, + substrs = ['Name: rax']) + + self.runCmd("continue") + + # Now specify i386 as the architecture for "testit". + self.expect("file -a i386 " + exe, CURRENT_EXECUTABLE_SET, + startstr = "Current executable set to ", + substrs = ["testit' (i386)."]) + + # Break inside the main. + lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + + # We should be able to launch the i386 executable as well. + self.runCmd("run", RUN_SUCCEEDED) + + # Check whether we have a 32-bit process launched. + target = self.dbg.GetSelectedTarget() + process = target.GetProcess() + self.assertTrue(target and process, + "32-bit process launched") + + pointerSize = self.invoke(process, 'GetAddressByteSize') + self.assertTrue(pointerSize == 4, + "AddressByteSize of 32-bit process should be 4, got %d instead." % pointerSize) + + frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0) + registers = print_registers(frame, string_buffer=True) + self.expect(registers, exe=False, + substrs = ['Name: eax']) + + self.runCmd("continue") |