Skip to content

Commit

Permalink
Update spectest v2 to latest (#2145)
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <[email protected]>
  • Loading branch information
mathetake authored Mar 12, 2024
1 parent ac1961d commit 4242b5e
Show file tree
Hide file tree
Showing 149 changed files with 1,191 additions and 643 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
steps:
- name: Install latest wast2json
run: | # Needed for build.spectest. wabt includes wast2json.
wabt_version=1.0.33
wabt_version=1.0.34
wabt_url=https://github.com/WebAssembly/wabt/releases/download/${wabt_version}/wabt-${wabt_version}-ubuntu.tar.gz
curl -sSL ${wabt_url} | tar --strip-components 2 -C /usr/local/bin -xzf - wabt-${wabt_version}/bin/wast2json
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ spectest_v1_testdata_dir := $(spectest_v1_dir)/testdata
spec_version_v1 := wg-1.0
spectest_v2_dir := $(spectest_base_dir)/v2
spectest_v2_testdata_dir := $(spectest_v2_dir)/testdata
# Latest draft state as of May 23, 2023.
spec_version_v2 := 2e8912e88a3118a46b90e8ccb659e24b4e8f3c23
# Latest draft state as of March 12, 2024.
spec_version_v2 := 1c5e5d178bd75c79b7a12881c529098beaee2a05
spectest_threads_dir := $(spectest_base_dir)/threads
spectest_threads_testdata_dir := $(spectest_threads_dir)/testdata
# From https://github.com/WebAssembly/threads/tree/upstream-rebuild which has not been merged to main yet.
Expand Down Expand Up @@ -167,8 +167,8 @@ build.spectest.v2: # Note: SIMD cases are placed in the "simd" subdirectory.
@cd $(spectest_v2_testdata_dir) \
&& curl -sSL 'https://api.github.com/repos/WebAssembly/spec/contents/test/core/simd?ref=$(spec_version_v2)' | jq -r '.[]| .download_url' | grep -E ".wast" | xargs -Iurl curl -sJL url -O
@cd $(spectest_v2_testdata_dir) && for f in `find . -name '*.wast'`; do \
wast2json --debug-names --no-check $$f; \
done
wast2json --debug-names --no-check $$f || true; \
done # Ignore the error here as some tests (e.g. comments.wast right now) are not supported by wast2json yet.

# Note: We currently cannot build the "threads" subdirectory that spawns threads due to missing support in wast2json.
# https://github.com/WebAssembly/wabt/issues/2348#issuecomment-1878003959
Expand Down
2 changes: 1 addition & 1 deletion examples/allocation/zig/testdata/greet.zig
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ pub export fn greeting(message: [*]const u8, size: u32) u64 {
// stringToPtr returns a pointer and size pair for the given string in a way
// compatible with WebAssembly numeric types.
pub fn stringToPtr(s: []const u8) u64 {
const p: u64 = @ptrToInt(s.ptr);
const p: u64 = @intFromPtr(s.ptr);
return p << 32 | s.len;
}
6 changes: 3 additions & 3 deletions internal/integration_test/spectest/spectest.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@ func (c command) expectedError() (err error) {
//
// cd testdata; wat2wasm --debug-names spectest.wat
//
// This module is required by some test cases, and instantiated before running cases.
// See https://github.com/WebAssembly/spec/blob/wg-1.0/test/core/imports.wast
// See https://github.com/WebAssembly/spec/blob/wg-1.0/interpreter/script/js.ml#L13-L25
// This module is required by some test cases, and must be instantiated before running cases.
// See https://github.com/WebAssembly/spec/blob/1c5e5d178bd75c79b7a12881c529098beaee2a05/test/core/imports.wast
// See https://github.com/WebAssembly/spec/blob/1c5e5d178bd75c79b7a12881c529098beaee2a05/interpreter/script/js.ml#L33-L50
//
//go:embed testdata/spectest.wasm
var spectestWasm []byte
Expand Down
Binary file modified internal/integration_test/spectest/testdata/spectest.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions internal/integration_test/spectest/testdata/spectest.wat
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module $spectest
(global (export "global_i32") i32 (i32.const 666))
(global (export "global_i64") i64 (i64.const 666))
(global (export "global_f32") f32 (f32.const 666))
(global (export "global_f64") f64 (f64.const 666))
(global (export "global_f32") f32 (f32.const 666.6))
(global (export "global_f64") f64 (f64.const 666.6))

(table (export "table") 10 20 funcref)

Expand Down
Binary file modified internal/integration_test/spectest/v2/testdata/binary.109.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions internal/integration_test/spectest/v2/testdata/binary.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@
{"type": "assert_malformed", "line": 1055, "filename": "binary.107.wasm", "text": "section size mismatch", "module_type": "binary"},
{"type": "module", "line": 1068, "filename": "binary.108.wasm"},
{"type": "assert_malformed", "line": 1086, "filename": "binary.109.wasm", "text": "unexpected end", "module_type": "binary"},
{"type": "module", "line": 1107, "filename": "binary.110.wasm"},
{"type": "assert_malformed", "line": 1121, "filename": "binary.111.wasm", "text": "unexpected content after last section", "module_type": "binary"}]}
{"type": "module", "line": 1119, "filename": "binary.110.wasm"},
{"type": "assert_malformed", "line": 1133, "filename": "binary.111.wasm", "text": "unexpected content after last section", "module_type": "binary"}]}
18 changes: 15 additions & 3 deletions internal/integration_test/spectest/v2/testdata/binary.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,19 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01" ;; type section
"\01\25\0c" ;; type section
"\60\00\00" ;; type 0
"\60\00\00" ;; type 1
"\60\00\00" ;; type 2
"\60\00\00" ;; type 3
"\60\00\00" ;; type 4
"\60\00\00" ;; type 5
"\60\00\00" ;; type 6
"\60\00\00" ;; type 7
"\60\00\00" ;; type 8
"\60\00\00" ;; type 9
"\60\00\00" ;; type 10
"\60\00\00" ;; type 11
"\03\02\01\00" ;; func section
"\0a\13\01" ;; code section
"\11\00" ;; func 0
Expand All @@ -1097,8 +1108,9 @@
"\0e\01" ;; br_table with inconsistent target count (1 declared, 2 given)
"\00" ;; break depth 0
"\01" ;; break depth 1
"\02" ;; break depth for default
"\0b\0b\0b" ;; end
"\02" ;; break depth for default, interpreted as a block
"\0b" ;; end, interpreted as type 11 for the block
"\0b\0b" ;; end
)
"unexpected end"
)
Expand Down
Binary file modified internal/integration_test/spectest/v2/testdata/comments.wast
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.56.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.57.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.58.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.59.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.60.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.61.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.62.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.63.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.64.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.65.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.66.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.67.wasm
Binary file not shown.
Binary file modified internal/integration_test/spectest/v2/testdata/elem.68.wasm
Binary file not shown.
73 changes: 36 additions & 37 deletions internal/integration_test/spectest/v2/testdata/elem.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,40 +62,39 @@
{"type": "assert_invalid", "line": 511, "filename": "elem.53.wasm", "text": "type mismatch", "module_type": "binary"},
{"type": "assert_invalid", "line": 519, "filename": "elem.54.wasm", "text": "type mismatch", "module_type": "binary"},
{"type": "assert_invalid", "line": 527, "filename": "elem.55.wasm", "text": "constant expression required", "module_type": "binary"},
{"type": "assert_invalid", "line": 536, "filename": "elem.56.wasm", "text": "constant expression required", "module_type": "binary"},
{"type": "module", "line": 545, "filename": "elem.57.wasm"},
{"type": "assert_return", "line": 556, "action": {"type": "invoke", "field": "call-overwritten", "args": []}, "expected": [{"type": "i32", "value": "66"}]},
{"type": "module", "line": 558, "filename": "elem.58.wasm"},
{"type": "assert_return", "line": 569, "action": {"type": "invoke", "field": "call-overwritten-element", "args": []}, "expected": [{"type": "i32", "value": "66"}]},
{"type": "module", "line": 573, "name": "$module1", "filename": "elem.59.wasm"},
{"type": "register", "line": 591, "name": "$module1", "as": "module1"},
{"type": "assert_trap", "line": 593, "action": {"type": "invoke", "module": "$module1", "field": "call-7", "args": []}, "text": "uninitialized element", "expected": [{"type": "i32"}]},
{"type": "assert_return", "line": 594, "action": {"type": "invoke", "module": "$module1", "field": "call-8", "args": []}, "expected": [{"type": "i32", "value": "65"}]},
{"type": "assert_return", "line": 595, "action": {"type": "invoke", "module": "$module1", "field": "call-9", "args": []}, "expected": [{"type": "i32", "value": "66"}]},
{"type": "module", "line": 597, "name": "$module2", "filename": "elem.60.wasm"},
{"type": "assert_return", "line": 606, "action": {"type": "invoke", "module": "$module1", "field": "call-7", "args": []}, "expected": [{"type": "i32", "value": "67"}]},
{"type": "assert_return", "line": 607, "action": {"type": "invoke", "module": "$module1", "field": "call-8", "args": []}, "expected": [{"type": "i32", "value": "68"}]},
{"type": "assert_return", "line": 608, "action": {"type": "invoke", "module": "$module1", "field": "call-9", "args": []}, "expected": [{"type": "i32", "value": "66"}]},
{"type": "module", "line": 610, "name": "$module3", "filename": "elem.61.wasm"},
{"type": "assert_return", "line": 619, "action": {"type": "invoke", "module": "$module1", "field": "call-7", "args": []}, "expected": [{"type": "i32", "value": "67"}]},
{"type": "assert_return", "line": 620, "action": {"type": "invoke", "module": "$module1", "field": "call-8", "args": []}, "expected": [{"type": "i32", "value": "69"}]},
{"type": "assert_return", "line": 621, "action": {"type": "invoke", "module": "$module1", "field": "call-9", "args": []}, "expected": [{"type": "i32", "value": "70"}]},
{"type": "assert_invalid", "line": 626, "filename": "elem.62.wasm", "text": "type mismatch", "module_type": "binary"},
{"type": "assert_invalid", "line": 631, "filename": "elem.63.wasm", "text": "type mismatch", "module_type": "binary"},
{"type": "assert_invalid", "line": 636, "filename": "elem.64.wasm", "text": "type mismatch", "module_type": "binary"},
{"type": "assert_invalid", "line": 645, "filename": "elem.65.wasm", "text": "type mismatch", "module_type": "binary"},
{"type": "module", "line": 654, "name": "$m", "filename": "elem.66.wasm"},
{"type": "register", "line": 661, "name": "$m", "as": "exporter"},
{"type": "assert_return", "line": 663, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "externref", "value": "null"}]},
{"type": "assert_return", "line": 664, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "1"}]}, "expected": [{"type": "externref", "value": "null"}]},
{"type": "assert_return", "line": 666, "action": {"type": "invoke", "module": "$m", "field": "set", "args": [{"type": "i32", "value": "0"}, {"type": "externref", "value": "42"}]}, "expected": []},
{"type": "assert_return", "line": 667, "action": {"type": "invoke", "module": "$m", "field": "set", "args": [{"type": "i32", "value": "1"}, {"type": "externref", "value": "137"}]}, "expected": []},
{"type": "assert_return", "line": 669, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "externref", "value": "42"}]},
{"type": "assert_return", "line": 670, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "1"}]}, "expected": [{"type": "externref", "value": "137"}]},
{"type": "module", "line": 672, "filename": "elem.67.wasm"},
{"type": "assert_return", "line": 676, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "externref", "value": "null"}]},
{"type": "assert_return", "line": 677, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "1"}]}, "expected": [{"type": "externref", "value": "137"}]},
{"type": "module", "line": 681, "name": "$module4", "filename": "elem.68.wasm"},
{"type": "register", "line": 688, "name": "$module4", "as": "module4"},
{"type": "module", "line": 690, "filename": "elem.69.wasm"},
{"type": "assert_return", "line": 700, "action": {"type": "invoke", "field": "call_imported_elem", "args": []}, "expected": [{"type": "i32", "value": "42"}]}]}
{"type": "module", "line": 537, "filename": "elem.56.wasm"},
{"type": "assert_return", "line": 548, "action": {"type": "invoke", "field": "call-overwritten", "args": []}, "expected": [{"type": "i32", "value": "66"}]},
{"type": "module", "line": 550, "filename": "elem.57.wasm"},
{"type": "assert_return", "line": 561, "action": {"type": "invoke", "field": "call-overwritten-element", "args": []}, "expected": [{"type": "i32", "value": "66"}]},
{"type": "module", "line": 565, "name": "$module1", "filename": "elem.58.wasm"},
{"type": "register", "line": 583, "name": "$module1", "as": "module1"},
{"type": "assert_trap", "line": 585, "action": {"type": "invoke", "module": "$module1", "field": "call-7", "args": []}, "text": "uninitialized element", "expected": [{"type": "i32"}]},
{"type": "assert_return", "line": 586, "action": {"type": "invoke", "module": "$module1", "field": "call-8", "args": []}, "expected": [{"type": "i32", "value": "65"}]},
{"type": "assert_return", "line": 587, "action": {"type": "invoke", "module": "$module1", "field": "call-9", "args": []}, "expected": [{"type": "i32", "value": "66"}]},
{"type": "module", "line": 589, "name": "$module2", "filename": "elem.59.wasm"},
{"type": "assert_return", "line": 598, "action": {"type": "invoke", "module": "$module1", "field": "call-7", "args": []}, "expected": [{"type": "i32", "value": "67"}]},
{"type": "assert_return", "line": 599, "action": {"type": "invoke", "module": "$module1", "field": "call-8", "args": []}, "expected": [{"type": "i32", "value": "68"}]},
{"type": "assert_return", "line": 600, "action": {"type": "invoke", "module": "$module1", "field": "call-9", "args": []}, "expected": [{"type": "i32", "value": "66"}]},
{"type": "module", "line": 602, "name": "$module3", "filename": "elem.60.wasm"},
{"type": "assert_return", "line": 611, "action": {"type": "invoke", "module": "$module1", "field": "call-7", "args": []}, "expected": [{"type": "i32", "value": "67"}]},
{"type": "assert_return", "line": 612, "action": {"type": "invoke", "module": "$module1", "field": "call-8", "args": []}, "expected": [{"type": "i32", "value": "69"}]},
{"type": "assert_return", "line": 613, "action": {"type": "invoke", "module": "$module1", "field": "call-9", "args": []}, "expected": [{"type": "i32", "value": "70"}]},
{"type": "assert_invalid", "line": 618, "filename": "elem.61.wasm", "text": "type mismatch", "module_type": "binary"},
{"type": "assert_invalid", "line": 623, "filename": "elem.62.wasm", "text": "type mismatch", "module_type": "binary"},
{"type": "assert_invalid", "line": 628, "filename": "elem.63.wasm", "text": "type mismatch", "module_type": "binary"},
{"type": "assert_invalid", "line": 637, "filename": "elem.64.wasm", "text": "type mismatch", "module_type": "binary"},
{"type": "module", "line": 646, "name": "$m", "filename": "elem.65.wasm"},
{"type": "register", "line": 653, "name": "$m", "as": "exporter"},
{"type": "assert_return", "line": 655, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "externref", "value": "null"}]},
{"type": "assert_return", "line": 656, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "1"}]}, "expected": [{"type": "externref", "value": "null"}]},
{"type": "assert_return", "line": 658, "action": {"type": "invoke", "module": "$m", "field": "set", "args": [{"type": "i32", "value": "0"}, {"type": "externref", "value": "42"}]}, "expected": []},
{"type": "assert_return", "line": 659, "action": {"type": "invoke", "module": "$m", "field": "set", "args": [{"type": "i32", "value": "1"}, {"type": "externref", "value": "137"}]}, "expected": []},
{"type": "assert_return", "line": 661, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "externref", "value": "42"}]},
{"type": "assert_return", "line": 662, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "1"}]}, "expected": [{"type": "externref", "value": "137"}]},
{"type": "module", "line": 664, "filename": "elem.66.wasm"},
{"type": "assert_return", "line": 668, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "0"}]}, "expected": [{"type": "externref", "value": "null"}]},
{"type": "assert_return", "line": 669, "action": {"type": "invoke", "module": "$m", "field": "get", "args": [{"type": "i32", "value": "1"}]}, "expected": [{"type": "externref", "value": "137"}]},
{"type": "module", "line": 673, "name": "$module4", "filename": "elem.67.wasm"},
{"type": "register", "line": 680, "name": "$module4", "as": "module4"},
{"type": "module", "line": 682, "filename": "elem.68.wasm"},
{"type": "assert_return", "line": 692, "action": {"type": "invoke", "field": "call_imported_elem", "args": []}, "expected": [{"type": "i32", "value": "42"}]}]}
8 changes: 0 additions & 8 deletions internal/integration_test/spectest/v2/testdata/elem.wast
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,6 @@
"constant expression required"
)

