Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test that debug symbols have the correct order as specified by the order file. |
| 3 | """ |
| 4 | |
| 5 | import os, time |
| 6 | import re |
| 7 | import unittest |
| 8 | import lldb |
| 9 | import lldbtest |
| 10 | |
Johnny Chen | 3c39a98 | 2010-07-27 21:03:55 +0000 | [diff] [blame^] | 11 | class TestOrderFile(lldbtest.TestBase): |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 12 | |
| 13 | mydir = "order" |
| 14 | |
Johnny Chen | 3c39a98 | 2010-07-27 21:03:55 +0000 | [diff] [blame^] | 15 | def test_order_file(self): |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 16 | """Test debug symbols follow the correct order by the order file.""" |
| 17 | res = self.res |
| 18 | exe = os.path.join(os.getcwd(), "a.out") |
| 19 | self.ci.HandleCommand("file " + exe, res) |
| 20 | self.assertTrue(res.Succeeded()) |
| 21 | |
| 22 | # Test that the debug symbols have Function f3 before Function f1. |
| 23 | self.ci.HandleCommand("image dump symtab a.out", res) |
| 24 | self.assertTrue(res.Succeeded()) |
| 25 | output = res.GetOutput() |
| 26 | mo_f3 = re.search("Function +.+f3", output) |
| 27 | mo_f1 = re.search("Function +.+f1", output) |
| 28 | |
| 29 | # Match objects for f3 and f1 must exist and f3 must come before f1. |
| 30 | self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start()) |
| 31 | |
| 32 | self.ci.HandleCommand("run", res) |
| 33 | self.assertTrue(res.Succeeded()) |
| 34 | |
| 35 | |
| 36 | if __name__ == '__main__': |
| 37 | lldb.SBDebugger.Initialize() |
| 38 | unittest.main() |
| 39 | lldb.SBDebugger.Terminate() |