Skip to content

Commit 9286448

Browse files
authored
Update Wasm 2.0 spec tests. (#2458)
I updated the Wasm 2.0 spectests to the `wg-2.0` tag, and fixed a couple of simple things. I'm still stuck on a few others. Specifically this one is failing (compiler crashes instead, but it's the same test, so probably the same issue): ``` --- FAIL: TestCompiler (2.42s) --- FAIL: TestCompiler/table_grow.wast (0.00s) --- FAIL: TestCompiler/table_grow.wast/module/line:117 (0.00s) require.go:331: expected no error, but was import table[grown-table.table]: minimum size mismatch: 2 > 1: table_grow.wast:117 module /usr/local/google/home/cruces/Documents/Personal/wazero/internal/integration_test/spectest/spectest.go:400 ``` It's this wast: ```wast (module $Tgt (table (export "table") 1 funcref) ;; initial size is 1 (func (export "grow") (result i32) (table.grow (ref.null func) (i32.const 1))) ) (register "grown-table" $Tgt) (assert_return (invoke $Tgt "grow") (i32.const 1)) ;; now size is 2 (module $Tgit1 ;; imported table limits should match, because external table size is 2 now (table (export "table") (import "grown-table" "table") 2 funcref) (func (export "grow") (result i32) (table.grow (ref.null func) (i32.const 1))) ) (register "grown-imported-table" $Tgit1) (assert_return (invoke $Tgit1 "grow") (i32.const 2)) ;; now size is 3 (module $Tgit2 ;; imported table limits should match, because external table size is 3 now (import "grown-imported-table" "table" (table 3 funcref)) (func (export "size") (result i32) (table.size)) ) (assert_return (invoke $Tgit2 "size") (i32.const 3)) ``` Apparently, registering the `grown-table` module registers it but doesn't instantiate it? Idk. @evacchi any ideas? --------- Signed-off-by: Nuno Cruces <[email protected]>
1 parent af80797 commit 9286448

335 files changed

Lines changed: 1787 additions & 1365 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/commit.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
steps:
3333
- name: Install latest wast2json
3434
run: | # Needed for build.spectest. wabt includes wast2json.
35-
wabt_version=1.0.34
36-
wabt_url=https://github.com/WebAssembly/wabt/releases/download/${wabt_version}/wabt-${wabt_version}-ubuntu.tar.gz
35+
wabt_version=1.0.39
36+
wabt_url=https://github.com/WebAssembly/wabt/releases/download/${wabt_version}/wabt-${wabt_version}-linux-x64.tar.gz
3737
curl -sSL ${wabt_url} | tar --strip-components 2 -C /usr/local/bin -xzf - wabt-${wabt_version}/bin/wast2json
3838
3939
- uses: actions/checkout@v4

‎Makefile‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,29 @@ internal/testing/dwarftestdata/testdata/rust/main.wasm.xz:
108108
@mv $(@D)/target/$(cargo_target)/release/$(@F) $(@D)
109109

110110
spectest_base_dir := internal/integration_test/spectest
111+
111112
spectest_v1_dir := $(spectest_base_dir)/v1
112113
spectest_v1_testdata_dir := $(spectest_v1_dir)/testdata
113114
spec_version_v1 := wg-1.0
115+
114116
spectest_v2_dir := $(spectest_base_dir)/v2
115117
spectest_v2_testdata_dir := $(spectest_v2_dir)/testdata
118+
spec_version_v2 := wg-2.0
116119

117-
# Latest draft state as of March 12, 2024.
118-
spec_version_v2 := 1c5e5d178bd75c79b7a12881c529098beaee2a05
119120
spectest_threads_dir := $(spectest_base_dir)/threads
120121
spectest_threads_testdata_dir := $(spectest_threads_dir)/testdata
121-
# From https://github.com/WebAssembly/threads/tree/upstream-rebuild which has not been merged to main yet.
122-
# It will likely be renamed to main in the future - https://github.com/WebAssembly/threads/issues/216.
123-
spec_version_threads := 3635ca51a17e57e106988846c5b0e0cc48ac04fc
122+
spec_version_threads := ff17701446d8e2086142423ef77ae947a025e26f
124123

125124
spectest_tail_call_dir := $(spectest_base_dir)/tail-call
126125
spectest_tail_call_testdata_dir := $(spectest_tail_call_dir)/testdata
127-
spec_version_tail_call := 4fd2339b5e9709e74b326797f69a88b13eac4d47
126+
spec_version_tail_call := 88e97b0f742f4c3ee01fea683da130f344dd7b02
128127

129128
.PHONY: build.spectest
130129
build.spectest:
131130
@$(MAKE) build.spectest.v1
132131
@$(MAKE) build.spectest.v2
132+
@$(MAKE) build.spectest.threads
133+
@$(MAKE) build.spectest.tail_call
133134

