@@ -14,39 +14,28 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- use hyperlight_host:: sandbox :: { MultiUseSandbox , UninitializedSandbox } ;
18
- use hyperlight_host:: { GuestBinary , Result } ;
17
+ use hyperlight_host:: GuestBinary ;
18
+ use hyperlight_host:: sandbox :: UninitializedSandbox ;
19
19
use hyperlight_testing:: simple_guest_as_string;
20
20
21
21
fn main ( ) {
22
22
// create a new `MultiUseSandbox` configured to run the `simpleguest.exe`
23
23
// test guest binary
24
- let mut sbox1: MultiUseSandbox = {
25
- let path = simple_guest_as_string ( ) . unwrap ( ) ;
26
- let u_sbox = UninitializedSandbox :: new ( GuestBinary :: FilePath ( path) , None ) . unwrap ( ) ;
27
- u_sbox. evolve ( )
28
- }
29
- . unwrap ( ) ;
30
-
31
- // create a new call context from the sandbox, then do some calls with it.
32
- do_calls ( & mut sbox1) . unwrap ( ) ;
33
-
34
- // create a new call context from the returned sandbox, then do some calls
35
- // with that one
36
- do_calls ( & mut sbox1) . unwrap ( ) ;
37
- }
38
-
39
- /// Given a `MultiUseGuestCallContext` derived from an existing
40
- /// `MultiUseSandbox` configured to run the `simpleguest.exe` test guest
41
- /// binary, do several calls against that binary, print their results, then
42
- /// call `ctx.finish()` and return the resulting `MultiUseSandbox`. Return an `Err`
43
- /// if anything failed.
44
- fn do_calls ( sbox : & mut MultiUseSandbox ) -> Result < ( ) > {
45
- let res: String = sbox. call_guest_function_by_name ( "Echo" , "hello" . to_string ( ) ) ?;
24
+ let path = simple_guest_as_string ( ) . unwrap ( ) ;
25
+ let mut sbox = UninitializedSandbox :: new ( GuestBinary :: FilePath ( path) , None )
26
+ . unwrap ( )
27
+ . evolve ( )
28
+ . unwrap ( ) ;
29
+
30
+ // Do several calls against a sandbox running the `simpleguest.exe` binary,
31
+ // and print their results
32
+ let res: String = sbox
33
+ . call_guest_function_by_name ( "Echo" , "hello" . to_string ( ) )
34
+ . unwrap ( ) ;
46
35
println ! ( "got Echo res: {res}" ) ;
47
36
48
- let res: i32 = sbox. call_guest_function_by_name ( "CallMalloc" , 200_i32 ) ?;
37
+ let res: i32 = sbox
38
+ . call_guest_function_by_name ( "CallMalloc" , 200_i32 )
39
+ . unwrap ( ) ;
49
40
println ! ( "got CallMalloc res: {res}" ) ;
50
-
51
- Ok ( ( ) )
52
41
}
0 commit comments