()
| 314 | #[tokio::test] |
| 315 | #[cfg_attr(miri, ignore)] |
| 316 | async fn cancel_host_future() -> Result<()> { |
| 317 | let mut config = Config::new(); |
| 318 | config.wasm_component_model_async(true); |
| 319 | let engine = Engine::new(&config)?; |
| 320 | |
| 321 | let component = Component::new( |
| 322 | &engine, |
| 323 | r#" |
| 324 | (component |
| 325 | (core module $libc (memory (export "memory") 1)) |
| 326 | (core instance $libc (instantiate $libc)) |
| 327 | (core module $m |
| 328 | (import "" "future.read" (func $future.read (param i32 i32) (result i32))) |
| 329 | (import "" "future.cancel-read" (func $future.cancel-read (param i32) (result i32))) |
| 330 | (memory (export "memory") 1) |
| 331 | |
| 332 | (func (export "run") (param i32) |
| 333 | ;; read/cancel attempt 1 |
| 334 | (call $future.read (local.get 0) (i32.const 100)) |
| 335 | i32.const -1 ;; BLOCKED |
| 336 | i32.ne |
| 337 | if unreachable end |
| 338 | |
| 339 | (call $future.cancel-read (local.get 0)) |
| 340 | i32.const 2 ;; CANCELLED |
| 341 | i32.ne |
| 342 | if unreachable end |
| 343 | |
| 344 | ;; read/cancel attempt 2 |
| 345 | (call $future.read (local.get 0) (i32.const 100)) |
| 346 | i32.const -1 ;; BLOCKED |
| 347 | i32.ne |
| 348 | if unreachable end |
| 349 | |
| 350 | (call $future.cancel-read (local.get 0)) |
| 351 | i32.const 2 ;; CANCELLED |
| 352 | i32.ne |
| 353 | if unreachable end |
| 354 | ) |
| 355 | ) |
| 356 | |
| 357 | (type $f (future u32)) |
| 358 | (core func $future.read (canon future.read $f async (memory $libc "memory"))) |
| 359 | (core func $future.cancel-read (canon future.cancel-read $f)) |
| 360 | |
| 361 | (core instance $i (instantiate $m |
| 362 | (with "" (instance |
| 363 | (export "future.read" (func $future.read)) |
| 364 | (export "future.cancel-read" (func $future.cancel-read)) |
| 365 | )) |
| 366 | )) |
| 367 | |
| 368 | (func (export "run") async (param "f" $f) |
| 369 | (canon lift |
| 370 | (core func $i "run") |
| 371 | (memory $libc "memory") |
| 372 | ) |
| 373 | ) |
nothing calls this directly
no test coverage detected