Skip to content

Commit 93bde74

Browse files
authored
[wasm-split] Split option tests from multi-split.wast (WebAssembly#8239)
This splits out option tests into `multi-split-options.wast`. I plan to add more option tests and adding all them to `multi-split.wast` looks a little too crowded.
1 parent af46d19 commit 93bde74

File tree

2 files changed

+247
-185
lines changed

2 files changed

+247
-185
lines changed
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
2+
3+
;; Check if --import-namespace, --export-prefix, and --no-placeholders options
4+
;; work.
5+
;; RUN: wasm-split -all -g --multi-split %s --manifest %S/multi-split.wast.manifest --out-prefix=%t --import-namespace=custom_env --export-prefix='%' --no-placeholders -o %t.wasm
6+
;; RUN: wasm-dis %t.wasm | filecheck %s --check-prefix=PRIMARY-OPTIONS
7+
;; RUN: wasm-dis %t1.wasm | filecheck %s --check-prefix=MOD1-OPTIONS
8+
;; RUN: wasm-dis %t2.wasm | filecheck %s --check-prefix=MOD2-OPTIONS
9+
;; RUN: wasm-dis %t3.wasm | filecheck %s --check-prefix=MOD3-OPTIONS
10+
11+
;; Check if --placeholder-namespace option works.
12+
;; RUN: wasm-split -all -g --multi-split %s --manifest %S/multi-split.wast.manifest --out-prefix=%t --placeholder-namespace=placeholder_env -o %t.wasm
13+
;; RUN: wasm-dis %t.wasm | filecheck %s --check-prefix=PRIMARY-PLACEHOLDER-NAMESPACE
14+
15+
(module
16+
;; PRIMARY-OPTIONS: (type $ret-i64 (func (result i64)))
17+
18+
;; PRIMARY-OPTIONS: (type $ret-f32 (func (result f32)))
19+
20+
;; PRIMARY-OPTIONS: (type $ret-i32 (func (result i32)))
21+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (type $ret-i64 (func (result i64)))
22+
23+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (type $ret-f32 (func (result f32)))
24+
25+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (type $ret-i32 (func (result i32)))
26+
(type $ret-i32 (func (result i32)))
27+
(type $ret-i64 (func (result i64)))
28+
(type $ret-f32 (func (result f32)))
29+
30+
;; MOD1-OPTIONS: (type $0 (func (result i64)))
31+
32+
;; MOD1-OPTIONS: (type $1 (func (result f32)))
33+
34+
;; MOD1-OPTIONS: (type $2 (func (result i32)))
35+
36+
;; MOD1-OPTIONS: (import "custom_env" "%table" (table $timport$0 3 funcref))
37+
38+
;; MOD1-OPTIONS: (import "custom_env" "%trampoline_B" (func $trampoline_B (exact (result i64))))
39+
40+
;; MOD1-OPTIONS: (import "custom_env" "%trampoline_C" (func $trampoline_C (exact (result f32))))
41+
42+
;; MOD1-OPTIONS: (elem $0 (i32.const 2) $A)
43+
44+
;; MOD1-OPTIONS: (func $A (result i32)
45+
;; MOD1-OPTIONS-NEXT: (drop
46+
;; MOD1-OPTIONS-NEXT: (call_ref $2
47+
;; MOD1-OPTIONS-NEXT: (ref.func $A)
48+
;; MOD1-OPTIONS-NEXT: )
49+
;; MOD1-OPTIONS-NEXT: )
50+
;; MOD1-OPTIONS-NEXT: (drop
51+
;; MOD1-OPTIONS-NEXT: (call_ref $0
52+
;; MOD1-OPTIONS-NEXT: (ref.func $trampoline_B)
53+
;; MOD1-OPTIONS-NEXT: )
54+
;; MOD1-OPTIONS-NEXT: )
55+
;; MOD1-OPTIONS-NEXT: (drop
56+
;; MOD1-OPTIONS-NEXT: (call_ref $1
57+
;; MOD1-OPTIONS-NEXT: (ref.func $trampoline_C)
58+
;; MOD1-OPTIONS-NEXT: )
59+
;; MOD1-OPTIONS-NEXT: )
60+
;; MOD1-OPTIONS-NEXT: (i32.const 0)
61+
;; MOD1-OPTIONS-NEXT: )
62+
(func $A (type $ret-i32) (result i32)
63+
(drop
64+
(call_ref $ret-i32
65+
(ref.func $A)
66+
)
67+
)
68+
(drop
69+
(call_ref $ret-i64
70+
(ref.func $B)
71+
)
72+
)
73+
(drop
74+
(call_ref $ret-f32
75+
(ref.func $C)
76+
)
77+
)
78+
(i32.const 0)
79+
)
80+
81+
;; MOD2-OPTIONS: (type $0 (func (result i32)))
82+
83+
;; MOD2-OPTIONS: (type $1 (func (result f32)))
84+
85+
;; MOD2-OPTIONS: (type $2 (func (result i64)))
86+
87+
;; MOD2-OPTIONS: (import "custom_env" "%table" (table $timport$0 3 funcref))
88+
89+
;; MOD2-OPTIONS: (import "custom_env" "%trampoline_A" (func $trampoline_A (exact (result i32))))
90+
91+
;; MOD2-OPTIONS: (import "custom_env" "%trampoline_C" (func $trampoline_C (exact (result f32))))
92+
93+
;; MOD2-OPTIONS: (elem $0 (i32.const 0) $B)
94+
95+
;; MOD2-OPTIONS: (func $B (result i64)
96+
;; MOD2-OPTIONS-NEXT: (drop
97+
;; MOD2-OPTIONS-NEXT: (call_ref $0
98+
;; MOD2-OPTIONS-NEXT: (ref.func $trampoline_A)
99+
;; MOD2-OPTIONS-NEXT: )
100+
;; MOD2-OPTIONS-NEXT: )
101+
;; MOD2-OPTIONS-NEXT: (drop
102+
;; MOD2-OPTIONS-NEXT: (call_ref $2
103+
;; MOD2-OPTIONS-NEXT: (ref.func $B)
104+
;; MOD2-OPTIONS-NEXT: )
105+
;; MOD2-OPTIONS-NEXT: )
106+
;; MOD2-OPTIONS-NEXT: (drop
107+
;; MOD2-OPTIONS-NEXT: (call_ref $1
108+
;; MOD2-OPTIONS-NEXT: (ref.func $trampoline_C)
109+
;; MOD2-OPTIONS-NEXT: )
110+
;; MOD2-OPTIONS-NEXT: )
111+
;; MOD2-OPTIONS-NEXT: (i64.const 0)
112+
;; MOD2-OPTIONS-NEXT: )
113+
(func $B (type $ret-i64) (result i64)
114+
(drop
115+
(call_ref $ret-i32
116+
(ref.func $A)
117+
)
118+
)
119+
(drop
120+
(call_ref $ret-i64
121+
(ref.func $B)
122+
)
123+
)
124+
(drop
125+
(call_ref $ret-f32
126+
(ref.func $C)
127+
)
128+
)
129+
(i64.const 0)
130+
)
131+
132+
;; MOD3-OPTIONS: (type $0 (func (result i32)))
133+
134+
;; MOD3-OPTIONS: (type $1 (func (result i64)))
135+
136+
;; MOD3-OPTIONS: (type $2 (func (result f32)))
137+
138+
;; MOD3-OPTIONS: (import "custom_env" "%table" (table $timport$0 3 funcref))
139+
140+
;; MOD3-OPTIONS: (import "custom_env" "%trampoline_A" (func $trampoline_A (exact (result i32))))
141+
142+
;; MOD3-OPTIONS: (import "custom_env" "%trampoline_B" (func $trampoline_B (exact (result i64))))
143+
144+
;; MOD3-OPTIONS: (elem $0 (i32.const 1) $C)
145+
146+
;; MOD3-OPTIONS: (func $C (result f32)
147+
;; MOD3-OPTIONS-NEXT: (drop
148+
;; MOD3-OPTIONS-NEXT: (call_ref $0
149+
;; MOD3-OPTIONS-NEXT: (ref.func $trampoline_A)
150+
;; MOD3-OPTIONS-NEXT: )
151+
;; MOD3-OPTIONS-NEXT: )
152+
;; MOD3-OPTIONS-NEXT: (drop
153+
;; MOD3-OPTIONS-NEXT: (call_ref $1
154+
;; MOD3-OPTIONS-NEXT: (ref.func $trampoline_B)
155+
;; MOD3-OPTIONS-NEXT: )
156+
;; MOD3-OPTIONS-NEXT: )
157+
;; MOD3-OPTIONS-NEXT: (drop
158+
;; MOD3-OPTIONS-NEXT: (call_ref $2
159+
;; MOD3-OPTIONS-NEXT: (ref.func $C)
160+
;; MOD3-OPTIONS-NEXT: )
161+
;; MOD3-OPTIONS-NEXT: )
162+
;; MOD3-OPTIONS-NEXT: (f32.const 0)
163+
;; MOD3-OPTIONS-NEXT: )
164+
(func $C (type $ret-f32) (result f32)
165+
(drop
166+
(call_ref $ret-i32
167+
(ref.func $A)
168+
)
169+
)
170+
(drop
171+
(call_ref $ret-i64
172+
(ref.func $B)
173+
)
174+
)
175+
(drop
176+
(call_ref $ret-f32
177+
(ref.func $C)
178+
)
179+
)
180+
(f32.const 0)
181+
)
182+
)
183+
;; PRIMARY-OPTIONS: (table $0 3 funcref)
184+
185+
;; PRIMARY-OPTIONS: (elem $0 (table $0) (i32.const 0) funcref (item (ref.null nofunc)) (item (ref.null nofunc)) (item (ref.null nofunc)))
186+
187+
;; PRIMARY-OPTIONS: (export "%trampoline_B" (func $trampoline_B))
188+
189+
;; PRIMARY-OPTIONS: (export "%trampoline_C" (func $trampoline_C))
190+
191+
;; PRIMARY-OPTIONS: (export "%trampoline_A" (func $trampoline_A))
192+
193+
;; PRIMARY-OPTIONS: (export "%table" (table $0))
194+
195+
;; PRIMARY-OPTIONS: (func $trampoline_B (result i64)
196+
;; PRIMARY-OPTIONS-NEXT: (call_indirect (type $ret-i64)
197+
;; PRIMARY-OPTIONS-NEXT: (i32.const 0)
198+
;; PRIMARY-OPTIONS-NEXT: )
199+
;; PRIMARY-OPTIONS-NEXT: )
200+
201+
;; PRIMARY-OPTIONS: (func $trampoline_C (result f32)
202+
;; PRIMARY-OPTIONS-NEXT: (call_indirect (type $ret-f32)
203+
;; PRIMARY-OPTIONS-NEXT: (i32.const 1)
204+
;; PRIMARY-OPTIONS-NEXT: )
205+
;; PRIMARY-OPTIONS-NEXT: )
206+
207+
;; PRIMARY-OPTIONS: (func $trampoline_A (result i32)
208+
;; PRIMARY-OPTIONS-NEXT: (call_indirect (type $ret-i32)
209+
;; PRIMARY-OPTIONS-NEXT: (i32.const 2)
210+
;; PRIMARY-OPTIONS-NEXT: )
211+
;; PRIMARY-OPTIONS-NEXT: )
212+
213+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (import "placeholder_env.2" "0" (func $placeholder_0 (result i64)))
214+
215+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (import "placeholder_env.3" "1" (func $placeholder_1 (result f32)))
216+
217+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (import "placeholder_env.1" "2" (func $placeholder_2 (result i32)))
218+
219+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (table $0 3 funcref)
220+
221+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (elem $0 (i32.const 0) $placeholder_0 $placeholder_1 $placeholder_2)
222+
223+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (export "trampoline_B" (func $trampoline_B))
224+
225+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (export "trampoline_C" (func $trampoline_C))
226+
227+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (export "trampoline_A" (func $trampoline_A))
228+
229+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (export "table" (table $0))
230+
231+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (func $trampoline_B (result i64)
232+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: (call_indirect (type $ret-i64)
233+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: (i32.const 0)
234+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: )
235+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: )
236+
237+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (func $trampoline_C (result f32)
238+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: (call_indirect (type $ret-f32)
239+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: (i32.const 1)
240+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: )
241+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: )
242+
243+
;; PRIMARY-PLACEHOLDER-NAMESPACE: (func $trampoline_A (result i32)
244+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: (call_indirect (type $ret-i32)
245+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: (i32.const 2)
246+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: )
247+
;; PRIMARY-PLACEHOLDER-NAMESPACE-NEXT: )

0 commit comments

Comments
 (0)