wiggle: automate borrow checking, explicitly passing borrow checker throughout

This commit is contained in:
Pat Hickey
2020-05-18 11:45:12 -07:00
parent e229fbc79c
commit 52e8300f01
14 changed files with 313 additions and 191 deletions

View File

@@ -1,6 +1,6 @@
use proptest::prelude::*;
use std::convert::TryFrom;
use wiggle::GuestMemory;
use wiggle::{BorrowChecker, GuestMemory};
use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx};
wiggle::from_witx!({
@@ -46,17 +46,19 @@ impl CookieCutterExercise {
pub fn test(&self) {
let ctx = WasiCtx::new();
let host_memory = HostMemory::new();
let bc = BorrowChecker::new();
let res = ints::cookie_cutter(
&ctx,
&host_memory,
&bc,
self.cookie.into(),
self.return_ptr_loc.ptr as i32,
);
assert_eq!(res, types::Errno::Ok.into(), "cookie cutter errno");
let is_cookie_start = host_memory
.ptr::<types::Bool>(self.return_ptr_loc.ptr)
.ptr::<types::Bool>(&bc, self.return_ptr_loc.ptr)
.read()
.expect("deref to Bool value");