use crate::utils::{self, OutDir};
#[test]
fn test_own_memory_expansion() {
if !utils::has_required_wasi_targets(true) {
return;
}
let err = utils::run_wasi_virt_layer_with_thread_toolchain(
Some("own_memory_vfs"),
None,
None, false, OutDir::Random,
true, &["--own-memory", "big_alloc"],
None,
)
.unwrap_err();
let err_str = format!("{err:?}");
assert!(
err_str.contains("RuntimeError: unreachable")
|| err_str.contains("memory allocation of 104857600 bytes failed"),
"Expected memory allocation failure due to strict own_memory bounds, but got: {}",
err_str
);
let _dir = utils::run_wasi_virt_layer_with_thread_toolchain(
Some("own_memory_vfs"),
None,
None, false, OutDir::Random,
true, &[
"--own-memory",
"--features",
"manual_expand_memory",
"big_alloc",
],
None,
)
.expect("Test should succeed with manual memory expansion");
}
#[test]
fn test_own_memory_self_api() {
if !utils::has_required_wasi_targets(true) {
return;
}
let dir = utils::run_wasi_virt_layer_with_thread_toolchain(
Some("own_memory_vfs"),
None,
None, false, OutDir::Random,
true, &[
"--own-memory",
"--features",
"manual_expand_memory,self_own_memory_api",
"big_alloc",
],
None,
)
.expect("Test should succeed with self own-memory API enabled");
let stdout = std::fs::read_to_string(dir.0.join(".deno-test-stdout.log"))
.expect("deno stdout should be captured");
assert!(
stdout.contains("self own-memory API results:"),
"expected self own-memory API output, got: {stdout}"
);
}