Skip to content

Commit 1d7ff9a

Browse files
committed
Add error path to test
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 288e66a commit 1d7ff9a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/hyperlight_host/src/sandbox/initialized_multi_use.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ mod tests {
502502
use std::sync::{Arc, Barrier};
503503
use std::thread;
504504

505+
use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode;
505506
use hyperlight_testing::simple_guest_as_string;
506507

507508
#[cfg(target_os = "linux")]
@@ -523,10 +524,14 @@ mod tests {
523524
sandbox.register("HostAdd", |a: i32, b: i32| a + b).unwrap();
524525
let mut sandbox = sandbox.evolve().unwrap();
525526

526-
// will exhaust io if leaky
527+
// will exhaust io if leaky. Tests both success and error paths
527528
for _ in 0..1000 {
528529
let result = sandbox.call::<i32>("Add", (5i32, 10i32)).unwrap();
529530
assert_eq!(result, 15);
531+
let result = sandbox.call::<i32>("AddToStaticAndFail", ()).unwrap_err();
532+
assert!(
533+
matches!(result, HyperlightError::GuestError (code, msg ) if code == ErrorCode::GuestError && msg == "Crash on purpose")
534+
);
530535
}
531536
}
532537

0 commit comments

Comments
 (0)