Todd Fiala | b91de78 | 2014-06-27 16:52:49 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test lldb 'image list' on object files across multiple architectures. |
| 3 | This exercises classes like ObjectFileELF and their support for opening |
| 4 | foreign-architecture object files. |
| 5 | """ |
| 6 | |
Todd Fiala | b91de78 | 2014-06-27 16:52:49 +0000 | [diff] [blame] | 7 | import os.path |
| 8 | import unittest2 |
| 9 | import lldb |
| 10 | from lldbtest import * |
| 11 | import lldbutil |
| 12 | import re |
| 13 | |
| 14 | class TestImageListMultiArchitecture(TestBase): |
| 15 | |
| 16 | mydir = TestBase.compute_mydir(__file__) |
| 17 | |
| 18 | def setUp(self): |
| 19 | # Call super's setUp(). |
| 20 | TestBase.setUp(self) |
| 21 | |
| 22 | def test_image_list_shows_multiple_architectures(self): |
| 23 | """Test that image list properly shows the correct architecture for a set of different architecture object files.""" |
| 24 | images = { |
Todd Fiala | 6ce5b63 | 2014-06-27 20:07:03 +0000 | [diff] [blame] | 25 | "hello-freebsd-10.0-x86_64-clang-3.3": re.compile(r"x86_64-(unknown)?-freebsd10.0 x86_64"), |
| 26 | "hello-freebsd-10.0-x86_64-gcc-4.7.3": re.compile(r"x86_64-(unknown)?-freebsd10.0 x86_64"), |
| 27 | "hello-netbsd-6.1-x86_64-gcc-4.5.3": re.compile(r"x86_64-(unknown)?-netbsd x86_64"), |
| 28 | "hello-ubuntu-14.04-x86_64-gcc-4.8.2": re.compile(r"x86_64-(unknown)?-linux x86_64"), |
| 29 | "hello-ubuntu-14.04-x86_64-clang-3.5pre": re.compile(r"x86_64-(unknown)?-linux x86_64"), |
Todd Fiala | 002fb10 | 2014-07-23 15:16:35 +0000 | [diff] [blame] | 30 | "hello-unknown-kalimba_arch4-kcc-36": re.compile(r"kalimba-csr-unknown kalimba"), |
Todd Fiala | b91de78 | 2014-06-27 16:52:49 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | for image_name in images: |
Todd Fiala | 6ce5b63 | 2014-06-27 20:07:03 +0000 | [diff] [blame] | 34 | file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), "bin", image_name)) |
Todd Fiala | b91de78 | 2014-06-27 16:52:49 +0000 | [diff] [blame] | 35 | expected_triple_and_arch_regex = images[image_name] |
| 36 | |
| 37 | self.runCmd("file {}".format(file_name)) |
| 38 | self.match("image list -t -A", [expected_triple_and_arch_regex]) |
| 39 | |
| 40 | if __name__ == '__main__': |
| 41 | import atexit |
| 42 | lldb.SBDebugger.Initialize() |
| 43 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 44 | unittest2.main() |