Merge pull request #700 from peterhuene/fix-wasi-test-programs

Fix WASI test program running.
This commit is contained in:
Peter Huene
2019-12-11 19:38:19 -08:00
committed by GitHub

View File

@@ -100,11 +100,27 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any
}
})
.collect::<Result<Vec<_>, _>>()?;
let _ = HostRef::new(Instance::new(&store, &module, &imports).context(format!(
let instance = HostRef::new(Instance::new(&store, &module, &imports).context(format!(
"error while instantiating Wasm module '{}'",
bin_name,
))?);
let export = instance
.borrow()
.find_export_by_name("_start")
.context("expected a _start export")?
.clone();
if let Err(trap) = export
.func()
.context("expected export to be a func")?
.borrow()
.call(&[])
{
bail!("trapped: {:?}", trap.borrow());
}
Ok(())
}