Skip to content

Commit 29509d3

Browse files
committed
Add new test case to test/async/trap-if-block-and-sync.wast
1 parent 5f49720 commit 29509d3

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

test/async/trap-if-block-and-sync.wast

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
;; $Tester is created to run each test.
55
(component definition $Tester
66
(component $C
7+
(core module $Memory (memory (export "mem") 1))
8+
(core instance $memory (instantiate $Memory))
79
(core module $CM
10+
(import "" "waitable-set.new" (func $waitable-set.new (result i32)))
11+
(import "" "waitable-set.wait" (func $waitable-set.wait (param i32 i32) (result i32)))
812
(func (export "sync-async-func")
913
unreachable
1014
)
@@ -14,15 +18,26 @@
1418
(func (export "async-async-func-cb") (param i32 i32 i32) (result i32)
1519
unreachable
1620
)
21+
(func (export "sync-blocks-and-traps")
22+
(call $waitable-set.wait (call $waitable-set.new) (i32.const 0xdeadbeef))
23+
unreachable
24+
)
1725
)
18-
(core instance $cm (instantiate $CM))
26+
(canon waitable-set.new (core func $waitable-set.new))
27+
(canon waitable-set.wait (memory $memory "mem") (core func $waitable-set.wait))
28+
(core instance $cm (instantiate $CM (with "" (instance
29+
(export "waitable-set.new" (func $waitable-set.new))
30+
(export "waitable-set.wait" (func $waitable-set.wait))
31+
))))
1932
(func (export "sync-async-func") async (canon lift (core func $cm "sync-async-func")))
2033
(func (export "async-async-func") async (canon lift (core func $cm "async-async-func") async (callback (func $cm "async-async-func-cb"))))
34+
(func (export "sync-blocks-and-traps") (canon lift (core func $cm "sync-blocks-and-traps")))
2135
)
2236
(component $D
2337
(import "c" (instance $c
2438
(export "sync-async-func" (func async))
2539
(export "async-async-func" (func async))
40+
(export "sync-blocks-and-traps" (func))
2641
))
2742

2843
(core module $Memory (memory (export "mem") 1))
@@ -55,6 +70,7 @@
5570
(import "" "future.cancel-write" (func $future.cancel-write (param i32) (result i32)))
5671
(import "" "await-sync-async-func" (func $await-sync-async-func))
5772
(import "" "await-async-async-func" (func $await-async-async-func))
73+
(import "" "sync-blocks-and-traps" (func $sync-blocks-and-traps))
5874
(import "" "__indirect_function_table" (table $indirect-function-table 2 funcref))
5975

6076
(func (export "unreachable-cb") (param i32 i32 i32) (result i32)
@@ -71,6 +87,10 @@
7187
(func (export "trap-if-sync-call-async2")
7288
(call $await-async-async-func)
7389
)
90+
(func (export "trap-if-async-calls-sync-and-blocks") (result i32)
91+
(call $sync-blocks-and-traps)
92+
unreachable
93+
)
7494
(func (export "trap-if-suspend")
7595
(call $thread.suspend)
7696
unreachable
@@ -192,6 +212,7 @@
192212
(canon future.cancel-write $FT (core func $future.cancel-write))
193213
(canon lower (func $c "sync-async-func") (core func $await-sync-async-func'))
194214
(canon lower (func $c "async-async-func") (core func $await-async-async-func'))
215+
(canon lower (func $c "sync-blocks-and-traps") (core func $sync-blocks-and-traps'))
195216
(core instance $core (instantiate $Core (with "" (instance
196217
(export "mem" (memory $memory "mem"))
197218
(export "task.return" (func $task.return))
@@ -217,6 +238,7 @@
217238
(export "future.cancel-write" (func $future.cancel-write))
218239
(export "await-sync-async-func" (func $await-sync-async-func'))
219240
(export "await-async-async-func" (func $await-async-async-func'))
241+
(export "sync-blocks-and-traps" (func $sync-blocks-and-traps'))
220242
(export "__indirect_function_table" (table $indirect-function-table))
221243
))))
222244
(func (export "trap-if-suspend") (canon lift (core func $core "trap-if-suspend")))
@@ -231,6 +253,7 @@
231253
(func (export "resume-later-is-fine") (result u32) (canon lift (core func $core "resume-later-is-fine")))
232254
(func (export "trap-if-sync-call-async1") (canon lift (core func $core "trap-if-sync-call-async1")))
233255
(func (export "trap-if-sync-call-async2") (canon lift (core func $core "trap-if-sync-call-async2")))
256+
(func (export "trap-if-async-calls-sync-and-blocks") (canon lift (core func $core "trap-if-async-calls-sync-and-blocks") async (callback (func $core "unreachable-cb"))))
234257
(func (export "trap-if-sync-cancel") (canon lift (core func $core "trap-if-sync-cancel")))
235258
(func (export "trap-if-sync-stream-read") (canon lift (core func $core "trap-if-sync-stream-read")))
236259
(func (export "trap-if-sync-stream-write") (canon lift (core func $core "trap-if-sync-stream-write")))
@@ -245,6 +268,7 @@
245268
(instance $d (instantiate $D (with "c" (instance $c))))
246269
(func (export "trap-if-sync-call-async1") (alias export $d "trap-if-sync-call-async1"))
247270
(func (export "trap-if-sync-call-async2") (alias export $d "trap-if-sync-call-async2"))
271+
(func (export "trap-if-async-calls-sync-and-blocks") (alias export $d "trap-if-async-calls-sync-and-blocks"))
248272
(func (export "trap-if-suspend") (alias export $d "trap-if-suspend"))
249273
(func (export "trap-if-wait") (alias export $d "trap-if-wait"))
250274
(func (export "trap-if-wait-cb") (alias export $d "trap-if-wait-cb"))
@@ -271,6 +295,8 @@
271295
(component instance $i $Tester)
272296
(assert_trap (invoke "trap-if-sync-call-async2") "cannot block a synchronous task before returning")
273297
(component instance $i $Tester)
298+
(assert_trap (invoke "trap-if-async-calls-sync-and-blocks") "cannot block a synchronous task before returning")
299+
(component instance $i $Tester)
274300
(assert_trap (invoke "trap-if-suspend") "cannot block a synchronous task before returning")
275301
(component instance $i $Tester)
276302
(assert_trap (invoke "trap-if-wait") "cannot block a synchronous task before returning")

0 commit comments

Comments
 (0)