feat(vm): add resource diagnostics and macOS stability qualification
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
This commit is contained in:
@@ -451,6 +451,10 @@ impl Default for HeadlessHost {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, feature = "resource-diagnostics"))]
|
||||
#[path = "resource_qualification_tests.rs"]
|
||||
mod resource_qualification_tests;
|
||||
|
||||
impl RenderSubmissionSink for HeadlessPlatform {
|
||||
fn submit_render_submission(
|
||||
&mut self,
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
#[allow(dead_code)]
|
||||
#[path = "../../../console/prometeu-vm/tests/support/callables.rs"]
|
||||
mod callables;
|
||||
use super::{AdvanceFrameOutcome, HeadlessHost};
|
||||
use prometeu_bytecode::{Value, registry::TypeId};
|
||||
|
||||
#[test]
|
||||
fn thousand_reset_reload_cycles_release_session_owners_and_preserve_controls() {
|
||||
let body =
|
||||
format!("{}FRAME_SYNC\nGET_CAPTURE 0\nRET", "MAKE_CLOSURE fn=2,type=4\nPOP\n".repeat(1030));
|
||||
let bytes = callables::bytes(
|
||||
&[
|
||||
(
|
||||
"PUSH_I32 73\nMAKE_CLOSURE fn=1,type=4\nCALL_CLOSURE 4\nRET",
|
||||
callables::sig(&[], &[0]),
|
||||
vec![],
|
||||
),
|
||||
(&body, callables::sig(&[], &[0]), vec![TypeId(0)]),
|
||||
("PUSH_I32 1\nRET", callables::sig(&[], &[0]), vec![]),
|
||||
],
|
||||
vec![],
|
||||
&[],
|
||||
)
|
||||
.unwrap();
|
||||
let path = std::env::temp_dir().join(format!("prometeu-resource-reset-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&path).unwrap();
|
||||
std::fs::write(path.join("program.pbx"), bytes).unwrap();
|
||||
std::fs::write(path.join("manifest.json"),r#"{"magic":"PMTU","cartridge_version":1,"app_id":77,"title":"Resource reset qualification","app_version":"1.0.0","app_mode":"Game","capabilities":[]}"#).unwrap();
|
||||
let mut host = HeadlessHost::new();
|
||||
for cycle in 0..1000 {
|
||||
host.boot(path.to_string_lossy()).unwrap();
|
||||
let observer = host
|
||||
.firmware
|
||||
.os
|
||||
.sessions()
|
||||
.resident_game_session_for_app(77)
|
||||
.unwrap()
|
||||
.vm
|
||||
.resource_observer();
|
||||
assert!(
|
||||
matches!(
|
||||
host.advance_frame().unwrap(),
|
||||
AdvanceFrameOutcome::FrameCompleted { logical_frame_index: 1, .. }
|
||||
),
|
||||
"cycle {cycle}"
|
||||
);
|
||||
{
|
||||
let sessions = host.firmware.os.sessions();
|
||||
let vm = &sessions.resident_game_session_for_app(77).unwrap().vm;
|
||||
assert_eq!(vm.heap().len(), 1);
|
||||
assert_eq!(vm.resource_snapshot().gc.collections, 1);
|
||||
}
|
||||
let pc = host.get_state().pc;
|
||||
host.pause().unwrap();
|
||||
host.tick_once();
|
||||
assert_eq!(host.get_state().pc, pc);
|
||||
host.resume().unwrap();
|
||||
assert!(matches!(
|
||||
host.advance_frame().unwrap(),
|
||||
AdvanceFrameOutcome::FrameCompleted { logical_frame_index: 2, .. }
|
||||
));
|
||||
assert_eq!(&*host.get_state().stack_top, &[Value::Int32(73)]);
|
||||
assert!(host.get_fault().is_none());
|
||||
host.reset();
|
||||
assert_eq!(host.firmware.os.sessions().vm_session_count(), 0);
|
||||
assert_eq!(
|
||||
observer.diagnostic_snapshot().used,
|
||||
[0; 8],
|
||||
"reset {cycle} retained session allocation"
|
||||
);
|
||||
}
|
||||
std::fs::remove_dir_all(path).unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user