xref: /llvm-project/lldb/test/API/macosx/macCatalyst/TestMacCatalyst.py (revision 80fcecb13c388ff087a27a4b0e7ca3dd8c98eaa4)
1import lldb
2from lldbsuite.test.lldbtest import *
3from lldbsuite.test.decorators import *
4import lldbsuite.test.lldbutil as lldbutil
5import os
6
7
8class TestMacCatalyst(TestBase):
9    @skipIf(macos_version=["<", "10.15"])
10    @skipUnlessDarwin
11    @skipIfDarwinEmbedded
12    def test_macabi(self):
13        """Test the x86_64-apple-ios-macabi target linked against a macos dylib"""
14        self.build()
15        log = self.getBuildArtifact("packets.log")
16        self.expect("log enable gdb-remote packets -f " + log)
17        lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.c"))
18        self.expect(
19            "image list -t -b",
20            patterns=[self.getArchitecture() + r".*-apple-ios.*-macabi a\.out"],
21        )
22        self.expect("fr v s", substrs=["Hello macCatalyst"])
23        self.expect("expression s", substrs=["Hello macCatalyst"])
24        self.check_debugserver(log)
25
26    def check_debugserver(self, log):
27        """scan the debugserver packet log"""
28        process_info = lldbutil.packetlog_get_process_info(log)
29        self.assertIn("ostype", process_info)
30        self.assertEqual(process_info["ostype"], "maccatalyst")
31
32        aout_info = None
33        dylib_info = lldbutil.packetlog_get_dylib_info(log)
34        for image in dylib_info["images"]:
35            if image["pathname"].endswith("a.out"):
36                aout_info = image
37        self.assertTrue(aout_info)
38        self.assertEqual(aout_info["min_version_os_name"], "maccatalyst")
39