Skip to content

Commit 28ac106

Browse files
committed
Move max_memory_sandbox test to layout module
Move the test from integration tests into the layout module where it belongs, and rewrite it to test SandboxMemoryLayout::get_memory_size directly instead of going through UninitializedSandbox::new. Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 1e0f712 commit 28ac106

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

src/hyperlight_host/src/mem/layout.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,4 +662,13 @@ mod tests {
662662
get_expected_memory_size(&sbox_mem_layout)
663663
);
664664
}
665+
666+
#[test]
667+
fn test_max_memory_sandbox() {
668+
let mut cfg = SandboxConfiguration::default();
669+
cfg.set_input_data_size(0x40000000);
670+
let layout = SandboxMemoryLayout::new(cfg, 4096, 2048, 4096, 4096, None).unwrap();
671+
let result = layout.get_memory_size();
672+
assert!(matches!(result.unwrap_err(), MemoryRequestTooBig(..)));
673+
}
665674
}

src/hyperlight_host/tests/sandbox_host_tests.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -207,24 +207,6 @@ fn incorrect_parameter_num() {
207207
});
208208
}
209209

210-
#[test]
211-
fn max_memory_sandbox() {
212-
use hyperlight_host::{GuestBinary, UninitializedSandbox};
213-
use hyperlight_testing::simple_guest_as_string;
214-
215-
let mut cfg = hyperlight_host::sandbox::SandboxConfiguration::default();
216-
cfg.set_input_data_size(0x40000000);
217-
let a = UninitializedSandbox::new(
218-
GuestBinary::FilePath(simple_guest_as_string().unwrap()),
219-
Some(cfg),
220-
);
221-
222-
assert!(matches!(
223-
a.unwrap_err(),
224-
HyperlightError::MemoryRequestTooBig(..)
225-
));
226-
}
227-
228210
#[test]
229211
fn iostack_is_working() {
230212
with_all_sandboxes(|mut sandbox| {

0 commit comments

Comments
 (0)