134135
.PHONY: build.spectest.v1
135136
build.spectest.v1: # Note: wabt by default uses >1.0 features, so wast2json flags might drift as they include more. See WebAssembly/wabt#1878
@@ -160,6 +161,7 @@ build.spectest.v1: # Note: wabt by default uses >1.0 features, so wast2json flag
160161

161162
.PHONY: build.spectest.v2
162163
build.spectest.v2: # Note: SIMD cases are placed in the "simd" subdirectory.
164+
@rm -rf $(spectest_v2_testdata_dir)
163165
@mkdir -p $(spectest_v2_testdata_dir)
164166
@cd $(spectest_v2_testdata_dir) \
165167
&& curl -sSL 'https://api.github.com/repos/WebAssembly/spec/contents/test/core?ref=$(spec_version_v2)' | jq -r '.[]| .download_url' | grep -E ".wast" | xargs -Iurl curl -sJL url -O
@@ -173,19 +175,21 @@ build.spectest.v2: # Note: SIMD cases are placed in the "simd" subdirectory.
173175
# https://github.com/WebAssembly/wabt/issues/2348#issuecomment-1878003959
174176
.PHONY: build.spectest.threads
175177
build.spectest.threads:
178+
@rm -rf $(spectest_threads_testdata_dir)
176179
@mkdir -p $(spectest_threads_testdata_dir)
177180
@cd $(spectest_threads_testdata_dir) \
178-
&& curl -sSL 'https://api.github.com/repos/WebAssembly/threads/contents/test/core?ref=$(spec_version_threads)' | jq -r '.[]| .download_url' | grep -E "atomic.wast" | xargs -Iurl curl -sJL url -O
181+
&& curl -sSL 'https://api.github.com/repos/WebAssembly/threads/contents/test/core/threads?ref=$(spec_version_threads)' | jq -r '.[]| .download_url' | grep -E "/atomic.wast" | xargs -Iurl curl -sJL url -O
179182
@cd $(spectest_threads_testdata_dir) && for f in `find . -name '*.wast'`; do \
180183
wast2json --enable-threads --debug-names $$f; \
181184
done
182185

183186
.PHONY: build.spectest.tail_call
184187
build.spectest.tail_call:
185-
mkdir -p $(spectest_tail_call_testdata_dir)
186-
cd $(spectest_tail_call_testdata_dir) \
188+
@rm -rf $(spectest_tail_call_testdata_dir)
189+
@mkdir -p $(spectest_tail_call_testdata_dir)
190+
@cd $(spectest_tail_call_testdata_dir) \
187191
&& curl -sSL 'https://api.github.com/repos/WebAssembly/testsuite/contents/proposals/tail-call?ref=$(spec_version_tail_call)' | jq -r '.[]| .download_url' | grep -E ".wast" | xargs -Iurl curl -sJL url -O
188-
cd $(spectest_tail_call_testdata_dir) && for f in `find . -name '*.wast'`; do \
192+
@cd $(spectest_tail_call_testdata_dir) && for f in `find . -name '*.wast'`; do \
189193
wast2json --enable-tail-call --debug-names $$f; \
190194
done
191195

35 Bytes
Binary file not shown.
35 Bytes
Binary file not shown.
35 Bytes
Binary file not shown.
35 Bytes
Binary file not shown.
35 Bytes
Binary file not shown.
35 Bytes
Binary file not shown.

‎internal/integration_test/spectest/v2/testdata/align.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,10 @@
155155
{"type": "assert_return", "line": 850, "action": {"type": "invoke", "field": "i64_align_switch", "args": [{"type": "i32", "value": "6"}, {"type": "i32", "value": "8"}]}, "expected": [{"type": "i64", "value": "10"}]},
156156
{"type": "module", "line": 854, "filename": "align.107.wasm"},
157157
{"type": "assert_trap", "line": 864, "action": {"type": "invoke", "field": "store", "args": [{"type": "i32", "value": "65532"}, {"type": "i64", "value": "18446744073709551615"}]}, "text": "out of bounds memory access", "expected": []},
158-
{"type": "assert_return", "line": 866, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "65532"}]}, "expected": [{"type": "i32", "value": "0"}]}]}
158+
{"type": "assert_return", "line": 866, "action": {"type": "invoke", "field": "load", "args": [{"type": "i32", "value": "65532"}]}, "expected": [{"type": "i32", "value": "0"}]},
159+
{"type": "assert_invalid", "line": 873, "filename": "align.108.wasm", "text": "alignment must not be larger than natural", "module_type": "binary"},
160+
{"type": "assert_malformed", "line": 892, "filename": "align.109.wasm", "text": "malformed memop flags", "module_type": "binary"},
161+
{"type": "assert_malformed", "line": 911, "filename": "align.110.wasm", "text": "malformed memop flags", "module_type": "binary"},
162+
{"type": "assert_malformed", "line": 930, "filename": "align.111.wasm", "text": "malformed memop flags", "module_type": "binary"},
163+
{"type": "assert_malformed", "line": 949, "filename": "align.112.wasm", "text": "malformed memop flags", "module_type": "binary"},
164+
{"type": "assert_malformed", "line": 968, "filename": "align.113.wasm", "text": "malformed memop flags", "module_type": "binary"}]}

