1000847f8SAdrian Prantlimport lldb 2000847f8SAdrian Prantlfrom lldbsuite.test.lldbtest import * 3000847f8SAdrian Prantlfrom lldbsuite.test.decorators import * 433c0f93fSPavel Labathfrom lldbsuite.test.gdbclientutils import * 533c0f93fSPavel Labathfrom lldbsuite.test.lldbgdbclient import GDBRemoteTestBase 6000847f8SAdrian Prantl 72238dcc3SJonas Devlieghere 8000847f8SAdrian Prantlclass TestIOSSimulator(GDBRemoteTestBase): 933c0f93fSPavel Labath 10000847f8SAdrian Prantl """ 11000847f8SAdrian Prantl Test that an ios simulator process is recognized as such. 12000847f8SAdrian Prantl """ 13000847f8SAdrian Prantl 14000847f8SAdrian Prantl class MyResponder(MockGDBServerResponder): 15000847f8SAdrian Prantl def __init__(self, host, process): 16000847f8SAdrian Prantl self.host_ostype = host 17000847f8SAdrian Prantl self.process_ostype = process 18000847f8SAdrian Prantl MockGDBServerResponder.__init__(self) 19000847f8SAdrian Prantl 20000847f8SAdrian Prantl def respond(self, packet): 21000847f8SAdrian Prantl if packet == "qProcessInfo": 22000847f8SAdrian Prantl return self.qProcessInfo() 23000847f8SAdrian Prantl return MockGDBServerResponder.respond(self, packet) 24000847f8SAdrian Prantl 25000847f8SAdrian Prantl def qHostInfo(self): 262238dcc3SJonas Devlieghere return ( 272238dcc3SJonas Devlieghere "cputype:16777223;cpusubtype:8;ostype:%s;vendor:apple;os_version:10.15.4;maccatalyst_version:13.4;endian:little;ptrsize:8;" 282238dcc3SJonas Devlieghere % self.host_ostype 292238dcc3SJonas Devlieghere ) 302238dcc3SJonas Devlieghere 31000847f8SAdrian Prantl def qProcessInfo(self): 322238dcc3SJonas Devlieghere return ( 332238dcc3SJonas Devlieghere "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;" 342238dcc3SJonas Devlieghere % self.process_ostype 352238dcc3SJonas Devlieghere ) 362238dcc3SJonas Devlieghere 37000847f8SAdrian Prantl def vCont(self): 38000847f8SAdrian Prantl return "vCont;" 39000847f8SAdrian Prantl 40000847f8SAdrian Prantl def platform_test(self, host, process, expected_triple): 41000847f8SAdrian Prantl self.server.responder = self.MyResponder(host, process) 42000847f8SAdrian Prantl if self.TraceOn(): 43000847f8SAdrian Prantl self.runCmd("log enable gdb-remote packets") 44000847f8SAdrian Prantl self.addTearDownHook(lambda: self.runCmd("log disable gdb-remote packets")) 45000847f8SAdrian Prantl 46000847f8SAdrian Prantl target = self.dbg.CreateTargetWithFileAndArch(None, None) 47000847f8SAdrian Prantl process = self.connect(target) 48000847f8SAdrian Prantl triple = target.GetTriple() 49000847f8SAdrian Prantl self.assertEqual(triple, expected_triple) 50000847f8SAdrian Prantl 51000847f8SAdrian Prantl @skipIfRemote 52000847f8SAdrian Prantl def test_macos(self): 532238dcc3SJonas Devlieghere self.platform_test( 542238dcc3SJonas Devlieghere host="macosx", process="macosx", expected_triple="x86_64h-apple-macosx-" 552238dcc3SJonas Devlieghere ) 56000847f8SAdrian Prantl 57000847f8SAdrian Prantl @skipIfRemote 58000847f8SAdrian Prantl def test_ios_sim(self): 592238dcc3SJonas Devlieghere self.platform_test( 602238dcc3SJonas Devlieghere host="macosx", 612238dcc3SJonas Devlieghere process="iossimulator", 622238dcc3SJonas Devlieghere expected_triple="x86_64h-apple-ios-simulator", 632238dcc3SJonas Devlieghere ) 64000847f8SAdrian Prantl 65000847f8SAdrian Prantl @skipIfRemote 66000847f8SAdrian Prantl def test_catalyst(self): 672238dcc3SJonas Devlieghere self.platform_test( 682238dcc3SJonas Devlieghere host="macosx", 692238dcc3SJonas Devlieghere process="maccatalyst", 702238dcc3SJonas Devlieghere expected_triple="x86_64h-apple-ios-macabi", 712238dcc3SJonas Devlieghere ) 72000847f8SAdrian Prantl 73000847f8SAdrian Prantl @skipIfRemote 74000847f8SAdrian Prantl def test_tvos_sim(self): 752238dcc3SJonas Devlieghere self.platform_test( 762238dcc3SJonas Devlieghere host="macosx", 772238dcc3SJonas Devlieghere process="tvossimulator", 782238dcc3SJonas Devlieghere expected_triple="x86_64h-apple-tvos-simulator", 792238dcc3SJonas Devlieghere ) 80000847f8SAdrian Prantl 81000847f8SAdrian Prantl @skipIfRemote 82*a4c18137SMichael Buch def test_watchos_sim(self): 832238dcc3SJonas Devlieghere self.platform_test( 842238dcc3SJonas Devlieghere host="macosx", 852238dcc3SJonas Devlieghere process="watchossimulator", 862238dcc3SJonas Devlieghere expected_triple="x86_64h-apple-watchos-simulator", 872238dcc3SJonas Devlieghere ) 88