PR006: add status-trap-panic conformance regression tests
This commit is contained in:
@@ -2560,6 +2560,41 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_status_first_syscall_results_count_mismatch_panic() {
|
||||
// GfxSetSprite (0x1007) expects 1 result.
|
||||
let code = assemble(
|
||||
"PUSH_I32 0\nPUSH_I32 0\nPUSH_I32 0\nPUSH_I32 0\nPUSH_I32 0\nPUSH_I32 0\nPUSH_I32 0\nPUSH_I32 0\nPUSH_I32 0\nPUSH_I32 0\nSYSCALL 0x1007",
|
||||
)
|
||||
.expect("assemble");
|
||||
|
||||
struct BadNativeNoReturn;
|
||||
impl NativeInterface for BadNativeNoReturn {
|
||||
fn syscall(
|
||||
&mut self,
|
||||
_id: u32,
|
||||
_args: &[Value],
|
||||
_ret: &mut HostReturn,
|
||||
_ctx: &mut HostContext,
|
||||
) -> Result<(), VmFault> {
|
||||
// Wrong: status-first syscall must return one status slot.
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
let mut vm = new_test_vm(code, vec![]);
|
||||
vm.set_capabilities(prometeu_hal::syscalls::caps::GFX);
|
||||
let mut native = BadNativeNoReturn;
|
||||
let mut ctx = HostContext::new(None);
|
||||
|
||||
vm.prepare_call("0");
|
||||
let report = vm.run_budget(100, &mut native, &mut ctx).expect("run");
|
||||
match report.reason {
|
||||
LogicalFrameEndingReason::Panic(msg) => assert!(msg.contains("results mismatch")),
|
||||
other => panic!("Expected Panic, got {:?}", other),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_loader_hardening_invalid_magic() {
|
||||
let mut vm = VirtualMachine::default();
|
||||
|
||||
Reference in New Issue
Block a user