Run a virtual iPhone on an Apple Silicon Mac.
Swift
Test where the guest's components come from without vphone600ap
Maximilian Paßdb120cd45aa1
diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Manifest/FirmwareManifest.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Manifest/FirmwareManifest.swiftindex 9ce1adf3..33abc9a1 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Manifest/FirmwareManifest.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/Manifest/FirmwareManifest.swift@@ -76,16 +76,12 @@ public enum FirmwareManifest {// per board it covers, so the userland one is picked by board.let device = chosen ?? VPhoneGuestDevice.detect(buildManifest: iPhoneBM) ?? .defaultlet (prod, res) = try findCloudOS(cloudIdentities, deviceClass: "vresearch101ap")- // Only the 26.1–26.4 beta cloudOS releases carry vphone600ap. Every other- // one boots the research board's own device tree and SEP, which- // `fw patch` converts (FirmwareResearchBoardPatchSet).- let vphone = try? findCloudOS(cloudIdentities, deviceClass: "vphone600ap")- let (vp, vpr) = vphone ?? (prod, res)+ let (vp, vpr) = findRuntime(cloudIdentities, researchBoard: (prod, res))let iErase = try findIPhoneErase(iPhoneIdentities, deviceClass: device.deviceClass)if verbose {print(" cloudOS vresearch101ap: release=#\(prod), research=#\(res)")- if vphone == nil {+ if (vp, vpr) == (prod, res) {print(" cloudOS vphone600ap: none, the research board stands in")} else {print(" cloudOS vphone600ap: release=#\(vp), research=#\(vpr)")@@ -188,6 +184,17 @@ public enum FirmwareManifest {return (rel, res)}+ /// The identities the guest's device tree, SEP and kernel come from:+ /// vphone600ap's, which only the 26.1–26.4 beta cloudOS releases carry, or+ /// else the research board's, which `fw patch` converts+ /// (FirmwareResearchBoardPatchSet).+ static func findRuntime(+ _ identities: [PlistDict],+ researchBoard: (release: Int, research: Int),+ ) -> (release: Int, research: Int) {+ (try? findCloudOS(identities, deviceClass: "vphone600ap")) ?? researchBoard+ }+/// Return the index of the first iPhone erase identity.////// With `deviceClass`, an erase identity for that board wins; the firstdiff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/FirmwareManifestSelectionTests.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/FirmwareManifestSelectionTests.swiftindex 4bf0dd87..26df18f4 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/FirmwareManifestSelectionTests.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcherTests/Core/FirmwareManifestSelectionTests.swift@@ -173,6 +173,78 @@ struct FirmwareManifestSelectionTests {}}+ // MARK: - findRuntime++ @Test+ func `the guest takes vphone600ap's identities where the cloudOS has them`() {+ let identities = [+ Self.identity(deviceClass: "vresearch101ap"),+ Self.identity(deviceClass: "vresearch101ap", variant: "Research Erase Install"),+ Self.identity(deviceClass: "vphone600ap"),+ Self.identity(deviceClass: "vphone600ap", variant: "Research Erase Install"),+ ]+ let (release, research) = FirmwareManifest.findRuntime(identities, researchBoard: (0, 1))+ #expect(release == 2)+ #expect(research == 3)+ }++ @Test+ func `without vphone600ap the research board stands in`() {+ let identities = [+ Self.identity(deviceClass: "vresearch101ap"),+ Self.identity(deviceClass: "vresearch101ap", variant: "Research Erase Install"),+ ]+ let (release, research) = FirmwareManifest.findRuntime(identities, researchBoard: (0, 1))+ #expect(release == 0)+ #expect(research == 1)+ }++ /// An identity naming each of `components` at `<component>.<device class>`.+ static func identity(deviceClass: String, variant: String, components: [String]) -> PlistDict {+ var identity = identity(deviceClass: deviceClass, variant: variant)+ var manifest = PlistDict()+ for component in components {+ manifest[component] = ["Info": ["Path": "\(component).\(deviceClass)"] as PlistDict] as PlistDict+ }+ identity["Manifest"] = manifest+ return identity+ }++ @Test+ func `the research board supplies the guest's components and may lack a RecoveryMode`() throws {+ let cloud = [+ "LLB", "iBSS", "iBEC", "iBoot", "Ap,RestoreSecurePageTableMonitor", "Ap,RestoreTrustedExecutionMonitor",+ "Ap,SecurePageTableMonitor", "Ap,TrustedExecutionMonitor", "DeviceTree", "RestoreDeviceTree", "SEP",+ "RestoreSEP", "KernelCache", "RestoreKernelCache", "RestoreRamDisk", "RestoreTrustCache",+ ]+ let cloudIdentities = [+ Self.identity(deviceClass: "vresearch101ap", variant: "Darwin Cloud Customer Erase Install (IPSW)", components: cloud),+ Self.identity(deviceClass: "vresearch101ap", variant: "Research Darwin Cloud Customer Erase Install (IPSW)", components: cloud),+ ]+ let iPhoneIdentities = [+ Self.identity(deviceClass: "d47ap", variant: "Customer Erase Install (IPSW)", components: [+ "Ap,SystemVolumeCanonicalMetadata", "OS", "StaticTrustCache", "SystemVolume",+ ]),+ ]+ let (vp, vpr) = FirmwareManifest.findRuntime(cloudIdentities, researchBoard: (0, 1))+ let identity = try FirmwareManifest.buildEraseIdentity(+ cloudIdentities: cloudIdentities,+ iPhoneIdentities: iPhoneIdentities,+ prod: 0,+ res: 1,+ vp: vp,+ vpr: vpr,+ iErase: 0,+ )+ let manifest = try #require(identity["Manifest"] as? PlistDict)+ func path(_ component: String) -> String? {+ ((manifest[component] as? PlistDict)?["Info"] as? PlistDict)?["Path"] as? String+ }+ #expect(path("RestoreDeviceTree") == "RestoreDeviceTree.vresearch101ap")+ #expect(path("SEP") == "SEP.vresearch101ap")+ #expect(manifest["RecoveryMode"] == nil)+ }+// MARK: - findIPhoneErase@Test