1000847f8SAdrian Prantlimport lldb 2000847f8SAdrian Prantlfrom lldbsuite.test.lldbtest import * 3000847f8SAdrian Prantlfrom lldbsuite.test.decorators import * 4*33c0f93fSPavel Labathfrom lldbsuite.test.gdbclientutils import * 5*33c0f93fSPavel Labathfrom lldbsuite.test.lldbgdbclient import GDBRemoteTestBase 6000847f8SAdrian Prantl 7000847f8SAdrian Prantlclass TestIOSSimulator(GDBRemoteTestBase): 8*33c0f93fSPavel Labath 9000847f8SAdrian Prantl """ 10000847f8SAdrian Prantl Test that an ios simulator process is recognized as such. 11000847f8SAdrian Prantl """ 12000847f8SAdrian Prantl 13000847f8SAdrian Prantl class MyResponder(MockGDBServerResponder): 14000847f8SAdrian Prantl def __init__(self, host, process): 15000847f8SAdrian Prantl self.host_ostype = host 16000847f8SAdrian Prantl self.process_ostype = process 17000847f8SAdrian Prantl MockGDBServerResponder.__init__(self) 18000847f8SAdrian Prantl 19000847f8SAdrian Prantl def respond(self, packet): 20000847f8SAdrian Prantl if packet == "qProcessInfo": 21000847f8SAdrian Prantl return self.qProcessInfo() 22000847f8SAdrian Prantl return MockGDBServerResponder.respond(self, packet) 23000847f8SAdrian Prantl 24000847f8SAdrian Prantl def qHostInfo(self): 25000847f8SAdrian Prantl 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 26000847f8SAdrian Prantl def qProcessInfo(self): 27000847f8SAdrian Prantl 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 28000847f8SAdrian Prantl def vCont(self): 29000847f8SAdrian Prantl return "vCont;" 30000847f8SAdrian Prantl 31000847f8SAdrian Prantl def platform_test(self, host, process, expected_triple): 32000847f8SAdrian Prantl self.server.responder = self.MyResponder(host, process) 33000847f8SAdrian Prantl if self.TraceOn(): 34000847f8SAdrian Prantl self.runCmd("log enable gdb-remote packets") 35000847f8SAdrian Prantl self.addTearDownHook(lambda: self.runCmd("log disable gdb-remote packets")) 36000847f8SAdrian Prantl 37000847f8SAdrian Prantl target = self.dbg.CreateTargetWithFileAndArch(None, None) 38000847f8SAdrian Prantl process = self.connect(target) 39000847f8SAdrian Prantl triple = target.GetTriple() 40000847f8SAdrian Prantl self.assertEqual(triple, expected_triple) 41000847f8SAdrian Prantl 42000847f8SAdrian Prantl @skipIfRemote 43000847f8SAdrian Prantl def test_macos(self): 44000847f8SAdrian Prantl self.platform_test(host="macosx", process="macosx", 45000847f8SAdrian Prantl expected_triple="x86_64h-apple-macosx-") 46000847f8SAdrian Prantl 47000847f8SAdrian Prantl @skipIfRemote 48000847f8SAdrian Prantl def test_ios_sim(self): 49000847f8SAdrian Prantl self.platform_test(host="macosx", process="iossimulator", 50000847f8SAdrian Prantl expected_triple="x86_64h-apple-ios-simulator") 51000847f8SAdrian Prantl 52000847f8SAdrian Prantl @skipIfRemote 53000847f8SAdrian Prantl def test_catalyst(self): 54000847f8SAdrian Prantl self.platform_test(host="macosx", process="maccatalyst", 55000847f8SAdrian Prantl expected_triple="x86_64h-apple-ios-macabi") 56000847f8SAdrian Prantl 57000847f8SAdrian Prantl @skipIfRemote 58000847f8SAdrian Prantl def test_tvos_sim(self): 59000847f8SAdrian Prantl self.platform_test(host="macosx", process="tvossimulator", 60000847f8SAdrian Prantl expected_triple="x86_64h-apple-tvos-simulator") 61000847f8SAdrian Prantl 62000847f8SAdrian Prantl @skipIfRemote 63000847f8SAdrian Prantl def test_tvos_sim(self): 64000847f8SAdrian Prantl self.platform_test(host="macosx", process="watchossimulator", 65000847f8SAdrian Prantl expected_triple="x86_64h-apple-watchos-simulator") 66