(assert_invalid
(module
(table 1 funcref)
(elem (i32.const 0) funcref (item (i32.add (i32.const 0) (i32.const 1))))
)
"constant expression required"
)

;; Two elements target the same slot

(module
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const _100))
(global f32 (f32.const nan:0x80_0000))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const +_100))
(global f64 (f64.const _100))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const -_100))
(global f64 (f64.const +_100))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 99_))
(global f64 (f64.const -_100))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1__000))
(global f64 (f64.const 99_))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const _1.0))
(global f64 (f64.const 1__000))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1.0_))
(global f64 (f64.const _1.0))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1_.0))
(global f64 (f64.const 1.0_))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1._0))
(global f64 (f64.const 1_.0))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const _1e1))
(global f64 (f64.const 1._0))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1e1_))
(global f64 (f64.const _1e1))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1_e1))
(global f64 (f64.const 1e1_))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1e_1))
(global f64 (f64.const 1_e1))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const _1.0e1))
(global f64 (f64.const 1e_1))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1.0e1_))
(global f64 (f64.const _1.0e1))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1.0_e1))
(global f64 (f64.const 1.0e1_))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1.0e_1))
(global f64 (f64.const 1.0_e1))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1.0e+_1))
(global f64 (f64.const 1.0e_1))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 1.0e_+1))
(global f64 (f64.const 1.0e+_1))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const _0x100))
(global f64 (f64.const 1.0e_+1))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 0_x100))
(global f64 (f64.const _0x100))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 0x_100))
(global f64 (f64.const 0_x100))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 0x00_))
(global f64 (f64.const 0x_100))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 0xff__ffff))
(global f64 (f64.const 0x00_))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 0x_1.0))
(global f64 (f64.const 0xff__ffff))
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(global f64 (f64.const 0x1.0_))
(global f64 (f64.const 0x_1.0))
Loading

0 comments on commit 4242b5e

Please sign in to comment.