feat(vm): add resource diagnostics and macOS stability qualification
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good

This commit is contained in:
2026-10-14 08:26:07 +01:00
parent 6c2a07e579
commit 3899b7f12c
21 changed files with 1502 additions and 33 deletions
@@ -523,6 +523,64 @@ mod tests {
use std::io::{Read, Write};
use std::net::TcpStream;
#[test]
fn desktop_worker_survives_repeated_home_resume_and_cold_reset() {
use prometeu_firmware::firmware::firmware_state::ResetStep;
use prometeu_hal::InputSignals;
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../../test-cartridges/dummy-boy");
let mut runner = HostRunner::new(None, None);
runner.set_boot_target(BootTarget::Cartridge {
path: path.to_string_lossy().into_owned(),
debug: false,
debug_port: 0,
});
let signals = InputSignals::default();
for cycle in 0..32 {
runner.firmware.change_state(
FirmwareState::Reset(ResetStep),
&signals,
&mut runner.hardware,
);
assert_eq!(runner.firmware.os.sessions().vm_session_count(), 0);
for _ in 0..6000 {
runner.firmware.tick(&signals, &mut runner.hardware);
if matches!(runner.firmware.state, FirmwareState::GameRunning(_)) {
break;
}
assert!(!matches!(runner.firmware.state, FirmwareState::AppCrashes(_)));
std::thread::sleep(Duration::from_millis(1));
}
assert!(matches!(runner.firmware.state, FirmwareState::GameRunning(_)), "boot {cycle}");
for _ in 0..8 {
runner.firmware.tick(&signals, &mut runner.hardware);
}
runner.firmware.request_home_from_host();
for _ in 0..32 {
runner.firmware.tick(&signals, &mut runner.hardware);
if matches!(runner.firmware.state, FirmwareState::HubHome(_)) {
break;
}
}
assert!(matches!(runner.firmware.state, FirmwareState::HubHome(_)), "home {cycle}");
assert!(runner.firmware.resume_resident_game_from_home());
for _ in 0..8 {
runner.firmware.tick(&signals, &mut runner.hardware);
}
assert!(
matches!(runner.firmware.state, FirmwareState::GameRunning(_)),
"resume {cycle}"
);
assert_eq!(runner.firmware.os.sessions().vm_session_count(), 1);
}
runner.firmware.change_state(
FirmwareState::Reset(ResetStep),
&signals,
&mut runner.hardware,
);
assert_eq!(runner.firmware.os.sessions().vm_session_count(), 0);
}
#[test]
fn presentation_state_requires_initial_redraw_only_once() {
let mut state = PresentationState::default();
@@ -0,0 +1,68 @@
"""Exercise the real Dummy Boy desktop window on localhost:17959.
Start the host with --debug test-cartridges/dummy-boy --port 17959 first.
This finite smoke observes progress; its timeout is not a realtime guarantee.
"""
import json
import socket
import time
def run():
with socket.create_connection(("127.0.0.1", 17959), timeout=10) as connection:
connection.settimeout(10)
with connection.makefile("rb") as incoming:
def send(kind):
connection.sendall((json.dumps({"type": kind}) + "\n").encode())
def state():
send("getState")
deadline = time.monotonic() + 10
while time.monotonic() < deadline:
line = incoming.readline()
assert line, "Desktop disconnected"
message = json.loads(line)
assert message.get("event") != "fault", message
if message.get("type") == "getState":
return message
raise TimeoutError("Desktop did not answer getState")
def await_progress(previous):
deadline = time.monotonic() + 5
current = state()
while current["frame_index"] == previous and time.monotonic() < deadline:
time.sleep(0.02)
current = state()
return current
handshake = json.loads(incoming.readline())
assert handshake["type"] == "handshake", handshake
assert handshake["cartridge"]["app_id"] == 2, handshake
print(json.dumps(handshake), flush=True)
send("start")
time.sleep(0.5)
first = state()
assert first["app_id"] == 2, first
for _ in range(32):
send("pause")
time.sleep(0.025)
paused = state()
time.sleep(0.025)
still = state()
assert (paused["pc"], paused["frame_index"]) == (still["pc"], still["frame_index"])
send("stepFrame")
stepped = await_progress(paused["frame_index"])
assert stepped["frame_index"] == paused["frame_index"] + 1, (paused, stepped)
send("resume")
resumed = await_progress(stepped["frame_index"])
assert resumed["frame_index"] > stepped["frame_index"], (stepped, resumed)
print(json.dumps({
"result": "pass", "cycles": 32,
"first_frame": first["frame_index"], "last_frame": resumed["frame_index"],
"last_pc": resumed["pc"],
}), flush=True)
send("resume")
if __name__ == "__main__":
run()