Merge pull request #3245 from peterhuene/add-paged-init-setting

Add `paged_memory_initialization` to Config.
This commit is contained in:
Peter Huene
2021-08-26 18:54:16 -07:00
committed by GitHub
3 changed files with 49 additions and 1 deletions

View File

@@ -32,6 +32,29 @@ fn initializes_linear_memory() -> Result<()> {
Ok(())
}
#[test]
fn initializes_linear_memory_paged() -> Result<()> {
let wat = r#"
(module
(memory (export "memory") 2)
(data (i32.const 0) "Hello World!")
)"#;
let mut config = Config::new();
config.paged_memory_initialization(true);
let module = Module::new(&Engine::new(&config)?, wat)?;
let mut store = Store::new(module.engine(), ());
let instance = Instance::new(&mut store, &module, &[])?;
let memory = instance.get_memory(&mut store, "memory").unwrap();
let mut bytes = [0; 12];
memory.read(&store, 0, &mut bytes)?;
assert_eq!(bytes, "Hello World!".as_bytes());
Ok(())
}
#[test]
fn linear_memory_limits() -> Result<()> {
// this test will allocate 4GB of virtual memory space, and may not work in