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    def test(self):
19        """Test the x86_64-apple-ios-macabi target linked against a macos dylib"""
20        self.build()
21        log = self.getBuildArtifact('packets.log')
22        self.expect("log enable gdb-remote packets -f "+log)
23        lldbutil.run_to_source_breakpoint(self, "break here",
24                                          lldb.SBFileSpec('main.c'))
25        arch = self.getArchitecture()
26        self.expect("image list -t -b",
27                    patterns=[arch + r'.*-apple-ios.*-macabi a\.out',
28                              arch + r'.*-apple-macosx.* libfoo.dylib[^(]'])
29        self.expect("fr v s", "Hello macCatalyst")
30        self.expect("p s", "Hello macCatalyst")
31        self.check_debugserver(log)
32
33    def check_debugserver(self, log):
34        """scan the debugserver packet log"""
35        process_info = lldbutil.packetlog_get_process_info(log)
36        self.assertIn('ostype', process_info)
37        self.assertEquals(process_info['ostype'], 'maccatalyst')
38
39        aout_info = None
40        libfoo_info = None
41        dylib_info = lldbutil.packetlog_get_dylib_info(log)
42        for image in dylib_info['images']:
43            if image['pathname'].endswith('a.out'):
44                aout_info = image
45            if image['pathname'].endswith('libfoo.dylib'):
46                libfoo_info = image
47        self.assertTrue(aout_info)
48        self.assertTrue(libfoo_info)
49        self.assertEquals(aout_info['min_version_os_name'], 'maccatalyst')
50        self.assertEquals(libfoo_info['min_version_os_name'], 'macosx')
51