aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api/basename/TestGetBaseName.py
blob: a3b752e67a356d3b48f49d5c85f007251e8031e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Test SBFunction::GetBaseName() and SBSymbol::GetBaseName() APIs.
"""

import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class GetBaseNameTestCase(TestBase):
    NO_DEBUG_INFO_TESTCASE = True

    def setUp(self):
        TestBase.setUp(self)
        self.main_source_file = lldb.SBFileSpec("main.cpp")

    @expectedFailureAll(
        oslist=["windows"],
        bugnumber="https://github.com/llvm/llvm-project/issues/156861",
    )
    def test(self):
        """Test SBFunction.GetBaseName() and SBSymbol.GetBaseName()"""
        self.build()
        _, _, thread, _ = lldbutil.run_to_source_breakpoint(
            self, "Set a breakpoint here", self.main_source_file
        )

        frame0 = thread.GetFrameAtIndex(0)

        # Get both function and symbol
        function = frame0.GetFunction()
        symbol = frame0.GetSymbol()

        # Test consistency between function and symbol basename
        function_basename = function.GetBaseName()
        symbol_basename = symbol.GetBaseName()

        self.assertEqual(function_basename, "templateFunc")
        self.assertEqual(symbol_basename, "templateFunc")