TestAppleTypesIsProduced.py revision a96b7890217c988c69f0f64cf608feb33f17db56
1"""
2Test that clang produces the __apple accelerator tables, for example, __apple_types, correctly.
3"""
4
5import os, time
6import unittest2
7import lldb
8from lldbtest import *
9from lldbutil import symbol_type_to_str
10
11class AppleTypesTestCase(TestBase):
12
13    mydir = os.path.join("macosx", "debug-info", "apple_types")
14
15    #rdar://problem/11166975
16    @unittest2.expectedFailure
17    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
18    def test_debug_info_for_apple_types(self):
19        """Test that __apple_types section does get produced by clang."""
20
21        if not self.getCompiler().endswith('clang'):
22            self.skipTest("clang compiler only test")
23
24        self.buildDefault()
25        self.apple_types()
26
27    def apple_types(self):
28        """Test that __apple_types section does get produced by clang."""
29        exe = os.path.join(os.getcwd(), "main.o")
30
31        target = self.dbg.CreateTarget(exe)
32        self.assertTrue(target, VALID_TARGET)
33        self.assertTrue(target.GetNumModules() > 0)
34
35        # Hide stdout if not running with '-t' option.
36        if not self.TraceOn():
37            self.HideStdout()
38
39        print "Number of modules for the target: %d" % target.GetNumModules()
40        for module in target.module_iter():
41            print module
42
43        # Get the executable module at index 0.
44        exe_module = target.GetModuleAtIndex(0)
45
46        debug_str_section = exe_module.FindSection("__debug_str")
47        self.assertTrue(debug_str_section)
48        print "__debug_str section:", debug_str_section
49
50        # Find our __apple_types section by name.
51        apple_types_section = exe_module.FindSection("__apple_types")
52        self.assertTrue(apple_types_section)
53        print "__apple_types section:", apple_types_section
54
55
56if __name__ == '__main__':
57    import atexit
58    lldb.SBDebugger.Initialize()
59    atexit.register(lambda: lldb.SBDebugger.Terminate())
60    unittest2.main()
61