1import lldb
2from lldbsuite.test.lldbtest import *
3from lldbsuite.test.decorators import *
4import lldbsuite.test.lldbutil as lldbutil
5import os
6
7
8class TestMacCatalystAppWithMacOSFramework(TestBase):
9    @skipIf(macos_version=["<", "10.15"])
10    @skipUnlessDarwin
11    @skipIfDarwinEmbedded
12    # There is a Clang driver change missing on llvm.org.
13    @expectedFailureAll(bugnumber="rdar://problem/54986190>")
14    def test(self):
15        """Test the x86_64-apple-ios-macabi target linked against a macos dylib"""
16        self.build()
17        log = self.getBuildArtifact("packets.log")
18        self.expect("log enable gdb-remote packets -f " + log)
19        lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.c"))
20        arch = self.getArchitecture()
21        self.expect(
22            "image list -t -b",
23            patterns=[
24                arch + r".*-apple-ios.*-macabi a\.out",
25                arch + r".*-apple-macosx.* libfoo.dylib[^(]",
26            ],
27        )
28        self.expect("fr v s", "Hello macCatalyst")
29        self.expect("expression s", "Hello macCatalyst")
30        self.check_debugserver(log)
31
32    def check_debugserver(self, log):
33        """scan the debugserver packet log"""
34        process_info = lldbutil.packetlog_get_process_info(log)
35        self.assertIn("ostype", process_info)
36        self.assertEqual(process_info["ostype"], "maccatalyst")
37
38        aout_info = None
39        libfoo_info = None
40        dylib_info = lldbutil.packetlog_get_dylib_info(log)
41        for image in dylib_info["images"]:
42            if image["pathname"].endswith("a.out"):
43                aout_info = image
44            if image["pathname"].endswith("libfoo.dylib"):
45                libfoo_info = image
46        self.assertTrue(aout_info)
47        self.assertTrue(libfoo_info)
48        self.assertEqual(aout_info["min_version_os_name"], "maccatalyst")
49        self.assertEqual(libfoo_info["min_version_os_name"], "macosx")
50