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