Skip to content

Commit 86f0bab

Browse files
committed
fixup! tmp
1 parent 079335b commit 86f0bab

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/hyperlight_host/src/sandbox/sandbox_builder.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,37 @@ mod tests {
971971
Ok(())
972972
}
973973

974+
#[test]
975+
#[cfg(inprocess)]
976+
fn test_sandbox_builder_with_exe_in_process() -> Result<()> {
977+
// Tests building an uninitialized sandbox w/ the sandbox builder
978+
let sandbox_builder =
979+
SandboxBuilder::new(GuestBinary::FilePath(simple_guest_exe_as_string()?))?
980+
.set_sandbox_run_options(SandboxRunOptions::RunInProcess(false))?;
981+
982+
let mut uninitialized_sandbox = sandbox_builder.build()?;
983+
984+
// Tests registering a host function
985+
fn add(a: i32, b: i32) -> Result<i32> {
986+
Ok(a + b)
987+
}
988+
let host_function = Arc::new(Mutex::new(add));
989+
host_function.register(&mut uninitialized_sandbox, "HostAdd")?;
990+
991+
// Tests evolving to a multi-use sandbox
992+
let mut multi_use_sandbox = uninitialized_sandbox.evolve(Noop::default())?;
993+
994+
let result = multi_use_sandbox.call_guest_function_by_name(
995+
"Add",
996+
ReturnType::Int,
997+
Some(vec![ParameterValue::Int(1), ParameterValue::Int(41)]),
998+
)?;
999+
1000+
assert_eq!(result, ReturnValue::Int(42));
1001+
1002+
Ok(())
1003+
}
1004+
9741005
#[test]
9751006
fn test_sandbox_builder_in_process() -> Result<()> {
9761007
// Tests building an uninitialized sandbox w/ the sandbox builder

0 commit comments

Comments
 (0)