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