brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 9540dc0 Raw
93 lines · python
1import lldb2from lldbsuite.test.decorators import *3from lldbsuite.test.lldbtest import *4from lldbsuite.test import lldbutil5from lldbsuite.test_event.build_exception import BuildError6 7 8class TestCase(TestBase):9    NO_DEBUG_INFO_TESTCASE = True10 11    def build_and_run(self, test_file):12        """13        Tries building the given test source and runs to the first breakpoint.14        Returns false if the file fails to build due to an unsupported calling15        convention on the current test target. Returns true if building and16        running to the breakpoint succeeded.17        """18        try:19            self.build(20                dictionary={21                    "C_SOURCES": test_file,22                    "CFLAGS_EXTRAS": "-Werror=ignored-attributes",23                }24            )25        except BuildError as e:26            # Test source failed to build. Check if it failed because the27            # calling convention argument is unsupported/unknown in which case28            # the test should be skipped.29            error_msg = str(e)30            # Clang gives an explicit error when a calling convention is31            # not supported.32            if "calling convention is not supported for this target" in error_msg:33                return False34            # GCC's has two different generic warnings it can emit.35            if "attribute ignored" in error_msg:36                return False37            if "attribute directive ignored " in error_msg:38                return False39            # We got a different build error, so raise it again to fail the40            # test.41            raise42        lldbutil.run_to_source_breakpoint(43            self, "// break here", lldb.SBFileSpec(test_file)44        )45        return True46 47    @skipIf(compiler="clang", compiler_version=["<", "9.0"])48    def test_regcall(self):49        if not self.build_and_run("regcall.c"):50            return51        self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")52 53    @skipIf(compiler="clang", compiler_version=["<", "17.0"], archs=["arm64"])54    @skipIf(compiler="clang", compiler_version=["<", "9.0"])55    def test_ms_abi(self):56        if not self.build_and_run("ms_abi.c"):57            return58        self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")59 60    @skipIf(compiler="clang", compiler_version=["<", "9.0"])61    def test_stdcall(self):62        if not self.build_and_run("stdcall.c"):63            return64        self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")65 66    # Fails on x86, passes elsewhere because clang doesn't support vectorcall on67    # any other architectures.68    @expectedFailureAll(69        triple=re.compile("^(x86|i386)"),70        oslist=["freebsd"], bugnumber="github.com/llvm/llvm-project/issues/56084"71    )72    def test_vectorcall(self):73        if not self.build_and_run("vectorcall.c"):74            return75        self.expect_expr("func(1.0)", result_type="int", result_value="1")76 77    @skipIf(compiler="clang", compiler_version=["<", "9.0"])78    def test_fastcall(self):79        if not self.build_and_run("fastcall.c"):80            return81        self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")82 83    @skipIf(compiler="clang", compiler_version=["<", "9.0"])84    def test_pascal(self):85        if not self.build_and_run("pascal.c"):86            return87        self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")88 89    def test_sysv_abi(self):90        if not self.build_and_run("sysv_abi.c"):91            return92        self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")93