Sync source edition with VCC Plus 3.7.0 build 63
This commit is contained in:
1 parent
c652a5276d
commit
b2ecec4d87
86 files changed
+10519
-472
No files matched your search
@@ -2,6 +2,64 @@
|
||||
import XCTest
|
||||
|
||||
final class DebuggerMMUBridgeTests: XCTestCase {
|
||||
@MainActor func testOverlayBridgeQualifiesOwnerAndRequiresFreshResidencyForSourceStep() async {
|
||||
for enhanced in [false, true] {
|
||||
let controller = VCCMachineController()
|
||||
_ = await command { controller.setAudioEnabled(false, volume: 0, completion: $0) }
|
||||
_ = await command { controller.configureMachine(use6309: enhanced, ram: 1, overclock: 1, frameInterval: 1, fastForward: false, completion: $0) }
|
||||
_ = await command { controller.loadDiagnostic(use6309: enhanced, completion: $0) }
|
||||
// Initial authored code setup. Guest-driven replacement itself is
|
||||
// covered by the core and disposable-worker loader fixtures.
|
||||
let a = Data([0x12, 0x86, 0x11, 0x39]), b = Data([0x12, 0x86, 0x22, 0x39])
|
||||
_ = await command { controller.debuggerWriteMemory(address: 0x4000, data: a, completion: $0) }
|
||||
_ = await command { controller.debuggerSetPC(0x4000, completion: $0) }
|
||||
_ = await command { controller.debuggerSetBreakpoints([0x4567], completion: $0) }
|
||||
let initial = await capture(controller, includePhysical: false)
|
||||
let physical = Int(initial.mmu.effective[2].sourceAddress / 8192)
|
||||
let modules: [[String: Any]] = [("a", a), ("b", b)].map { name, bytes in
|
||||
["id": name, "pages": [["logicalPage": 2, "physicalPage": physical]],
|
||||
"addresses": [0x4000], "bytes": [bytes], "breakpoints": [],
|
||||
"overlay_group": "stage", "overlay_owner": name]
|
||||
}
|
||||
let armed = await command { controller.debuggerArmBankedDevelopmentBreakpoints([], modules: modules, completion: $0) }
|
||||
XCTAssertNil(armed.errorMessage); XCTAssertTrue(armed.debuggerDevelopmentAttached)
|
||||
XCTAssertNotEqual(armed.debuggerResidencyFingerprint, 0)
|
||||
var malformed = modules
|
||||
malformed[0].removeValue(forKey: "overlay_owner")
|
||||
let invalid = await command { controller.debuggerArmBankedDevelopmentBreakpoints([], modules: malformed, completion: $0) }
|
||||
XCTAssertNotNil(invalid.errorMessage)
|
||||
XCTAssertEqual(invalid.debuggerResidencyFingerprint, armed.debuggerResidencyFingerprint)
|
||||
for key in ["overlay_group", "overlay_owner"] {
|
||||
var definitions = modules; definitions[0][key] = "a\0truncated"
|
||||
let rejectedDefinitions = definitions
|
||||
let rejected = await command { controller.debuggerArmBankedDevelopmentBreakpoints([], modules: rejectedDefinitions, completion: $0) }
|
||||
XCTAssertNotNil(rejected.errorMessage)
|
||||
XCTAssertEqual(rejected.debuggerResidencyFingerprint, armed.debuggerResidencyFingerprint)
|
||||
}
|
||||
func step(_ fingerprint: UInt64) async -> VCCMachineSnapshot {
|
||||
await command {
|
||||
controller.debuggerStepBankedSource(mode: 0, addresses: [0x4000,0x4001,0x4000,0x4001], locations: [1,2,3,4],
|
||||
bytes: [Data([0x12]),Data([0x86,0x11]),Data([0x12]),Data([0x86,0x22])],
|
||||
moduleIdentifiers: ["a","a","b","b"], generation: armed.generation,
|
||||
programRevision: armed.debuggerProgramRevision, mappingFingerprint: armed.debuggerMappingFingerprint,
|
||||
residencyFingerprint: fingerprint, programCounter: 0x4000, completion: $0)
|
||||
}
|
||||
}
|
||||
let stale = await step(armed.debuggerResidencyFingerprint &+ 1)
|
||||
XCTAssertNotNil(stale.errorMessage); XCTAssertEqual(stale.cycles, armed.cycles)
|
||||
let started = await step(armed.debuggerResidencyFingerprint)
|
||||
XCTAssertNil(started.errorMessage)
|
||||
var stopped = started
|
||||
for _ in 0..<100 where stopped.state == .running {
|
||||
try? await Task.sleep(for: .milliseconds(5)); stopped = await command(controller.snapshot)
|
||||
}
|
||||
XCTAssertEqual(stopped.state, .paused); XCTAssertEqual(stopped.programCounter, 0x4001)
|
||||
XCTAssertEqual(stopped.debuggerResidencyFingerprint, armed.debuggerResidencyFingerprint)
|
||||
let final = await capture(controller, includePhysical: false)
|
||||
XCTAssertEqual(final.breakpoints.map(\.uint16Value), [0x4567])
|
||||
_ = await command(controller.shutdown)
|
||||
}
|
||||
}
|
||||
@MainActor func testBankedGuardBridgeFreezesModulesAndPreservesManualPoints() async {
|
||||
let controller = VCCMachineController()
|
||||
_ = await command { controller.setAudioEnabled(false, volume: 0, completion: $0) }
|
||||
@@ -41,7 +99,8 @@ final class DebuggerMMUBridgeTests: XCTestCase {
|
||||
controller.debuggerStepBankedSource(mode: 0, addresses: [0x4000,0x4001], locations: [1,2],
|
||||
bytes: [Data([0x12]),Data([0x20,0xfe])], moduleIdentifiers: ["resident","resident"],
|
||||
generation: armed.generation, programRevision: armed.debuggerProgramRevision,
|
||||
mappingFingerprint: armed.debuggerMappingFingerprint &+ 1, programCounter: 0x4000, completion: $0)
|
||||
mappingFingerprint: armed.debuggerMappingFingerprint &+ 1,
|
||||
residencyFingerprint: armed.debuggerResidencyFingerprint, programCounter: 0x4000, completion: $0)
|
||||
}
|
||||
XCTAssertNotNil(stale.errorMessage); XCTAssertEqual(stale.state, .paused)
|
||||
let cleared = await command(controller.debuggerClearDevelopmentBreakpoints)
|
||||
|
||||
Reference in new issue
Block a user