Skip to content

Commit e1fdcd1

Browse files
committed
Add test/async/dont-block-start.wast
1 parent 2ed7a09 commit e1fdcd1

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/async/dont-block-start.wast

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
;; test a few cases where components trap during core module instantiation
2+
;; due to blocking during the (implicitly sync) start function
3+
(assert_trap
4+
(component
5+
(core module $Memory (memory (export "mem") 1))
6+
(core instance $memory (instantiate $Memory))
7+
(core module $M
8+
(import "" "waitable-set.new" (func $waitable-set.new (result i32)))
9+
(import "" "waitable-set.wait" (func $waitable-set.wait (param i32 i32) (result i32)))
10+
(func $start
11+
(drop (call $waitable-set.wait (call $waitable-set.new) (i32.const 0)))
12+
)
13+
(start $start)
14+
)
15+
(canon waitable-set.new (core func $waitable-set.new))
16+
(canon waitable-set.wait (memory $memory "mem") (core func $waitable-set.wait))
17+
(core instance $m (instantiate $M (with "" (instance
18+
(export "waitable-set.new" (func $waitable-set.new))
19+
(export "waitable-set.wait" (func $waitable-set.wait))
20+
))))
21+
)
22+
"cannot block a synchronous task before returning"
23+
)
24+
(assert_trap
25+
(component
26+
(component $C
27+
(core module $M
28+
(func (export "f") (result i32) unreachable)
29+
(func (export "f_cb") (param i32 i32 i32) (result i32) unreachable)
30+
)
31+
(core instance $i (instantiate $M))
32+
(func (export "f") async (canon lift (core func $i "f") async (callback (func $i "f_cb"))))
33+
)
34+
(component $D
35+
(import "f" (func $f async))
36+
(core module $M
37+
(import "" "f" (func $f))
38+
(func $start (call $f))
39+
(start $start)
40+
)
41+
(canon lower (func $f) (core func $f'))
42+
(core instance $m (instantiate $M (with "" (instance
43+
(export "f" (func $f'))
44+
))))
45+
)
46+
(instance $c (instantiate $C))
47+
(instance $d (instantiate $D (with "f" (func $c "f"))))
48+
)
49+
"cannot block a synchronous task before returning"
50+
)

0 commit comments

Comments
 (0)