• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import lldb
2from lldbsuite.test.lldbtest import *
3from lldbsuite.test.decorators import *
4from gdbclientutils import *
5
6@skipIfReproducer
7class TestIOSSimulator(GDBRemoteTestBase):
8    """
9    Test that an ios simulator process is recognized as such.
10    """
11
12    class MyResponder(MockGDBServerResponder):
13        def __init__(self, host, process):
14            self.host_ostype = host
15            self.process_ostype = process
16            MockGDBServerResponder.__init__(self)
17
18        def respond(self, packet):
19            if packet == "qProcessInfo":
20                return self.qProcessInfo()
21            return MockGDBServerResponder.respond(self, packet)
22
23        def qHostInfo(self):
24            return "cputype:16777223;cpusubtype:8;ostype:%s;vendor:apple;os_version:10.15.4;maccatalyst_version:13.4;endian:little;ptrsize:8;"%self.host_ostype
25        def qProcessInfo(self):
26            return "pid:a860;parent-pid:d2a0;real-uid:1f5;real-gid:14;effective-uid:1f5;effective-gid:14;cputype:1000007;cpusubtype:8;ptrsize:8;ostype:%s;vendor:apple;endian:little;"%self.process_ostype
27        def vCont(self):
28            return "vCont;"
29
30    def platform_test(self, host, process, expected_triple):
31        self.server.responder = self.MyResponder(host, process)
32        if self.TraceOn():
33            self.runCmd("log enable gdb-remote packets")
34            self.addTearDownHook(lambda: self.runCmd("log disable gdb-remote packets"))
35
36        target = self.dbg.CreateTargetWithFileAndArch(None, None)
37        process = self.connect(target)
38        triple = target.GetTriple()
39        self.assertEqual(triple, expected_triple)
40
41    @skipIfRemote
42    def test_macos(self):
43        self.platform_test(host="macosx", process="macosx",
44                           expected_triple="x86_64h-apple-macosx-")
45
46    @skipIfRemote
47    def test_ios_sim(self):
48        self.platform_test(host="macosx", process="iossimulator",
49                           expected_triple="x86_64h-apple-ios-simulator")
50
51    @skipIfRemote
52    def test_catalyst(self):
53        self.platform_test(host="macosx", process="maccatalyst",
54                           expected_triple="x86_64h-apple-ios-macabi")
55
56    @skipIfRemote
57    def test_tvos_sim(self):
58        self.platform_test(host="macosx", process="tvossimulator",
59                           expected_triple="x86_64h-apple-tvos-simulator")
60
61    @skipIfRemote
62    def test_tvos_sim(self):
63        self.platform_test(host="macosx", process="watchossimulator",
64                           expected_triple="x86_64h-apple-watchos-simulator")
65