()
| 140 | #[tokio::test] |
| 141 | #[cfg_attr(miri, ignore)] |
| 142 | async fn recursive_call() { |
| 143 | let mut store = async_store(); |
| 144 | let func_ty = FuncType::new(store.engine(), None, None); |
| 145 | let async_wasm_func = Func::new_async(&mut store, func_ty, |_caller, _params, _results| { |
| 146 | Box::new(async { |
| 147 | tokio::task::yield_now().await; |
| 148 | Ok(()) |
| 149 | }) |
| 150 | }); |
| 151 | |
| 152 | // Create an imported function which recursively invokes another wasm |
| 153 | // function asynchronously, although this one is just our own host function |
| 154 | // which suffices for this test. |
| 155 | let func_ty = FuncType::new(store.engine(), None, None); |
| 156 | let func2 = Func::new_async(&mut store, func_ty, move |mut caller, _params, _results| { |
| 157 | Box::new(async move { |
| 158 | async_wasm_func |
| 159 | .call_async(&mut caller, &[], &mut []) |
| 160 | .await?; |
| 161 | Ok(()) |
| 162 | }) |
| 163 | }); |
| 164 | |
| 165 | // Create an instance which calls an async import twice. |
| 166 | let module = Module::new( |
| 167 | store.engine(), |
| 168 | " |
| 169 | (module |
| 170 | (import \"\" \"\" (func)) |
| 171 | (func (export \"\") |
| 172 | ;; call imported function which recursively does an async |
| 173 | ;; call |
| 174 | call 0 |
| 175 | ;; do it again, and our various pointers all better align |
| 176 | call 0)) |
| 177 | ", |
| 178 | ) |
| 179 | .unwrap(); |
| 180 | |
| 181 | let instance = Instance::new_async(&mut store, &module, &[func2.into()]) |
| 182 | .await |
| 183 | .unwrap(); |
| 184 | let func = instance.get_func(&mut store, "").unwrap(); |
| 185 | func.call_async(&mut store, &[], &mut []).await.unwrap(); |
| 186 | } |
| 187 | |
| 188 | #[tokio::test] |
| 189 | #[cfg_attr(miri, ignore)] |
nothing calls this directly
no test coverage detected