From f45d52301227de7a969422bf1e495e3b4bdc029a Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Mon, 8 Jul 2019 11:11:27 -0700 Subject: [PATCH] update tests to use backend as in cache key gen --- lib/runtime/benches/nginx.rs | 7 +++++-- lib/runtime/src/cache.rs | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/runtime/benches/nginx.rs b/lib/runtime/benches/nginx.rs index 1466addb1..9c80ae768 100644 --- a/lib/runtime/benches/nginx.rs +++ b/lib/runtime/benches/nginx.rs @@ -6,6 +6,7 @@ use wasmer_runtime::{ cache::{Cache, FileSystemCache, WasmHash}, compile, validate, }; +use wasmer_runtime_core::backend::Backend; static NGINX_WASM: &'static [u8] = include_bytes!("../../../examples/nginx/nginx.wasm"); @@ -18,7 +19,9 @@ fn load_module(hash: WasmHash, cache: &impl Cache) { } fn hashing_benchmark(c: &mut Criterion) { - c.bench_function("nginx HASH", |b| b.iter(|| WasmHash::generate(NGINX_WASM))); + c.bench_function("nginx HASH", |b| { + b.iter(|| WasmHash::generate(NGINX_WASM, Backend::Cranelift)) + }); } fn validate_benchmark(c: &mut Criterion) { @@ -36,7 +39,7 @@ fn load_benchmark(c: &mut Criterion) { FileSystemCache::new(tempdir.path()).expect("unable to create file system cache") }; let module = compile(NGINX_WASM).unwrap(); - let wasm_hash = WasmHash::generate(NGINX_WASM); + let wasm_hash = WasmHash::generate(NGINX_WASM, Backend::Cranelift); cache .store(wasm_hash, module) .expect("unable to store into cache"); diff --git a/lib/runtime/src/cache.rs b/lib/runtime/src/cache.rs index b6d1d779b..9b452c70a 100644 --- a/lib/runtime/src/cache.rs +++ b/lib/runtime/src/cache.rs @@ -20,6 +20,7 @@ pub use wasmer_runtime_core::cache::{Artifact, Cache, WasmHash, WASMER_VERSION_H /// /// ```rust /// use wasmer_runtime::cache::{Cache, FileSystemCache, WasmHash}; +/// use wasmer_runtime_core::backend::Backend; /// /// # use wasmer_runtime::{Module, error::CacheError}; /// fn store_module(module: Module) -> Result { @@ -28,7 +29,7 @@ pub use wasmer_runtime_core::cache::{Artifact, Cache, WasmHash, WASMER_VERSION_H /// // corrupted or tampered with. /// let mut fs_cache = unsafe { FileSystemCache::new("some/directory/goes/here")? }; /// // Compute a key for a given WebAssembly binary -/// let key = WasmHash::generate(&[]); +/// let key = WasmHash::generate(&[], Backend::Cranelift); /// // Store a module into the cache given a key /// fs_cache.store(key, module.clone())?; /// Ok(module) @@ -119,6 +120,7 @@ mod tests { use super::*; use std::env; + use wasmer_runtime_core::backend::Backend; #[test] fn test_file_system_cache_run() { @@ -147,7 +149,7 @@ mod tests { .unwrap() }; // store module - let key = WasmHash::generate(&wasm); + let key = WasmHash::generate(&wasm, Backend::Cranelift); fs_cache.store(key, module.clone()).unwrap(); // load module