blob: d8b7f37f26bd1ae7b4cc536d0a8639ea42573bbd [file] [log] [blame]
Johnny Chenacfbeff2010-07-08 00:17:29 +00001"""
2Test that debug symbols have the correct order as specified by the order file.
3"""
4
5import os, time
6import re
Johnny Chen73258832010-08-05 23:42:46 +00007import unittest2
Johnny Chenacfbeff2010-07-08 00:17:29 +00008import lldb
Johnny Chen17941842010-08-09 23:44:24 +00009from lldbtest import *
Johnny Chenacfbeff2010-07-08 00:17:29 +000010
Johnny Chencbb4be02010-09-01 19:59:58 +000011class OrderFileTestCase(TestBase):
Johnny Chenacfbeff2010-07-08 00:17:29 +000012
Greg Clayton4570d3e2013-12-10 23:19:29 +000013 mydir = TestBase.compute_mydir(__file__)
Johnny Chenacfbeff2010-07-08 00:17:29 +000014
Robert Flack13c7ad92015-03-30 14:12:17 +000015 @skipUnlessDarwin
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000016 def test(self):
Johnny Chenacfbeff2010-07-08 00:17:29 +000017 """Test debug symbols follow the correct order by the order file."""
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000018 self.build()
Johnny Chenacfbeff2010-07-08 00:17:29 +000019 exe = os.path.join(os.getcwd(), "a.out")
Johnny Chenff3d01d2010-08-20 21:03:09 +000020 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
Johnny Chenacfbeff2010-07-08 00:17:29 +000021
22 # Test that the debug symbols have Function f3 before Function f1.
Johnny Chen96332142010-12-17 18:02:08 +000023 # Use "-s address" option to sort by address.
24 self.runCmd("image dump symtab -s address a.out")
Johnny Chenff3d01d2010-08-20 21:03:09 +000025 output = self.res.GetOutput()
Johnny Chen9440d1c2010-09-13 16:59:11 +000026 mo_f3 = re.search("Code +.+f3", output)
27 mo_f1 = re.search("Code +.+f1", output)
Johnny Chenacfbeff2010-07-08 00:17:29 +000028
29 # Match objects for f3 and f1 must exist and f3 must come before f1.
Johnny Chen17941842010-08-09 23:44:24 +000030 self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(),
31 "Symbols have correct order by the order file")
Johnny Chenacfbeff2010-07-08 00:17:29 +000032
Johnny Chenff3d01d2010-08-20 21:03:09 +000033 self.runCmd("run", RUN_COMPLETED)
Johnny Chenacfbeff2010-07-08 00:17:29 +000034
Johnny Chenacfbeff2010-07-08 00:17:29 +000035if __name__ == '__main__':
Johnny Chena2124952010-08-05 21:23:45 +000036 import atexit
Johnny Chenacfbeff2010-07-08 00:17:29 +000037 lldb.SBDebugger.Initialize()
Johnny Chena2124952010-08-05 21:23:45 +000038 atexit.register(lambda: lldb.SBDebugger.Terminate())
Johnny Chen73258832010-08-05 23:42:46 +000039 unittest2.main()