xref: /llvm-project/lldb/test/API/macosx/order/TestOrderFile.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test that debug symbols have the correct order as specified by the order file.
3"""
4
5
6import re
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12
13class OrderFileTestCase(TestBase):
14    @skipUnlessDarwin
15    def test(self):
16        """Test debug symbols follow the correct order by the order file."""
17        self.build()
18        exe = self.getBuildArtifact("a.out")
19        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
20
21        # Test that the debug symbols have Function f3 before Function f1.
22        # Use "-s address" option to sort by address.
23        self.runCmd("image dump symtab -s address %s" % exe)
24        output = self.res.GetOutput()
25        mo_f3 = re.search("Code +.+f3", output)
26        mo_f1 = re.search("Code +.+f1", output)
27
28        # Match objects for f3 and f1 must exist and f3 must come before f1.
29        self.assertTrue(
30            mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(),
31            "Symbols have correct order by the order file",
32        )
33
34        self.runCmd("run", RUN_COMPLETED)
35