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 TestMacCatalyst(TestBase):
10
11    mydir = TestBase.compute_mydir(__file__)
12
13    @skipIf(macos_version=["<", "10.15"])
14    @skipUnlessDarwin
15    @skipIfDarwinEmbedded
16    @skipIfReproducer # This is hitting https://bugs.python.org/issue22393
17    def test_macabi(self):
18        """Test the x86_64-apple-ios-macabi target linked against a macos dylib"""
19        self.build()
20        log = self.getBuildArtifact('packets.log')
21        self.expect("log enable gdb-remote packets -f "+log)
22        lldbutil.run_to_source_breakpoint(self, "break here",
23                                          lldb.SBFileSpec('main.c'))
24        self.expect("image list -t -b",
25                    patterns=[self.getArchitecture() +
26                              r'.*-apple-ios.*-macabi a\.out'])
27        self.expect("fr v s", substrs=["Hello macCatalyst"])
28        self.expect("p s", substrs=["Hello macCatalyst"])
29        self.check_debugserver(log)
30
31    def check_debugserver(self, log):
32        """scan the debugserver packet log"""
33        process_info = lldbutil.packetlog_get_process_info(log)
34        self.assertIn('ostype', process_info)
35        self.assertEquals(process_info['ostype'], 'maccatalyst')
36
37        aout_info = None
38        dylib_info = lldbutil.packetlog_get_dylib_info(log)
39        for image in dylib_info['images']:
40            if image['pathname'].endswith('a.out'):
41                aout_info = image
42        self.assertTrue(aout_info)
43        self.assertEquals(aout_info['min_version_os_name'], 'maccatalyst')
44