File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
src/hyperlight_host/src/sandbox Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments