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

Commit 2229af3

Browse files
get tests building and running
1 parent 3d26fc8 commit 2229af3

5 files changed

Lines changed: 23 additions & 5 deletions

File tree

lucet-runtime/lucet-runtime-internals/src/alloc/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ macro_rules! alloc_tests {
607607
&mut parent,
608608
heap_touching_child as usize,
609609
&[Val::CPtr(heap_ptr)],
610+
heap_ptr,
610611
)
611612
.expect("context init succeeds");
612613
Context::swap(&mut parent, &child);
@@ -649,6 +650,7 @@ macro_rules! alloc_tests {
649650
&mut parent,
650651
stack_pattern_child as usize,
651652
&[Val::CPtr(heap_ptr)],
653+
heap_ptr,
652654
)
653655
.expect("context init succeeds");
654656
Context::swap(&mut parent, &child);

lucet-runtime/lucet-runtime-internals/src/context/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ impl Context {
256256
/// &mut child,
257257
/// entrypoint as usize,
258258
/// &[Val::U64(120), Val::F32(3.14)],
259+
/// std::ptr::null_mut(),
259260
/// );
260261
/// assert!(res.is_ok());
261262
/// ```
@@ -281,6 +282,7 @@ impl Context {
281282
/// &mut child,
282283
/// entrypoint as usize,
283284
/// &[Val::U64(120), Val::F32(3.14)],
285+
/// std::ptr::null_mut(),
284286
/// );
285287
/// assert!(res.is_ok());
286288
/// ```
@@ -446,6 +448,7 @@ impl Context {
446448
/// &mut child,
447449
/// entrypoint as usize,
448450
/// &[],
451+
/// std::ptr::null_mut(),
449452
/// ).unwrap();
450453
///
451454
/// unsafe { Context::swap(&mut parent, &child); }

lucet-runtime/lucet-runtime-internals/src/context/tests/c_child.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ macro_rules! init_and_swap {
5656
parent_regs.as_mut().unwrap(),
5757
$fn as usize,
5858
&[$( $args ),*],
59+
// this is the Context heap pointer, eventually put in r15.
60+
// because it's not an argument by the ABI, either it's used (by guest code)
61+
// or ignored and overwritten (by compiler-generated code)
62+
std::ptr::null_mut(),
5963
).unwrap()));
6064

6165
child_regs = child;

lucet-runtime/lucet-runtime-internals/src/context/tests/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use std::slice;
77
#[test]
88
fn context_offsets_correct() {
99
assert_eq!(offset_of!(Context, gpr), 0);
10-
assert_eq!(offset_of!(Context, fpr), 8 * 8);
11-
assert_eq!(offset_of!(Context, retvals_gp), 8 * 8 + 8 * 16);
12-
assert_eq!(offset_of!(Context, retval_fp), 8 * 8 + 8 * 16 + 8 * 2);
10+
assert_eq!(offset_of!(Context, fpr), 10 * 8);
11+
assert_eq!(offset_of!(Context, retvals_gp), 10 * 8 + 8 * 16);
12+
assert_eq!(offset_of!(Context, retval_fp), 10 * 8 + 8 * 16 + 8 * 2);
1313
}
1414

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

3333
// now we have the unaligned stack, let's make sure it blows up right
3434
let mut parent = ContextHandle::new();
35-
let res =
36-
ContextHandle::create_and_init(&mut stack_unaligned, &mut parent, dummy as usize, &[]);
35+
let res = ContextHandle::create_and_init(
36+
&mut stack_unaligned,
37+
&mut parent,
38+
dummy as usize,
39+
&[],
40+
std::ptr::null_mut(),
41+
);
3742

3843
if let Err(Error::UnalignedStack) = res {
3944
assert!(true);

lucet-runtime/lucet-runtime-internals/src/context/tests/rust_child.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ macro_rules! init_and_swap {
5252
PARENT.as_mut().unwrap(),
5353
$fn as usize,
5454
&[$( $args ),*],
55+
// this is the Context heap pointer, eventually put in r15.
56+
// because it's not an argument by the ABI, either it's used (by guest code)
57+
// or ignored and overwritten (by compiler-generated code)
58+
std::ptr::null_mut(),
5559
).unwrap();
5660
CHILD = Some(child);
5761

0 commit comments

Comments
 (0)