‎internal/integration_test/spectest/v2/testdata/align.wast‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,3 +864,120 @@
864864
(assert_trap (invoke "store" (i32.const 65532) (i64.const -1)) "out of bounds memory access")
865865
;; No memory was changed
866866
(assert_return (invoke "load" (i32.const 65532)) (i32.const 0))
867+
868+
;; Test invalid alignment values that may cause overflow when parsed.
869+
;; These use the binary format, because it stores alignment as a base-2 exponent.
870+
871+
;; Signed 32-bit overflow
872+
(assert_invalid
873+
(module binary
874+
"\00asm" "\01\00\00\00"
875+
"\01\04\01\60\00\00" ;; Type section: 1 type
876+
"\03\02\01\00" ;; Function section: 1 function
877+
"\05\03\01\00\01" ;; Memory section: 1 memory
878+
"\0a\0a\01" ;; Code section: 1 function
879+
880+
;; function 0
881+
"\08\00"
882+
"\41\00" ;; i32.const 0
883+
"\28\1f\00" ;; i32.load offset=0 align=2**31
884+
"\1a" ;; drop
885+
"\0b" ;; end
886+
)
887+
"alignment must not be larger than natural"
888+
)
889+
890+
;; Unsigned 32-bit overflow
891+
(assert_malformed
892+
(module binary
893+
"\00asm" "\01\00\00\00"
894+
"\01\04\01\60\00\00" ;; Type section: 1 type
895+
"\03\02\01\00" ;; Function section: 1 function
896+
"\05\03\01\00\01" ;; Memory section: 1 memory
897+
"\0a\0a\01" ;; Code section: 1 function
898+
899+
;; function 0
900+
"\08\00"
901+
"\41\00" ;; i32.const 0
902+
"\28\20\00" ;; i32.load offset=0 align=2**32
903+
"\1a" ;; drop
904+
"\0b" ;; end
905+
)
906+
"malformed memop flags"
907+
)
908+
909+
;; 32-bit out of range
910+
(assert_malformed
911+
(module binary
912+
"\00asm" "\01\00\00\00"
913+
"\01\04\01\60\00\00" ;; Type section: 1 type
914+
"\03\02\01\00" ;; Function section: 1 function
915+
"\05\03\01\00\01" ;; Memory section: 1 memory
916+
"\0a\0a\01" ;; Code section: 1 function
917+
918+
;; function 0
919+
"\08\00"
920+
"\41\00" ;; i32.const 0
921+
"\28\21\00" ;; i32.load offset=0 align=2**33
922+
"\1a" ;; drop
923+
"\0b" ;; end
924+
)
925+
"malformed memop flags"
926+
)
927+
928+
;; Signed 64-bit overflow
929+
(assert_malformed
930+
(module binary
931+
"\00asm" "\01\00\00\00"
932+
"\01\04\01\60\00\00" ;; Type section: 1 type
933+
"\03\02\01\00" ;; Function section: 1 function
934+
"\05\03\01\00\01" ;; Memory section: 1 memory
935+
"\0a\0a\01" ;; Code section: 1 function
936+
937+
;; function 0
938+
"\08\00"
939+
"\41\00" ;; i32.const 0
940+
"\28\3f\00" ;; i32.load offset=0 align=2**63
941+
"\1a" ;; drop
942+
"\0b" ;; end
943+
)
944+
"malformed memop flags"
945+
)
946+
947+
;; Unsigned 64-bit overflow
948+
(assert_malformed
949+
(module binary
950+
"\00asm" "\01\00\00\00"
951+
"\01\04\01\60\00\00" ;; Type section: 1 type
952+
"\03\02\01\00" ;; Function section: 1 function
953+
"\05\03\01\00\01" ;; Memory section: 1 memory
954+
"\0a\0a\01" ;; Code section: 1 function
955+
956+
;; function 0
957+
"\08\00"
958+
"\41\00" ;; i32.const 0
959+
"\28\40\00" ;; i32.load offset=0 align=2**64
960+
"\1a" ;; drop
961+
"\0b" ;; end
962+
)
963+
"malformed memop flags"
964+
)
965+
966+
;; 64-bit out of range
967+
(assert_malformed
968+
(module binary
969+
"\00asm" "\01\00\00\00"
970+
"\01\04\01\60\00\00" ;; Type section: 1 type
971+
"\03\02\01\00" ;; Function section: 1 function
972+
"\05\03\01\00\01" ;; Memory section: 1 memory
973+
"\0a\0a\01" ;; Code section: 1 function
974+
975+
;; function 0
976+
"\08\00"
977+
"\41\00" ;; i32.const 0
978+
"\28\41\00" ;; i32.load offset=0 align=2**65
979+
"\1a" ;; drop
980+
"\0b" ;; end
981+
)
982+
"malformed memop flags"
983+
)

0 commit comments

Comments
 (0)