|
1 |
| -/* |
2 |
| -Copyright 2024 The Hyperlight Authors. |
3 |
| -
|
4 |
| -Licensed under the Apache License, Version 2.0 (the "License"); |
5 |
| -you may not use this file except in compliance with the License. |
6 |
| -You may obtain a copy of the License at |
7 |
| -
|
8 |
| - http://www.apache.org/licenses/LICENSE-2.0 |
9 |
| -
|
10 |
| -Unless required by applicable law or agreed to in writing, software |
11 |
| -distributed under the License is distributed on an "AS IS" BASIS, |
12 |
| -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 |
| -See the License for the specific language governing permissions and |
14 |
| -limitations under the License. |
15 |
| -*/ |
16 |
| - |
17 |
| -use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType}; |
18 |
| -use hyperlight_host::func::call_ctx::MultiUseGuestCallContext; |
19 |
| -use hyperlight_host::sandbox::{MultiUseSandbox, UninitializedSandbox}; |
20 |
| -use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; |
21 |
| -use hyperlight_host::sandbox_state::transition::Noop; |
22 |
| -use hyperlight_host::{new_error, GuestBinary, Result}; |
23 |
| -use hyperlight_testing::simple_guest_as_string; |
24 |
| - |
| 1 | +// TODO(danbugs:297): bring back |
| 2 | +// /* |
| 3 | +// Copyright 2024 The Hyperlight Authors. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +// you may not use this file except in compliance with the License. |
| 7 | +// You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, software |
| 12 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +// See the License for the specific language governing permissions and |
| 15 | +// limitations under the License. |
| 16 | +// */ |
| 17 | +// |
| 18 | +// use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType}; |
| 19 | +// use hyperlight_host::func::call_ctx::MultiUseGuestCallContext; |
| 20 | +// use hyperlight_host::sandbox::{MultiUseSandbox, UninitializedSandbox}; |
| 21 | +// use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox; |
| 22 | +// use hyperlight_host::sandbox_state::transition::Noop; |
| 23 | +// use hyperlight_host::{new_error, GuestBinary, Result}; |
| 24 | +// use hyperlight_testing::simple_guest_as_string; |
| 25 | +// |
25 | 26 | fn main() {
|
26 |
| - // create a new `MultiUseSandbox` configured to run the `simpleguest.exe` |
27 |
| - // test guest binary |
28 |
| - let sbox1: MultiUseSandbox = { |
29 |
| - let path = simple_guest_as_string().unwrap(); |
30 |
| - let u_sbox = |
31 |
| - UninitializedSandbox::new(GuestBinary::FilePath(path), None, None, None).unwrap(); |
32 |
| - u_sbox.evolve(Noop::default()) |
33 |
| - } |
34 |
| - .unwrap(); |
35 |
| - |
36 |
| - // create a new call context from the sandbox, then do some calls with it. |
37 |
| - let ctx1 = sbox1.new_call_context(); |
38 |
| - let sbox2 = do_calls(ctx1).unwrap(); |
39 |
| - // create a new call context from the returned sandbox, then do some calls |
40 |
| - // with that one |
41 |
| - let ctx2 = sbox2.new_call_context(); |
42 |
| - do_calls(ctx2).unwrap(); |
43 |
| -} |
44 |
| - |
45 |
| -/// Given a `MultiUseGuestCallContext` derived from an existing |
46 |
| -/// `MultiUseSandbox` configured to run the `simpleguest.exe` test guest |
47 |
| -/// binary, do several calls against that binary, print their results, then |
48 |
| -/// call `ctx.finish()` and return the resulting `MultiUseSandbox`. Return an `Err` |
49 |
| -/// if anything failed. |
50 |
| -fn do_calls(mut ctx: MultiUseGuestCallContext) -> Result<MultiUseSandbox> { |
51 |
| - { |
52 |
| - let res1: String = { |
53 |
| - let rv = ctx.call( |
54 |
| - "Echo", |
55 |
| - ReturnType::Int, |
56 |
| - Some(vec![ParameterValue::String("hello".to_string())]), |
57 |
| - )?; |
58 |
| - rv.try_into() |
59 |
| - } |
60 |
| - .map_err(|e| new_error!("failed to get Echo result: {}", e))?; |
61 |
| - println!("got Echo res: {res1}"); |
62 |
| - } |
63 |
| - { |
64 |
| - let res2: i32 = { |
65 |
| - let rv = ctx.call( |
66 |
| - "CallMalloc", |
67 |
| - ReturnType::Int, |
68 |
| - Some(vec![ParameterValue::Int(200)]), |
69 |
| - )?; |
70 |
| - rv.try_into() |
71 |
| - } |
72 |
| - .map_err(|e| new_error!("failed to get CallMalloc result: {}", e))?; |
73 |
| - println!("got CallMalloc res: {res2}"); |
74 |
| - } |
75 |
| - ctx.finish() |
| 27 | + // // create a new `MultiUseSandbox` configured to run the `simpleguest.exe` |
| 28 | + // // test guest binary |
| 29 | + // let sbox1: MultiUseSandbox = { |
| 30 | + // let path = simple_guest_as_string().unwrap(); |
| 31 | + // let u_sbox = |
| 32 | + // UninitializedSandbox::new(GuestBinary::FilePath(path), None, None, None).unwrap(); |
| 33 | + // u_sbox.evolve(Noop::default()) |
| 34 | + // } |
| 35 | + // .unwrap(); |
| 36 | + // |
| 37 | + // // create a new call context from the sandbox, then do some calls with it. |
| 38 | + // let ctx1 = sbox1.new_call_context(); |
| 39 | + // let sbox2 = do_calls(ctx1).unwrap(); |
| 40 | + // // create a new call context from the returned sandbox, then do some calls |
| 41 | + // // with that one |
| 42 | + // let ctx2 = sbox2.new_call_context(); |
| 43 | + // do_calls(ctx2).unwrap(); |
76 | 44 | }
|
| 45 | +// |
| 46 | +// /// Given a `MultiUseGuestCallContext` derived from an existing |
| 47 | +// /// `MultiUseSandbox` configured to run the `simpleguest.exe` test guest |
| 48 | +// /// binary, do several calls against that binary, print their results, then |
| 49 | +// /// call `ctx.finish()` and return the resulting `MultiUseSandbox`. Return an `Err` |
| 50 | +// /// if anything failed. |
| 51 | +// fn do_calls(mut ctx: MultiUseGuestCallContext) -> Result<MultiUseSandbox> { |
| 52 | +// { |
| 53 | +// let res1: String = { |
| 54 | +// let rv = ctx.call( |
| 55 | +// "Echo", |
| 56 | +// ReturnType::Int, |
| 57 | +// Some(vec![ParameterValue::String("hello".to_string())]), |
| 58 | +// )?; |
| 59 | +// rv.try_into() |
| 60 | +// } |
| 61 | +// .map_err(|e| new_error!("failed to get Echo result: {}", e))?; |
| 62 | +// println!("got Echo res: {res1}"); |
| 63 | +// } |
| 64 | +// { |
| 65 | +// let res2: i32 = { |
| 66 | +// let rv = ctx.call( |
| 67 | +// "CallMalloc", |
| 68 | +// ReturnType::Int, |
| 69 | +// Some(vec![ParameterValue::Int(200)]), |
| 70 | +// )?; |
| 71 | +// rv.try_into() |
| 72 | +// } |
| 73 | +// .map_err(|e| new_error!("failed to get CallMalloc result: {}", e))?; |
| 74 | +// println!("got CallMalloc res: {res2}"); |
| 75 | +// } |
| 76 | +// ctx.finish() |
| 77 | +// } |
0 commit comments