Skip to content

Commit 5f34fb0

Browse files
committed
Update iprocess and local library tests to take account of inprocess feature flag
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
1 parent 953c6ab commit 5f34fb0

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

src/hyperlight_host/src/sandbox/uninitialized.rs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,28 @@ mod tests {
371371
);
372372

373373
// in process should only be enabled with the inprocess feature and on debug builds
374-
assert_eq!(sbox.is_ok(), cfg!(inprocess));
374+
assert_eq!(sbox.is_ok(), cfg!(all(inprocess, target_os = "windows")));
375+
376+
let sbox = UninitializedSandbox::new(
377+
GuestBinary::FilePath(simple_guest_path.clone()),
378+
None,
379+
Some(SandboxRunOptions::RunInProcess(true)),
380+
None,
381+
);
382+
383+
// debug mode should fail with an elf executable
384+
assert!(sbox.is_err());
385+
386+
let simple_guest_path = simple_guest_exe_as_string().unwrap();
387+
let sbox = UninitializedSandbox::new(
388+
GuestBinary::FilePath(simple_guest_path.clone()),
389+
None,
390+
Some(SandboxRunOptions::RunInProcess(false)),
391+
None,
392+
);
393+
394+
// in process should only be enabled with the inprocess feature and on debug builds
395+
assert_eq!(sbox.is_ok(), cfg!(all(inprocess, target_os = "windows")));
375396

376397
let sbox = UninitializedSandbox::new(
377398
GuestBinary::FilePath(simple_guest_path.clone()),
@@ -380,7 +401,7 @@ mod tests {
380401
None,
381402
);
382403

383-
// in process should only be enabled with the inprocess feature and on debug builds, and requires windows
404+
// debug mode should succeed with a PE executable on windows with inprocess enabled
384405
assert_eq!(sbox.is_ok(), cfg!(all(inprocess, target_os = "windows")));
385406
}
386407

@@ -608,7 +629,14 @@ mod tests {
608629
}
609630
#[cfg(target_os = "windows")]
610631
{
611-
let _ = mgr_res.unwrap();
632+
#[cfg(inprocess)]
633+
{
634+
assert!(mgr_res.is_ok())
635+
}
636+
#[cfg(not(inprocess))]
637+
{
638+
assert!(mgr_res.is_err())
639+
}
612640
}
613641
}
614642

@@ -1131,7 +1159,7 @@ mod tests {
11311159
None,
11321160
);
11331161
assert!(
1134-
matches!(sbox, Err(e) if e.to_string().contains("GuestBinary not found: 'some/path/that/does/not/exist': No such file or directory (os error 2)"))
1162+
matches!(sbox, Err(e) if e.to_string().contains("GuestBinary not found: 'some/path/that/does/not/exist': The system cannot find the path specified. (os error"))
11351163
);
11361164
}
11371165
}

0 commit comments

Comments
 (0)