()
| 922 | #[tokio::test] |
| 923 | #[cfg(not(miri))] |
| 924 | async fn total_stacks_limit() -> Result<()> { |
| 925 | use super::async_functions::PollOnce; |
| 926 | |
| 927 | const TOTAL_STACKS: u32 = 2; |
| 928 | |
| 929 | let mut pool = crate::small_pool_config(); |
| 930 | pool.total_stacks(TOTAL_STACKS) |
| 931 | .total_core_instances(TOTAL_STACKS + 1); |
| 932 | let mut config = Config::new(); |
| 933 | config.allocation_strategy(pool); |
| 934 | |
| 935 | let engine = Engine::new(&config)?; |
| 936 | |
| 937 | let mut linker = Linker::new(&engine); |
| 938 | linker.func_new_async( |
| 939 | "async", |
| 940 | "yield", |
| 941 | FuncType::new(&engine, [], []), |
| 942 | |_caller, _params, _results| { |
| 943 | Box::new(async { |
| 944 | tokio::task::yield_now().await; |
| 945 | Ok(()) |
| 946 | }) |
| 947 | }, |
| 948 | )?; |
| 949 | |
| 950 | let module = Module::new( |
| 951 | &engine, |
| 952 | r#" |
| 953 | (module |
| 954 | (import "async" "yield" (func $yield)) |
| 955 | (func (export "run") |
| 956 | call $yield |
| 957 | ) |
| 958 | |
| 959 | (func $empty) |
| 960 | (start $empty) |
| 961 | ) |
| 962 | "#, |
| 963 | )?; |
| 964 | |
| 965 | // Allocate stacks up to the limit. (Poll the futures once to make sure we |
| 966 | // actually enter Wasm and force a stack allocation.) |
| 967 | |
| 968 | let mut store1 = Store::new(&engine, ()); |
| 969 | let instance1 = linker.instantiate_async(&mut store1, &module).await?; |
| 970 | let run1 = instance1.get_func(&mut store1, "run").unwrap(); |
| 971 | let future1 = PollOnce::new(Box::pin(run1.call_async(store1, &[], &mut []))) |
| 972 | .await |
| 973 | .unwrap_err(); |
| 974 | |
| 975 | let mut store2 = Store::new(&engine, ()); |
| 976 | let instance2 = linker.instantiate_async(&mut store2, &module).await?; |
| 977 | let run2 = instance2.get_func(&mut store2, "run").unwrap(); |
| 978 | let future2 = PollOnce::new(Box::pin(run2.call_async(store2, &[], &mut []))) |
| 979 | .await |
| 980 | .unwrap_err(); |
| 981 |
nothing calls this directly
no test coverage detected