Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
get tests building and running
Browse files Browse the repository at this point in the history
  • Loading branch information
awortman-fastly committed Sep 4, 2019
1 parent 3d26fc8 commit 2229af3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lucet-runtime/lucet-runtime-internals/src/alloc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ macro_rules! alloc_tests {
&mut parent,
heap_touching_child as usize,
&[Val::CPtr(heap_ptr)],
heap_ptr,
)
.expect("context init succeeds");
Context::swap(&mut parent, &child);
Expand Down Expand Up @@ -649,6 +650,7 @@ macro_rules! alloc_tests {
&mut parent,
stack_pattern_child as usize,
&[Val::CPtr(heap_ptr)],
heap_ptr,
)
.expect("context init succeeds");
Context::swap(&mut parent, &child);
Expand Down
3 changes: 3 additions & 0 deletions lucet-runtime/lucet-runtime-internals/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ impl Context {
/// &mut child,
/// entrypoint as usize,
/// &[Val::U64(120), Val::F32(3.14)],
/// std::ptr::null_mut(),
/// );
/// assert!(res.is_ok());
/// ```
Expand All @@ -281,6 +282,7 @@ impl Context {
/// &mut child,
/// entrypoint as usize,
/// &[Val::U64(120), Val::F32(3.14)],
/// std::ptr::null_mut(),
/// );
/// assert!(res.is_ok());
/// ```
Expand Down Expand Up @@ -446,6 +448,7 @@ impl Context {
/// &mut child,
/// entrypoint as usize,
/// &[],
/// std::ptr::null_mut(),
/// ).unwrap();
///
/// unsafe { Context::swap(&mut parent, &child); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ macro_rules! init_and_swap {
parent_regs.as_mut().unwrap(),
$fn as usize,
&[$( $args ),*],
// this is the Context heap pointer, eventually put in r15.
// because it's not an argument by the ABI, either it's used (by guest code)
// or ignored and overwritten (by compiler-generated code)
std::ptr::null_mut(),
).unwrap()));

child_regs = child;
Expand Down
15 changes: 10 additions & 5 deletions lucet-runtime/lucet-runtime-internals/src/context/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::slice;
#[test]
fn context_offsets_correct() {
assert_eq!(offset_of!(Context, gpr), 0);
assert_eq!(offset_of!(Context, fpr), 8 * 8);
assert_eq!(offset_of!(Context, retvals_gp), 8 * 8 + 8 * 16);
assert_eq!(offset_of!(Context, retval_fp), 8 * 8 + 8 * 16 + 8 * 2);
assert_eq!(offset_of!(Context, fpr), 10 * 8);
assert_eq!(offset_of!(Context, retvals_gp), 10 * 8 + 8 * 16);
assert_eq!(offset_of!(Context, retval_fp), 10 * 8 + 8 * 16 + 8 * 2);
}

#[test]
Expand All @@ -32,8 +32,13 @@ fn init_rejects_unaligned() {

// now we have the unaligned stack, let's make sure it blows up right
let mut parent = ContextHandle::new();
let res =
ContextHandle::create_and_init(&mut stack_unaligned, &mut parent, dummy as usize, &[]);
let res = ContextHandle::create_and_init(
&mut stack_unaligned,
&mut parent,
dummy as usize,
&[],
std::ptr::null_mut(),
);

if let Err(Error::UnalignedStack) = res {
assert!(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ macro_rules! init_and_swap {
PARENT.as_mut().unwrap(),
$fn as usize,
&[$( $args ),*],
// this is the Context heap pointer, eventually put in r15.
// because it's not an argument by the ABI, either it's used (by guest code)
// or ignored and overwritten (by compiler-generated code)
std::ptr::null_mut(),
).unwrap();
CHILD = Some(child);

Expand Down

0 comments on commit 2229af3

Please sign in to comment.