TestOrderFile.py revision 68687f50e278727ee89202eeb2b159034e55e202
1""" 2Test that debug symbols have the correct order as specified by the order file. 3""" 4 5import os, time 6import re 7import unittest2 8import lldb 9from lldbtest import * 10 11class OrderFileTestCase(TestBase): 12 13 mydir = os.path.join("macosx", "order") 14 15 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 16 def test_with_dsym(self): 17 """Test debug symbols follow the correct order by the order file.""" 18 self.buildDsym() 19 self.order_file() 20 21 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 22 def test_with_dwarf(self): 23 """Test debug symbols follow the correct order by the order file.""" 24 self.buildDwarf() 25 self.order_file() 26 27 def order_file(self): 28 """Test debug symbols follow the correct order by the order file.""" 29 exe = os.path.join(os.getcwd(), "a.out") 30 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 31 32 # Test that the debug symbols have Function f3 before Function f1. 33 # Use "-s address" option to sort by address. 34 self.runCmd("image dump symtab -s address a.out") 35 output = self.res.GetOutput() 36 mo_f3 = re.search("Code +.+f3", output) 37 mo_f1 = re.search("Code +.+f1", output) 38 39 # Match objects for f3 and f1 must exist and f3 must come before f1. 40 self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(), 41 "Symbols have correct order by the order file") 42 43 self.runCmd("run", RUN_COMPLETED) 44 45 46if __name__ == '__main__': 47 import atexit 48 lldb.SBDebugger.Initialize() 49 atexit.register(lambda: lldb.SBDebugger.Terminate()) 50 unittest2.main() 51