From de0d556e72bc90f58077f05a6232b1083503f89a Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Sat, 7 Dec 2024 00:40:43 +0100 Subject: [PATCH] chore: move wasm-testsuite to a seperate repo & update tests Signed-off-by: Henry Gressmann --- CHANGELOG.md | 2 +- Cargo.lock | 168 ++++-------------- crates/tinywasm/Cargo.toml | 5 +- crates/tinywasm/tests/generated/wasm-2.csv | 2 +- .../tests/generated/wasm-annotations.csv | 2 +- .../tests/generated/wasm-multi-memory.csv | 2 +- crates/tinywasm/tests/test-wasm-1.rs | 23 +-- crates/tinywasm/tests/test-wasm-2.rs | 19 +- .../tinywasm/tests/test-wasm-annotations.rs | 21 +-- .../tests/test-wasm-custom-page-sizes.rs | 13 -- .../tests/test-wasm-extended-const.rs | 19 +- crates/tinywasm/tests/test-wasm-memory64.rs | 14 +- .../tinywasm/tests/test-wasm-multi-memory.rs | 21 +-- .../tinywasm/tests/test-wasm-relaxed-simd.rs | 13 ++ crates/tinywasm/tests/test-wasm-simd.rs | 20 --- crates/tinywasm/tests/testsuite/indexmap.rs | 31 ---- crates/tinywasm/tests/testsuite/mod.rs | 16 +- crates/tinywasm/tests/testsuite/run.rs | 145 ++++++++------- crates/tinywasm/tests/testsuite/util.rs | 4 +- crates/wasm-testsuite/Cargo.toml | 19 -- crates/wasm-testsuite/README.md | 20 --- crates/wasm-testsuite/data | 1 - crates/wasm-testsuite/lib.rs | 86 --------- .../custom-page-sizes-invalid.wast | 112 ------------ .../custom-page-sizes/custom-page-sizes.wast | 110 ------------ 25 files changed, 176 insertions(+), 712 deletions(-) create mode 100644 crates/tinywasm/tests/test-wasm-relaxed-simd.rs delete mode 100644 crates/tinywasm/tests/test-wasm-simd.rs delete mode 100644 crates/tinywasm/tests/testsuite/indexmap.rs delete mode 100644 crates/wasm-testsuite/Cargo.toml delete mode 100644 crates/wasm-testsuite/README.md delete mode 160000 crates/wasm-testsuite/data delete mode 100644 crates/wasm-testsuite/lib.rs delete mode 100644 crates/wasm-testsuite/tests/proposals/custom-page-sizes/custom-page-sizes-invalid.wast delete mode 100644 crates/wasm-testsuite/tests/proposals/custom-page-sizes/custom-page-sizes.wast diff --git a/CHANGELOG.md b/CHANGELOG.md index b84e6ba..a660685 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - **Breaking:**: New backwards-incompatible version of the twasm format (upgraded `rkyv` to 0.8.0) -- Increased MSRV to 1.81.0 +- Increased MSRV to 1.83.0 ### Fixed diff --git a/Cargo.lock b/Cargo.lock index bc521f0..7e6cacc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,25 +66,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bstr" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" -dependencies = [ - "memchr", - "serde", -] - [[package]] name = "bumpalo" version = "3.16.0" @@ -161,18 +142,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.22" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69371e34337c4c984bbe322360c2547210bf632eb2814bbe78a6e87a2935bd2b" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.22" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e24c1b4099818523236a8ca881d2b45db98dadfb4625cf6608c12069fcbbde1" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstyle", "clap_lex", @@ -180,18 +161,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" - -[[package]] -name = "cpufeatures" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" -dependencies = [ - "libc", -] +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "criterion" @@ -259,26 +231,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - [[package]] name = "either" version = "1.13.0" @@ -314,29 +266,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "globset" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" -dependencies = [ - "aho-corasick", - "bstr", - "log", - "regex-automata", - "regex-syntax", -] - [[package]] name = "half" version = "2.4.1" @@ -365,6 +294,25 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "include_dir" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" +dependencies = [ + "include_dir_macros", +] + +[[package]] +name = "include_dir_macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "indenter" version = "0.3.3" @@ -629,41 +577,6 @@ dependencies = [ "syn", ] -[[package]] -name = "rust-embed" -version = "8.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa66af4a4fdd5e7ebc276f115e895611a34739a9c1c01028383d612d550953c0" -dependencies = [ - "rust-embed-impl", - "rust-embed-utils", - "walkdir", -] - -[[package]] -name = "rust-embed-impl" -version = "8.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6125dbc8867951125eec87294137f4e9c2c96566e61bf72c45095a7c77761478" -dependencies = [ - "proc-macro2", - "quote", - "rust-embed-utils", - "syn", - "walkdir", -] - -[[package]] -name = "rust-embed-utils" -version = "8.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5347777e9aacb56039b0e1f28785929a8a3b709e87482e7442c72e7c12529d" -dependencies = [ - "globset", - "sha2", - "walkdir", -] - [[package]] name = "ryu" version = "1.0.18" @@ -717,17 +630,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "simdutf8" version = "0.1.5" @@ -785,6 +687,7 @@ version = "0.9.0-alpha.0" dependencies = [ "criterion", "eyre", + "indexmap", "libm", "log", "owo-colors", @@ -836,12 +739,6 @@ dependencies = [ "rkyv", ] -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - [[package]] name = "unicode-ident" version = "1.0.14" @@ -860,12 +757,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - [[package]] name = "walkdir" version = "2.5.0" @@ -888,9 +779,12 @@ dependencies = [ [[package]] name = "wasm-testsuite" -version = "0.6.0-alpha.0" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dc81f607820a4f651559ad68709106d53bf50c20f01effe90f4da6954d4885d" dependencies = [ - "rust-embed", + "include_dir", + "wast", ] [[package]] diff --git a/crates/tinywasm/Cargo.toml b/crates/tinywasm/Cargo.toml index d111e89..80f148c 100644 --- a/crates/tinywasm/Cargo.toml +++ b/crates/tinywasm/Cargo.toml @@ -20,7 +20,8 @@ tinywasm-types={version="0.9.0-alpha.0", path="../types", default-features=false libm={version="0.2", default-features=false} [dev-dependencies] -wasm-testsuite={path="../wasm-testsuite"} +wasm-testsuite={version="0.3.2"} +indexmap="2.7" wast={workspace=true} eyre={workspace=true} pretty_env_logger={workspace=true} @@ -67,7 +68,7 @@ harness=false test=false [[test]] -name="test-wasm-simd" +name="test-wasm-relaxed-simd" harness=false test=false diff --git a/crates/tinywasm/tests/generated/wasm-2.csv b/crates/tinywasm/tests/generated/wasm-2.csv index a001172..b0949ec 100644 --- a/crates/tinywasm/tests/generated/wasm-2.csv +++ b/crates/tinywasm/tests/generated/wasm-2.csv @@ -10,4 +10,4 @@ 0.6.1,20278,0,[{"name":"address.wast","passed":260,"failed":0},{"name":"align.wast","passed":162,"failed":0},{"name":"binary-leb128.wast","passed":91,"failed":0},{"name":"binary.wast","passed":112,"failed":0},{"name":"block.wast","passed":223,"failed":0},{"name":"br.wast","passed":97,"failed":0},{"name":"br_if.wast","passed":118,"failed":0},{"name":"br_table.wast","passed":174,"failed":0},{"name":"call.wast","passed":91,"failed":0},{"name":"call_indirect.wast","passed":170,"failed":0},{"name":"comments.wast","passed":8,"failed":0},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":619,"failed":0},{"name":"custom.wast","passed":11,"failed":0},{"name":"data.wast","passed":61,"failed":0},{"name":"elem.wast","passed":98,"failed":0},{"name":"endianness.wast","passed":69,"failed":0},{"name":"exports.wast","passed":96,"failed":0},{"name":"f32.wast","passed":2514,"failed":0},{"name":"f32_bitwise.wast","passed":364,"failed":0},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":2514,"failed":0},{"name":"f64_bitwise.wast","passed":364,"failed":0},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":8,"failed":0},{"name":"float_exprs.wast","passed":900,"failed":0},{"name":"float_literals.wast","passed":179,"failed":0},{"name":"float_memory.wast","passed":90,"failed":0},{"name":"float_misc.wast","passed":441,"failed":0},{"name":"forward.wast","passed":5,"failed":0},{"name":"func.wast","passed":172,"failed":0},{"name":"func_ptrs.wast","passed":36,"failed":0},{"name":"global.wast","passed":110,"failed":0},{"name":"i32.wast","passed":460,"failed":0},{"name":"i64.wast","passed":416,"failed":0},{"name":"if.wast","passed":241,"failed":0},{"name":"imports.wast","passed":186,"failed":0},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":108,"failed":0},{"name":"int_literals.wast","passed":51,"failed":0},{"name":"labels.wast","passed":29,"failed":0},{"name":"left-to-right.wast","passed":96,"failed":0},{"name":"linking.wast","passed":132,"failed":0},{"name":"load.wast","passed":97,"failed":0},{"name":"local_get.wast","passed":36,"failed":0},{"name":"local_set.wast","passed":53,"failed":0},{"name":"local_tee.wast","passed":97,"failed":0},{"name":"loop.wast","passed":120,"failed":0},{"name":"memory.wast","passed":79,"failed":0},{"name":"memory_grow.wast","passed":96,"failed":0},{"name":"memory_redundancy.wast","passed":8,"failed":0},{"name":"memory_size.wast","passed":42,"failed":0},{"name":"memory_trap.wast","passed":182,"failed":0},{"name":"names.wast","passed":486,"failed":0},{"name":"nop.wast","passed":88,"failed":0},{"name":"return.wast","passed":84,"failed":0},{"name":"select.wast","passed":148,"failed":0},{"name":"skip-stack-guard-page.wast","passed":11,"failed":0},{"name":"stack.wast","passed":7,"failed":0},{"name":"start.wast","passed":20,"failed":0},{"name":"store.wast","passed":68,"failed":0},{"name":"switch.wast","passed":28,"failed":0},{"name":"table.wast","passed":19,"failed":0},{"name":"token.wast","passed":58,"failed":0},{"name":"traps.wast","passed":36,"failed":0},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":64,"failed":0},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unreached-valid.wast","passed":7,"failed":0},{"name":"unwind.wast","passed":50,"failed":0},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}] 0.7.0,20278,0,[{"name":"address.wast","passed":260,"failed":0},{"name":"align.wast","passed":162,"failed":0},{"name":"binary-leb128.wast","passed":91,"failed":0},{"name":"binary.wast","passed":112,"failed":0},{"name":"block.wast","passed":223,"failed":0},{"name":"br.wast","passed":97,"failed":0},{"name":"br_if.wast","passed":118,"failed":0},{"name":"br_table.wast","passed":174,"failed":0},{"name":"call.wast","passed":91,"failed":0},{"name":"call_indirect.wast","passed":170,"failed":0},{"name":"comments.wast","passed":8,"failed":0},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":619,"failed":0},{"name":"custom.wast","passed":11,"failed":0},{"name":"data.wast","passed":61,"failed":0},{"name":"elem.wast","passed":98,"failed":0},{"name":"endianness.wast","passed":69,"failed":0},{"name":"exports.wast","passed":96,"failed":0},{"name":"f32.wast","passed":2514,"failed":0},{"name":"f32_bitwise.wast","passed":364,"failed":0},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":2514,"failed":0},{"name":"f64_bitwise.wast","passed":364,"failed":0},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":8,"failed":0},{"name":"float_exprs.wast","passed":900,"failed":0},{"name":"float_literals.wast","passed":179,"failed":0},{"name":"float_memory.wast","passed":90,"failed":0},{"name":"float_misc.wast","passed":441,"failed":0},{"name":"forward.wast","passed":5,"failed":0},{"name":"func.wast","passed":172,"failed":0},{"name":"func_ptrs.wast","passed":36,"failed":0},{"name":"global.wast","passed":110,"failed":0},{"name":"i32.wast","passed":460,"failed":0},{"name":"i64.wast","passed":416,"failed":0},{"name":"if.wast","passed":241,"failed":0},{"name":"imports.wast","passed":186,"failed":0},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":108,"failed":0},{"name":"int_literals.wast","passed":51,"failed":0},{"name":"labels.wast","passed":29,"failed":0},{"name":"left-to-right.wast","passed":96,"failed":0},{"name":"linking.wast","passed":132,"failed":0},{"name":"load.wast","passed":97,"failed":0},{"name":"local_get.wast","passed":36,"failed":0},{"name":"local_set.wast","passed":53,"failed":0},{"name":"local_tee.wast","passed":97,"failed":0},{"name":"loop.wast","passed":120,"failed":0},{"name":"memory.wast","passed":79,"failed":0},{"name":"memory_grow.wast","passed":96,"failed":0},{"name":"memory_redundancy.wast","passed":8,"failed":0},{"name":"memory_size.wast","passed":42,"failed":0},{"name":"memory_trap.wast","passed":182,"failed":0},{"name":"names.wast","passed":486,"failed":0},{"name":"nop.wast","passed":88,"failed":0},{"name":"return.wast","passed":84,"failed":0},{"name":"select.wast","passed":148,"failed":0},{"name":"skip-stack-guard-page.wast","passed":11,"failed":0},{"name":"stack.wast","passed":7,"failed":0},{"name":"start.wast","passed":20,"failed":0},{"name":"store.wast","passed":68,"failed":0},{"name":"switch.wast","passed":28,"failed":0},{"name":"table.wast","passed":19,"failed":0},{"name":"token.wast","passed":58,"failed":0},{"name":"traps.wast","passed":36,"failed":0},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":64,"failed":0},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unreached-valid.wast","passed":7,"failed":0},{"name":"unwind.wast","passed":50,"failed":0},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}] 0.8.0,28008,0,[{"name":"address.wast","passed":260,"failed":0},{"name":"align.wast","passed":162,"failed":0},{"name":"binary-leb128.wast","passed":91,"failed":0},{"name":"binary.wast","passed":128,"failed":0},{"name":"block.wast","passed":223,"failed":0},{"name":"br.wast","passed":97,"failed":0},{"name":"br_if.wast","passed":118,"failed":0},{"name":"br_table.wast","passed":174,"failed":0},{"name":"bulk.wast","passed":117,"failed":0},{"name":"call.wast","passed":91,"failed":0},{"name":"call_indirect.wast","passed":170,"failed":0},{"name":"comments.wast","passed":8,"failed":0},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":619,"failed":0},{"name":"custom.wast","passed":11,"failed":0},{"name":"data.wast","passed":61,"failed":0},{"name":"elem.wast","passed":98,"failed":0},{"name":"endianness.wast","passed":69,"failed":0},{"name":"exports.wast","passed":96,"failed":0},{"name":"f32.wast","passed":2514,"failed":0},{"name":"f32_bitwise.wast","passed":364,"failed":0},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":2514,"failed":0},{"name":"f64_bitwise.wast","passed":364,"failed":0},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":8,"failed":0},{"name":"float_exprs.wast","passed":927,"failed":0},{"name":"float_literals.wast","passed":179,"failed":0},{"name":"float_memory.wast","passed":90,"failed":0},{"name":"float_misc.wast","passed":471,"failed":0},{"name":"forward.wast","passed":5,"failed":0},{"name":"func.wast","passed":172,"failed":0},{"name":"func_ptrs.wast","passed":36,"failed":0},{"name":"global.wast","passed":110,"failed":0},{"name":"i32.wast","passed":460,"failed":0},{"name":"i64.wast","passed":416,"failed":0},{"name":"if.wast","passed":241,"failed":0},{"name":"imports.wast","passed":178,"failed":0},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":108,"failed":0},{"name":"int_literals.wast","passed":51,"failed":0},{"name":"labels.wast","passed":29,"failed":0},{"name":"left-to-right.wast","passed":96,"failed":0},{"name":"linking.wast","passed":132,"failed":0},{"name":"load.wast","passed":97,"failed":0},{"name":"local_get.wast","passed":36,"failed":0},{"name":"local_set.wast","passed":53,"failed":0},{"name":"local_tee.wast","passed":97,"failed":0},{"name":"loop.wast","passed":120,"failed":0},{"name":"memory.wast","passed":88,"failed":0},{"name":"memory_copy.wast","passed":4450,"failed":0},{"name":"memory_fill.wast","passed":100,"failed":0},{"name":"memory_grow.wast","passed":104,"failed":0},{"name":"memory_init.wast","passed":240,"failed":0},{"name":"memory_redundancy.wast","passed":8,"failed":0},{"name":"memory_size.wast","passed":42,"failed":0},{"name":"memory_trap.wast","passed":182,"failed":0},{"name":"names.wast","passed":486,"failed":0},{"name":"nop.wast","passed":88,"failed":0},{"name":"obsolete-keywords.wast","passed":11,"failed":0},{"name":"ref_func.wast","passed":17,"failed":0},{"name":"ref_is_null.wast","passed":16,"failed":0},{"name":"ref_null.wast","passed":3,"failed":0},{"name":"return.wast","passed":84,"failed":0},{"name":"select.wast","passed":148,"failed":0},{"name":"skip-stack-guard-page.wast","passed":11,"failed":0},{"name":"stack.wast","passed":7,"failed":0},{"name":"start.wast","passed":20,"failed":0},{"name":"store.wast","passed":68,"failed":0},{"name":"switch.wast","passed":28,"failed":0},{"name":"table-sub.wast","passed":2,"failed":0},{"name":"table.wast","passed":19,"failed":0},{"name":"table_copy.wast","passed":1728,"failed":0},{"name":"table_fill.wast","passed":45,"failed":0},{"name":"table_get.wast","passed":16,"failed":0},{"name":"table_grow.wast","passed":58,"failed":0},{"name":"table_init.wast","passed":780,"failed":0},{"name":"table_set.wast","passed":26,"failed":0},{"name":"table_size.wast","passed":39,"failed":0},{"name":"token.wast","passed":58,"failed":0},{"name":"traps.wast","passed":36,"failed":0},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":64,"failed":0},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unreached-valid.wast","passed":7,"failed":0},{"name":"unwind.wast","passed":50,"failed":0},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}] -0.9.0-alpha.0,28010,0,[{"name":"address.wast","passed":260,"failed":0},{"name":"align.wast","passed":162,"failed":0},{"name":"binary-leb128.wast","passed":91,"failed":0},{"name":"binary.wast","passed":128,"failed":0},{"name":"block.wast","passed":223,"failed":0},{"name":"br.wast","passed":97,"failed":0},{"name":"br_if.wast","passed":118,"failed":0},{"name":"br_table.wast","passed":174,"failed":0},{"name":"bulk.wast","passed":117,"failed":0},{"name":"call.wast","passed":91,"failed":0},{"name":"call_indirect.wast","passed":172,"failed":0},{"name":"comments.wast","passed":8,"failed":0},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":619,"failed":0},{"name":"custom.wast","passed":11,"failed":0},{"name":"data.wast","passed":61,"failed":0},{"name":"elem.wast","passed":98,"failed":0},{"name":"endianness.wast","passed":69,"failed":0},{"name":"exports.wast","passed":96,"failed":0},{"name":"f32.wast","passed":2514,"failed":0},{"name":"f32_bitwise.wast","passed":364,"failed":0},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":2514,"failed":0},{"name":"f64_bitwise.wast","passed":364,"failed":0},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":8,"failed":0},{"name":"float_exprs.wast","passed":927,"failed":0},{"name":"float_literals.wast","passed":179,"failed":0},{"name":"float_memory.wast","passed":90,"failed":0},{"name":"float_misc.wast","passed":471,"failed":0},{"name":"forward.wast","passed":5,"failed":0},{"name":"func.wast","passed":172,"failed":0},{"name":"func_ptrs.wast","passed":36,"failed":0},{"name":"global.wast","passed":110,"failed":0},{"name":"i32.wast","passed":460,"failed":0},{"name":"i64.wast","passed":416,"failed":0},{"name":"if.wast","passed":241,"failed":0},{"name":"imports.wast","passed":178,"failed":0},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":108,"failed":0},{"name":"int_literals.wast","passed":51,"failed":0},{"name":"labels.wast","passed":29,"failed":0},{"name":"left-to-right.wast","passed":96,"failed":0},{"name":"linking.wast","passed":132,"failed":0},{"name":"load.wast","passed":97,"failed":0},{"name":"local_get.wast","passed":36,"failed":0},{"name":"local_set.wast","passed":53,"failed":0},{"name":"local_tee.wast","passed":97,"failed":0},{"name":"loop.wast","passed":120,"failed":0},{"name":"memory.wast","passed":88,"failed":0},{"name":"memory_copy.wast","passed":4450,"failed":0},{"name":"memory_fill.wast","passed":100,"failed":0},{"name":"memory_grow.wast","passed":104,"failed":0},{"name":"memory_init.wast","passed":240,"failed":0},{"name":"memory_redundancy.wast","passed":8,"failed":0},{"name":"memory_size.wast","passed":42,"failed":0},{"name":"memory_trap.wast","passed":182,"failed":0},{"name":"names.wast","passed":486,"failed":0},{"name":"nop.wast","passed":88,"failed":0},{"name":"obsolete-keywords.wast","passed":11,"failed":0},{"name":"ref_func.wast","passed":17,"failed":0},{"name":"ref_is_null.wast","passed":16,"failed":0},{"name":"ref_null.wast","passed":3,"failed":0},{"name":"return.wast","passed":84,"failed":0},{"name":"select.wast","passed":148,"failed":0},{"name":"skip-stack-guard-page.wast","passed":11,"failed":0},{"name":"stack.wast","passed":7,"failed":0},{"name":"start.wast","passed":20,"failed":0},{"name":"store.wast","passed":68,"failed":0},{"name":"switch.wast","passed":28,"failed":0},{"name":"table-sub.wast","passed":2,"failed":0},{"name":"table.wast","passed":19,"failed":0},{"name":"table_copy.wast","passed":1728,"failed":0},{"name":"table_fill.wast","passed":45,"failed":0},{"name":"table_get.wast","passed":16,"failed":0},{"name":"table_grow.wast","passed":58,"failed":0},{"name":"table_init.wast","passed":780,"failed":0},{"name":"table_set.wast","passed":26,"failed":0},{"name":"table_size.wast","passed":39,"failed":0},{"name":"token.wast","passed":58,"failed":0},{"name":"traps.wast","passed":36,"failed":0},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":64,"failed":0},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unreached-valid.wast","passed":7,"failed":0},{"name":"unwind.wast","passed":50,"failed":0},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}] +0.9.0-alpha.0,27826,0,[{"name":"address.wast","passed":260,"failed":0},{"name":"align.wast","passed":156,"failed":0},{"name":"binary-leb128.wast","passed":81,"failed":0},{"name":"binary.wast","passed":162,"failed":0},{"name":"block.wast","passed":223,"failed":0},{"name":"br.wast","passed":97,"failed":0},{"name":"br_if.wast","passed":118,"failed":0},{"name":"br_table.wast","passed":174,"failed":0},{"name":"bulk.wast","passed":117,"failed":0},{"name":"call.wast","passed":91,"failed":0},{"name":"call_indirect.wast","passed":169,"failed":0},{"name":"comments.wast","passed":4,"failed":0},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":619,"failed":0},{"name":"custom.wast","passed":11,"failed":0},{"name":"data.wast","passed":58,"failed":0},{"name":"elem.wast","passed":74,"failed":0},{"name":"endianness.wast","passed":69,"failed":0},{"name":"exports.wast","passed":96,"failed":0},{"name":"f32.wast","passed":2514,"failed":0},{"name":"f32_bitwise.wast","passed":364,"failed":0},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":2514,"failed":0},{"name":"f64_bitwise.wast","passed":364,"failed":0},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":8,"failed":0},{"name":"float_exprs.wast","passed":900,"failed":0},{"name":"float_literals.wast","passed":161,"failed":0},{"name":"float_memory.wast","passed":90,"failed":0},{"name":"float_misc.wast","passed":441,"failed":0},{"name":"forward.wast","passed":5,"failed":0},{"name":"func.wast","passed":172,"failed":0},{"name":"func_ptrs.wast","passed":36,"failed":0},{"name":"global.wast","passed":108,"failed":0},{"name":"i32.wast","passed":460,"failed":0},{"name":"i64.wast","passed":416,"failed":0},{"name":"if.wast","passed":239,"failed":0},{"name":"imports.wast","passed":183,"failed":0},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":108,"failed":0},{"name":"int_literals.wast","passed":51,"failed":0},{"name":"labels.wast","passed":29,"failed":0},{"name":"left-to-right.wast","passed":96,"failed":0},{"name":"linking.wast","passed":132,"failed":0},{"name":"load.wast","passed":97,"failed":0},{"name":"local_get.wast","passed":36,"failed":0},{"name":"local_set.wast","passed":53,"failed":0},{"name":"local_tee.wast","passed":97,"failed":0},{"name":"loop.wast","passed":120,"failed":0},{"name":"memory.wast","passed":79,"failed":0},{"name":"memory_copy.wast","passed":4450,"failed":0},{"name":"memory_fill.wast","passed":100,"failed":0},{"name":"memory_grow.wast","passed":96,"failed":0},{"name":"memory_init.wast","passed":240,"failed":0},{"name":"memory_redundancy.wast","passed":8,"failed":0},{"name":"memory_size.wast","passed":42,"failed":0},{"name":"memory_trap.wast","passed":182,"failed":0},{"name":"names.wast","passed":486,"failed":0},{"name":"nop.wast","passed":88,"failed":0},{"name":"ref_func.wast","passed":17,"failed":0},{"name":"ref_is_null.wast","passed":16,"failed":0},{"name":"ref_null.wast","passed":3,"failed":0},{"name":"return.wast","passed":84,"failed":0},{"name":"select.wast","passed":147,"failed":0},{"name":"skip-stack-guard-page.wast","passed":11,"failed":0},{"name":"stack.wast","passed":7,"failed":0},{"name":"start.wast","passed":20,"failed":0},{"name":"store.wast","passed":68,"failed":0},{"name":"switch.wast","passed":28,"failed":0},{"name":"table-sub.wast","passed":2,"failed":0},{"name":"table.wast","passed":19,"failed":0},{"name":"table_copy.wast","passed":1728,"failed":0},{"name":"table_fill.wast","passed":45,"failed":0},{"name":"table_get.wast","passed":16,"failed":0},{"name":"table_grow.wast","passed":50,"failed":0},{"name":"table_init.wast","passed":780,"failed":0},{"name":"table_set.wast","passed":26,"failed":0},{"name":"table_size.wast","passed":39,"failed":0},{"name":"token.wast","passed":2,"failed":0},{"name":"traps.wast","passed":36,"failed":0},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":64,"failed":0},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unreached-valid.wast","passed":6,"failed":0},{"name":"unwind.wast","passed":50,"failed":0},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}] diff --git a/crates/tinywasm/tests/generated/wasm-annotations.csv b/crates/tinywasm/tests/generated/wasm-annotations.csv index a1c7fb6..1b99033 100644 --- a/crates/tinywasm/tests/generated/wasm-annotations.csv +++ b/crates/tinywasm/tests/generated/wasm-annotations.csv @@ -1,2 +1,2 @@ 0.8.0,142,0,[{"name":"annotations.wast","passed":74,"failed":0},{"name":"annotations/simd_lane.wast (skipped)","passed":0,"failed":0},{"name":"id.wast","passed":7,"failed":0},{"name":"token.wast","passed":61,"failed":0}] -0.9.0-alpha.0,142,0,[{"name":"annotations.wast","passed":74,"failed":0},{"name":"annotations/simd_lane.wast (skipped)","passed":0,"failed":0},{"name":"id.wast","passed":7,"failed":0},{"name":"token.wast","passed":61,"failed":0}] +0.9.0-alpha.0,142,0,[{"name":"annotations.wast","passed":74,"failed":0},{"name":"id.wast","passed":7,"failed":0},{"name":"simd_lane.wast (skipped)","passed":0,"failed":0},{"name":"token.wast","passed":61,"failed":0}] diff --git a/crates/tinywasm/tests/generated/wasm-multi-memory.csv b/crates/tinywasm/tests/generated/wasm-multi-memory.csv index 0f70c8e..ae9ba03 100644 --- a/crates/tinywasm/tests/generated/wasm-multi-memory.csv +++ b/crates/tinywasm/tests/generated/wasm-multi-memory.csv @@ -1,2 +1,2 @@ 0.8.0,1872,0,[{"name":"address0.wast","passed":92,"failed":0},{"name":"address1.wast","passed":127,"failed":0},{"name":"align.wast","passed":160,"failed":0},{"name":"align0.wast","passed":5,"failed":0},{"name":"binary.wast","passed":126,"failed":0},{"name":"binary0.wast","passed":7,"failed":0},{"name":"data.wast","passed":61,"failed":0},{"name":"data0.wast","passed":7,"failed":0},{"name":"data1.wast","passed":14,"failed":0},{"name":"data_drop0.wast","passed":11,"failed":0},{"name":"exports0.wast","passed":8,"failed":0},{"name":"float_exprs0.wast","passed":14,"failed":0},{"name":"float_exprs1.wast","passed":3,"failed":0},{"name":"float_memory0.wast","passed":30,"failed":0},{"name":"imports.wast","passed":175,"failed":0},{"name":"imports0.wast","passed":8,"failed":0},{"name":"imports1.wast","passed":5,"failed":0},{"name":"imports2.wast","passed":20,"failed":0},{"name":"imports3.wast","passed":10,"failed":0},{"name":"imports4.wast","passed":16,"failed":0},{"name":"linking0.wast","passed":6,"failed":0},{"name":"linking1.wast","passed":14,"failed":0},{"name":"linking2.wast","passed":11,"failed":0},{"name":"linking3.wast","passed":14,"failed":0},{"name":"load.wast","passed":118,"failed":0},{"name":"load0.wast","passed":3,"failed":0},{"name":"load1.wast","passed":18,"failed":0},{"name":"load2.wast","passed":38,"failed":0},{"name":"memory-multi.wast","passed":6,"failed":0},{"name":"memory.wast","passed":86,"failed":0},{"name":"memory_copy0.wast","passed":29,"failed":0},{"name":"memory_copy1.wast","passed":14,"failed":0},{"name":"memory_fill0.wast","passed":16,"failed":0},{"name":"memory_grow.wast","passed":157,"failed":0},{"name":"memory_init0.wast","passed":13,"failed":0},{"name":"memory_size.wast","passed":49,"failed":0},{"name":"memory_size0.wast","passed":8,"failed":0},{"name":"memory_size1.wast","passed":15,"failed":0},{"name":"memory_size2.wast","passed":21,"failed":0},{"name":"memory_size3.wast","passed":2,"failed":0},{"name":"memory_trap0.wast","passed":14,"failed":0},{"name":"memory_trap1.wast","passed":168,"failed":0},{"name":"multi-memory/simd_memory-multi.wast (skipped)","passed":0,"failed":0},{"name":"start0.wast","passed":9,"failed":0},{"name":"store.wast","passed":111,"failed":0},{"name":"store0.wast","passed":5,"failed":0},{"name":"store1.wast","passed":13,"failed":0},{"name":"traps0.wast","passed":15,"failed":0}] -0.9.0-alpha.0,1872,0,[{"name":"address0.wast","passed":92,"failed":0},{"name":"address1.wast","passed":127,"failed":0},{"name":"align.wast","passed":160,"failed":0},{"name":"align0.wast","passed":5,"failed":0},{"name":"binary.wast","passed":126,"failed":0},{"name":"binary0.wast","passed":7,"failed":0},{"name":"data.wast","passed":61,"failed":0},{"name":"data0.wast","passed":7,"failed":0},{"name":"data1.wast","passed":14,"failed":0},{"name":"data_drop0.wast","passed":11,"failed":0},{"name":"exports0.wast","passed":8,"failed":0},{"name":"float_exprs0.wast","passed":14,"failed":0},{"name":"float_exprs1.wast","passed":3,"failed":0},{"name":"float_memory0.wast","passed":30,"failed":0},{"name":"imports.wast","passed":175,"failed":0},{"name":"imports0.wast","passed":8,"failed":0},{"name":"imports1.wast","passed":5,"failed":0},{"name":"imports2.wast","passed":20,"failed":0},{"name":"imports3.wast","passed":10,"failed":0},{"name":"imports4.wast","passed":16,"failed":0},{"name":"linking0.wast","passed":6,"failed":0},{"name":"linking1.wast","passed":14,"failed":0},{"name":"linking2.wast","passed":11,"failed":0},{"name":"linking3.wast","passed":14,"failed":0},{"name":"load.wast","passed":118,"failed":0},{"name":"load0.wast","passed":3,"failed":0},{"name":"load1.wast","passed":18,"failed":0},{"name":"load2.wast","passed":38,"failed":0},{"name":"memory-multi.wast","passed":6,"failed":0},{"name":"memory.wast","passed":86,"failed":0},{"name":"memory_copy0.wast","passed":29,"failed":0},{"name":"memory_copy1.wast","passed":14,"failed":0},{"name":"memory_fill0.wast","passed":16,"failed":0},{"name":"memory_grow.wast","passed":157,"failed":0},{"name":"memory_init0.wast","passed":13,"failed":0},{"name":"memory_size.wast","passed":49,"failed":0},{"name":"memory_size0.wast","passed":8,"failed":0},{"name":"memory_size1.wast","passed":15,"failed":0},{"name":"memory_size2.wast","passed":21,"failed":0},{"name":"memory_size3.wast","passed":2,"failed":0},{"name":"memory_trap0.wast","passed":14,"failed":0},{"name":"memory_trap1.wast","passed":168,"failed":0},{"name":"multi-memory/simd_memory-multi.wast (skipped)","passed":0,"failed":0},{"name":"start0.wast","passed":9,"failed":0},{"name":"store.wast","passed":111,"failed":0},{"name":"store0.wast","passed":5,"failed":0},{"name":"store1.wast","passed":13,"failed":0},{"name":"traps0.wast","passed":15,"failed":0}] +0.9.0-alpha.0,1872,0,[{"name":"address0.wast","passed":92,"failed":0},{"name":"address1.wast","passed":127,"failed":0},{"name":"align.wast","passed":160,"failed":0},{"name":"align0.wast","passed":5,"failed":0},{"name":"binary.wast","passed":126,"failed":0},{"name":"binary0.wast","passed":7,"failed":0},{"name":"data.wast","passed":61,"failed":0},{"name":"data0.wast","passed":7,"failed":0},{"name":"data1.wast","passed":14,"failed":0},{"name":"data_drop0.wast","passed":11,"failed":0},{"name":"exports0.wast","passed":8,"failed":0},{"name":"float_exprs0.wast","passed":14,"failed":0},{"name":"float_exprs1.wast","passed":3,"failed":0},{"name":"float_memory0.wast","passed":30,"failed":0},{"name":"imports.wast","passed":175,"failed":0},{"name":"imports0.wast","passed":8,"failed":0},{"name":"imports1.wast","passed":5,"failed":0},{"name":"imports2.wast","passed":20,"failed":0},{"name":"imports3.wast","passed":10,"failed":0},{"name":"imports4.wast","passed":16,"failed":0},{"name":"linking0.wast","passed":6,"failed":0},{"name":"linking1.wast","passed":14,"failed":0},{"name":"linking2.wast","passed":11,"failed":0},{"name":"linking3.wast","passed":14,"failed":0},{"name":"load.wast","passed":118,"failed":0},{"name":"load0.wast","passed":3,"failed":0},{"name":"load1.wast","passed":18,"failed":0},{"name":"load2.wast","passed":38,"failed":0},{"name":"memory-multi.wast","passed":6,"failed":0},{"name":"memory.wast","passed":86,"failed":0},{"name":"memory_copy0.wast","passed":29,"failed":0},{"name":"memory_copy1.wast","passed":14,"failed":0},{"name":"memory_fill0.wast","passed":16,"failed":0},{"name":"memory_grow.wast","passed":157,"failed":0},{"name":"memory_init0.wast","passed":13,"failed":0},{"name":"memory_size.wast","passed":49,"failed":0},{"name":"memory_size0.wast","passed":8,"failed":0},{"name":"memory_size1.wast","passed":15,"failed":0},{"name":"memory_size2.wast","passed":21,"failed":0},{"name":"memory_size3.wast","passed":2,"failed":0},{"name":"memory_trap0.wast","passed":14,"failed":0},{"name":"memory_trap1.wast","passed":168,"failed":0},{"name":"simd_memory-multi.wast (skipped)","passed":0,"failed":0},{"name":"start0.wast","passed":9,"failed":0},{"name":"store.wast","passed":111,"failed":0},{"name":"store0.wast","passed":5,"failed":0},{"name":"store1.wast","passed":13,"failed":0},{"name":"traps0.wast","passed":15,"failed":0}] diff --git a/crates/tinywasm/tests/test-wasm-1.rs b/crates/tinywasm/tests/test-wasm-1.rs index 77694c5..e6a9dd9 100644 --- a/crates/tinywasm/tests/test-wasm-1.rs +++ b/crates/tinywasm/tests/test-wasm-1.rs @@ -1,20 +1,13 @@ mod testsuite; -use eyre::{eyre, Result}; -use owo_colors::OwoColorize; -use testsuite::TestSuite; +use eyre::Result; fn main() -> Result<()> { - let mut test_suite = TestSuite::new(); + println!("Skipping 1.0 tests (False positives due to relaxed validation in later versions)"); + Ok(()) + // TestSuite::set_log_level(log::LevelFilter::Off); - TestSuite::set_log_level(log::LevelFilter::Off); - test_suite.run_spec_group(wasm_testsuite::MVP_TESTS)?; - test_suite.save_csv("./tests/generated/wasm-1.csv", env!("CARGO_PKG_VERSION"))?; - - if test_suite.failed() { - println!(); - Err(eyre!(format!("{}:\n{:#?}", "failed one or more tests".red().bold(), test_suite,))) - } else { - println!("\n\npassed all tests:\n{test_suite:#?}"); - Ok(()) - } + // let mut test_suite = TestSuite::new(); + // test_suite.run_files(spec(&SpecVersion::V1))?; + // test_suite.save_csv("./tests/generated/wasm-1.csv", env!("CARGO_PKG_VERSION"))?; + // test_suite.report_status() } diff --git a/crates/tinywasm/tests/test-wasm-2.rs b/crates/tinywasm/tests/test-wasm-2.rs index 336632f..9b30ac0 100644 --- a/crates/tinywasm/tests/test-wasm-2.rs +++ b/crates/tinywasm/tests/test-wasm-2.rs @@ -1,20 +1,13 @@ mod testsuite; -use eyre::{eyre, Result}; -use owo_colors::OwoColorize; +use eyre::Result; use testsuite::TestSuite; +use wasm_testsuite::data::{spec, SpecVersion}; fn main() -> Result<()> { - let mut test_suite = TestSuite::new(); - TestSuite::set_log_level(log::LevelFilter::Off); - test_suite.run_spec_group(wasm_testsuite::V2_TESTS)?; - test_suite.save_csv("./tests/generated/wasm-2.csv", env!("CARGO_PKG_VERSION"))?; - if test_suite.failed() { - println!(); - Err(eyre!(format!("{}:\n{:#?}", "failed one or more tests".red().bold(), test_suite,))) - } else { - println!("\n\npassed all tests:\n{test_suite:#?}"); - Ok(()) - } + let mut test_suite = TestSuite::new(); + test_suite.run_files(spec(&SpecVersion::V2))?; + test_suite.save_csv("./tests/generated/wasm-2.csv", env!("CARGO_PKG_VERSION"))?; + test_suite.report_status() } diff --git a/crates/tinywasm/tests/test-wasm-annotations.rs b/crates/tinywasm/tests/test-wasm-annotations.rs index c521156..3170241 100644 --- a/crates/tinywasm/tests/test-wasm-annotations.rs +++ b/crates/tinywasm/tests/test-wasm-annotations.rs @@ -1,21 +1,14 @@ mod testsuite; -use eyre::{eyre, Result}; -use owo_colors::OwoColorize; +use eyre::Result; use testsuite::TestSuite; +use wasm_testsuite::data::{proposal, Proposal}; fn main() -> Result<()> { - let mut test_suite = TestSuite::new(); - TestSuite::set_log_level(log::LevelFilter::Off); - test_suite.skip("annotations/simd_lane.wast"); - test_suite.run_spec_group(wasm_testsuite::get_proposal_tests("annotations"))?; - test_suite.save_csv("./tests/generated/wasm-annotations.csv", env!("CARGO_PKG_VERSION"))?; - if test_suite.failed() { - println!(); - Err(eyre!(format!("{}:\n{:#?}", "failed one or more tests".red().bold(), test_suite,))) - } else { - println!("\n\npassed all tests:\n{test_suite:#?}"); - Ok(()) - } + let mut test_suite = TestSuite::new(); + test_suite.skip("simd_lane.wast"); + test_suite.run_files(proposal(&Proposal::Annotations))?; + test_suite.save_csv("./tests/generated/wasm-annotations.csv", env!("CARGO_PKG_VERSION"))?; + test_suite.report_status() } diff --git a/crates/tinywasm/tests/test-wasm-custom-page-sizes.rs b/crates/tinywasm/tests/test-wasm-custom-page-sizes.rs index ee9c732..d49d89a 100644 --- a/crates/tinywasm/tests/test-wasm-custom-page-sizes.rs +++ b/crates/tinywasm/tests/test-wasm-custom-page-sizes.rs @@ -4,17 +4,4 @@ use eyre::Result; fn main() -> Result<()> { println!("Skipping Wasm Custom Page Sizes tests (Wast doesn't support the syntax yet)"); Ok(()) - - // let mut test_suite = TestSuite::new(); - // TestSuite::set_log_level(log::LevelFilter::Off); - // test_suite.run_spec_group(wasm_testsuite::get_proposal_tests("custom-page-sizes"))?; - // test_suite.save_csv("./tests/generated/wasm-custom-page-sizes.csv", env!("CARGO_PKG_VERSION"))?; - - // if test_suite.failed() { - // println!(); - // Err(eyre!(format!("{}:\n{:#?}", "failed one or more tests".red().bold(), test_suite,))) - // } else { - // println!("\n\npassed all tests:\n{test_suite:#?}"); - // Ok(()) - // } } diff --git a/crates/tinywasm/tests/test-wasm-extended-const.rs b/crates/tinywasm/tests/test-wasm-extended-const.rs index f544b35..7c9a304 100644 --- a/crates/tinywasm/tests/test-wasm-extended-const.rs +++ b/crates/tinywasm/tests/test-wasm-extended-const.rs @@ -1,20 +1,13 @@ mod testsuite; -use eyre::{eyre, Result}; -use owo_colors::OwoColorize; +use eyre::Result; use testsuite::TestSuite; +use wasm_testsuite::data::{proposal, Proposal}; fn main() -> Result<()> { - let mut test_suite = TestSuite::new(); - TestSuite::set_log_level(log::LevelFilter::Off); - test_suite.run_spec_group(wasm_testsuite::get_proposal_tests("extended-const"))?; - test_suite.save_csv("./tests/generated/wasm-extended-const.csv", env!("CARGO_PKG_VERSION"))?; - if test_suite.failed() { - println!(); - Err(eyre!(format!("{}:\n{:#?}", "failed one or more tests".red().bold(), test_suite,))) - } else { - println!("\n\npassed all tests:\n{test_suite:#?}"); - Ok(()) - } + let mut test_suite = TestSuite::new(); + test_suite.run_files(proposal(&Proposal::ExtendedConst))?; + test_suite.save_csv("./tests/generated/wasm-extended-const.csv", env!("CARGO_PKG_VERSION"))?; + test_suite.report_status() } diff --git a/crates/tinywasm/tests/test-wasm-memory64.rs b/crates/tinywasm/tests/test-wasm-memory64.rs index 0dfe2b8..391a1ef 100644 --- a/crates/tinywasm/tests/test-wasm-memory64.rs +++ b/crates/tinywasm/tests/test-wasm-memory64.rs @@ -4,6 +4,8 @@ use owo_colors::OwoColorize; use testsuite::TestSuite; fn main() -> Result<()> { + TestSuite::set_log_level(log::LevelFilter::Off); + let mut test_suite = TestSuite::new(); test_suite.skip("memory64/array.wast"); test_suite.skip("memory64/extern.wast"); @@ -16,15 +18,7 @@ fn main() -> Result<()> { test_suite.skip("memory64/struct.wast"); test_suite.skip("memory64/table.wast"); - TestSuite::set_log_level(log::LevelFilter::Off); - test_suite.run_spec_group(wasm_testsuite::get_proposal_tests("memory64"))?; + test_suite.run_files(proposal(&Proposal::Memory64))?; test_suite.save_csv("./tests/generated/wasm-memory64.csv", env!("CARGO_PKG_VERSION"))?; - - if test_suite.failed() { - println!(); - Err(eyre!(format!("{}:\n{:#?}", "failed one or more tests".red().bold(), test_suite,))) - } else { - println!("\n\npassed all tests:\n{test_suite:#?}"); - Ok(()) - } + test_suite.report_status() } diff --git a/crates/tinywasm/tests/test-wasm-multi-memory.rs b/crates/tinywasm/tests/test-wasm-multi-memory.rs index 9b1f8b7..d491fb1 100644 --- a/crates/tinywasm/tests/test-wasm-multi-memory.rs +++ b/crates/tinywasm/tests/test-wasm-multi-memory.rs @@ -1,21 +1,14 @@ mod testsuite; -use eyre::{eyre, Result}; -use owo_colors::OwoColorize; +use eyre::Result; use testsuite::TestSuite; +use wasm_testsuite::data::{proposal, Proposal}; fn main() -> Result<()> { - let mut test_suite = TestSuite::new(); - TestSuite::set_log_level(log::LevelFilter::Off); - test_suite.skip("multi-memory/simd_memory-multi.wast"); - test_suite.run_spec_group(wasm_testsuite::get_proposal_tests("multi-memory"))?; - test_suite.save_csv("./tests/generated/wasm-multi-memory.csv", env!("CARGO_PKG_VERSION"))?; - if test_suite.failed() { - println!(); - Err(eyre!(format!("{}:\n{:#?}", "failed one or more tests".red().bold(), test_suite,))) - } else { - println!("\n\npassed all tests:\n{test_suite:#?}"); - Ok(()) - } + let mut test_suite = TestSuite::new(); + test_suite.skip("simd_memory-multi.wast"); + test_suite.run_files(proposal(&Proposal::MultiMemory))?; + test_suite.save_csv("./tests/generated/wasm-multi-memory.csv", env!("CARGO_PKG_VERSION"))?; + test_suite.report_status() } diff --git a/crates/tinywasm/tests/test-wasm-relaxed-simd.rs b/crates/tinywasm/tests/test-wasm-relaxed-simd.rs new file mode 100644 index 0000000..7af830a --- /dev/null +++ b/crates/tinywasm/tests/test-wasm-relaxed-simd.rs @@ -0,0 +1,13 @@ +mod testsuite; +use eyre::Result; +use testsuite::TestSuite; +use wasm_testsuite::data::{proposal, Proposal}; + +fn main() -> Result<()> { + TestSuite::set_log_level(log::LevelFilter::Off); + + let mut test_suite = TestSuite::new(); + test_suite.run_files(proposal(&Proposal::RelaxedSimd))?; + test_suite.save_csv("./tests/generated/wasm-relaxed-simd.csv", env!("CARGO_PKG_VERSION"))?; + test_suite.report_status() +} diff --git a/crates/tinywasm/tests/test-wasm-simd.rs b/crates/tinywasm/tests/test-wasm-simd.rs deleted file mode 100644 index 289bf2b..0000000 --- a/crates/tinywasm/tests/test-wasm-simd.rs +++ /dev/null @@ -1,20 +0,0 @@ -mod testsuite; -use eyre::{eyre, Result}; -use owo_colors::OwoColorize; -use testsuite::TestSuite; - -fn main() -> Result<()> { - let mut test_suite = TestSuite::new(); - - TestSuite::set_log_level(log::LevelFilter::Off); - test_suite.run_spec_group(wasm_testsuite::SIMD_TESTS)?; - test_suite.save_csv("./tests/generated/wasm-simd.csv", env!("CARGO_PKG_VERSION"))?; - - if test_suite.failed() { - println!(); - Err(eyre!(format!("{}:\n{:#?}", "failed one or more tests".red().bold(), test_suite,))) - } else { - println!("\n\npassed all tests:\n{test_suite:#?}"); - Ok(()) - } -} diff --git a/crates/tinywasm/tests/testsuite/indexmap.rs b/crates/tinywasm/tests/testsuite/indexmap.rs deleted file mode 100644 index 0c75e4c..0000000 --- a/crates/tinywasm/tests/testsuite/indexmap.rs +++ /dev/null @@ -1,31 +0,0 @@ -/// A naive implementation of an index map for use in the test suite -pub struct IndexMap { - map: std::collections::HashMap, - keys: Vec, -} - -impl IndexMap -where - K: std::cmp::Eq + std::hash::Hash + Clone, -{ - pub fn new() -> Self { - Self { map: std::collections::HashMap::new(), keys: Vec::new() } - } - - pub fn insert(&mut self, key: K, value: V) -> Option { - if let std::collections::hash_map::Entry::Occupied(mut e) = self.map.entry(key.clone()) { - return Some(e.insert(value)); - } - - self.keys.push(key.clone()); - self.map.insert(key, value) - } - - pub fn iter(&self) -> impl Iterator { - self.keys.iter().map(move |k| (k, self.map.get(k).unwrap())) - } - - pub fn values(&self) -> impl Iterator { - self.map.values() - } -} diff --git a/crates/tinywasm/tests/testsuite/mod.rs b/crates/tinywasm/tests/testsuite/mod.rs index 3c23e00..ee0336e 100644 --- a/crates/tinywasm/tests/testsuite/mod.rs +++ b/crates/tinywasm/tests/testsuite/mod.rs @@ -1,5 +1,6 @@ #![allow(unused)] -use eyre::Result; +use eyre::{eyre, Result}; +use indexmap::IndexMap; use owo_colors::OwoColorize; use std::io::{BufRead, Seek, SeekFrom}; use std::{ @@ -8,14 +9,11 @@ use std::{ io::BufReader, }; -mod indexmap; mod run; mod util; use serde::{Deserialize, Serialize}; -use self::indexmap::IndexMap; - #[derive(Serialize, Deserialize)] pub struct TestGroupResult { pub name: String, @@ -30,6 +28,16 @@ impl TestSuite { pretty_env_logger::formatted_builder().filter_level(level).init(); } + pub fn report_status(&self) -> Result<()> { + if self.failed() { + println!(); + Err(eyre!(format!("{}:\n{:#?}", "failed one or more tests".red().bold(), self))) + } else { + println!("\n\npassed all tests:\n{self:#?}"); + Ok(()) + } + } + pub fn print_errors(&self) { for (group_name, group) in &self.0 { let tests = &group.tests; diff --git a/crates/tinywasm/tests/testsuite/run.rs b/crates/tinywasm/tests/testsuite/run.rs index 26d2e6d..6324a5b 100644 --- a/crates/tinywasm/tests/testsuite/run.rs +++ b/crates/tinywasm/tests/testsuite/run.rs @@ -3,20 +3,22 @@ use std::{borrow::Cow, collections::HashMap}; use super::TestSuite; use eyre::{eyre, Result}; +use indexmap::IndexMap; use log::{debug, error, info}; use tinywasm::{Extern, Imports, ModuleInstance}; use tinywasm_types::{ExternVal, MemoryType, ModuleInstanceAddr, TableType, ValType, WasmValue}; +use wasm_testsuite::data::TestFile; use wast::{lexer::Lexer, parser::ParseBuffer, Wast}; #[derive(Default)] -struct RegisteredModules { +struct ModuleRegistry { modules: HashMap, named_modules: HashMap, last_module: Option, } -impl RegisteredModules { +impl ModuleRegistry { fn modules(&self) -> &HashMap { &self.modules } @@ -70,10 +72,15 @@ impl RegisteredModules { impl TestSuite { pub fn run_paths(&mut self, tests: &[&str]) -> Result<()> { - for group in tests { - let group_wast = std::fs::read(group).expect("failed to read test wast"); - let group_wast = Cow::Owned(group_wast); - self.run_group(group, group_wast).expect("failed to run group"); + for file_name in tests { + let group_wast = std::fs::read(file_name).expect("failed to read test wast"); + let file = TestFile { + contents: std::str::from_utf8(&group_wast).expect("failed to convert to utf8"), + name: file_name.to_string(), + parent: "(custom group)".into(), + }; + + self.run_file(file).expect("failed to run group"); } Ok(()) @@ -147,40 +154,33 @@ impl TestSuite { Ok(imports) } - pub fn run_spec_group>(&mut self, tests: impl IntoIterator) -> Result<()> { + pub fn run_files<'a>(&mut self, tests: impl IntoIterator>) -> Result<()> { tests.into_iter().for_each(|group| { - println!("running group: {}", group.as_ref()); - let group = group.as_ref(); - let group_wast = wasm_testsuite::get_test_wast(group).expect("failed to get test wast"); - if self.1.contains(&(*group).to_string()) { - info!("skipping group: {}", group); - self.test_group(&format!("{group} (skipped)"), group); + let name = group.name(); + println!("running group: {}", name); + if self.1.contains(&name.to_string()) { + info!("skipping group: {name}"); + self.test_group(&format!("{name} (skipped)"), name); return; } - self.run_group(group, group_wast).expect("failed to run group"); + self.run_file(group).expect("failed to run group"); }); Ok(()) } - pub fn run_group(&mut self, group_name: &str, group_wast: Cow<'_, [u8]>) -> Result<()> { - let file_name = group_name.split('/').last().unwrap_or(group_name); - let test_group = self.test_group(file_name, group_name); - let wast = std::str::from_utf8(&group_wast).expect("failed to convert wast to utf8"); - - let mut lexer = Lexer::new(wast); - // we need to allow confusing unicode characters since they are technically valid wasm - lexer.allow_confusing_unicode(true); - - let buf = ParseBuffer::new_with_lexer(lexer).expect("failed to create parse buffer"); - let wast_data = wast::parser::parse::(&buf).expect("failed to parse wat"); + pub fn run_file<'a>(&mut self, file: TestFile<'a>) -> Result<()> { + let test_group = self.test_group(file.name(), file.parent()); + let wast_raw = file.raw(); + let wast = file.wast()?; + let directives = wast.directives()?; let mut store = tinywasm::Store::default(); - let mut registered_modules = RegisteredModules::default(); + let mut module_registry = ModuleRegistry::default(); - println!("running {} tests for group: {}", wast_data.directives.len(), group_name); - for (i, directive) in wast_data.directives.into_iter().enumerate() { + println!("running {} tests for group: {}", directives.len(), file.name()); + for (i, directive) in directives.into_iter().enumerate() { let span = directive.span(); use wast::WastDirective::{ AssertExhaustion, AssertInvalid, AssertMalformed, AssertReturn, AssertTrap, AssertUnlinkable, Invoke, @@ -189,16 +189,16 @@ impl TestSuite { match directive { Register { span, name, .. } => { - let Some(last) = registered_modules.last(&store) else { + let Some(last) = module_registry.last(&store) else { test_group.add_result( &format!("Register({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("no module to register")), ); continue; }; - registered_modules.register(name.to_string(), last.id()); - test_group.add_result(&format!("Register({i})"), span.linecol_in(wast), Ok(())); + module_registry.register(name.to_string(), last.id()); + test_group.add_result(&format!("Register({i})"), span.linecol_in(wast_raw), Ok(())); } Wat(module) => { @@ -208,7 +208,7 @@ impl TestSuite { let m = parse_module_bytes(&bytes).expect("failed to parse module bytes"); let module_instance = tinywasm::Module::from(m) - .instantiate(&mut store, Some(Self::imports(registered_modules.modules()).unwrap())) + .instantiate(&mut store, Some(Self::imports(module_registry.modules()).unwrap())) .expect("failed to instantiate module"); (name, module_instance) @@ -217,15 +217,15 @@ impl TestSuite { match &result { Err(err) => debug!("failed to parse module: {:?}", err), - Ok((name, module)) => registered_modules.update_last_module(module.id(), name.clone()), + Ok((name, module)) => module_registry.update_last_module(module.id(), name.clone()), }; - test_group.add_result(&format!("Wat({i})"), span.linecol_in(wast), result.map(|_| ())); + test_group.add_result(&format!("Wat({i})"), span.linecol_in(wast_raw), result.map(|_| ())); } AssertMalformed { span, mut module, message } => { let Ok(module) = module.encode() else { - test_group.add_result(&format!("AssertMalformed({i})"), span.linecol_in(wast), Ok(())); + test_group.add_result(&format!("AssertMalformed({i})"), span.linecol_in(wast_raw), Ok(())); continue; }; @@ -235,12 +235,13 @@ impl TestSuite { test_group.add_result( &format!("AssertMalformed({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), match res { Ok(_) => { - // // skip "zero byte expected" as the magic number is not checked by wasmparser - // (Don't need to error on this, doesn't matter if it's malformed) - if message == "zero byte expected" { + // - skip "zero byte expected" as the magic number is not checked by wasmparser + // (Don't need to error on this, doesn't matter if it's malformed) + // - skip "integer representation too long" as this has some false positives + if message == "zero byte expected" || message == "integer representation too long" { continue; } @@ -253,7 +254,7 @@ impl TestSuite { AssertInvalid { span, mut module, message } => { if ["multiple memories"].contains(&message) { - test_group.add_result(&format!("AssertInvalid({i})"), span.linecol_in(wast), Ok(())); + test_group.add_result(&format!("AssertInvalid({i})"), span.linecol_in(wast_raw), Ok(())); continue; } @@ -263,7 +264,7 @@ impl TestSuite { test_group.add_result( &format!("AssertInvalid({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), match res { Ok(_) => Err(eyre!("expected module to be invalid")), Err(_) => Ok(()), @@ -272,7 +273,7 @@ impl TestSuite { } AssertExhaustion { call, message, span } => { - let module = registered_modules.get_idx(call.module); + let module = module_registry.get_idx(call.module); let args = convert_wastargs(call.args).expect("failed to convert args"); let res = catch_unwind_silent(|| exec_fn_instance(module, &mut store, call.name, &args).map(|_| ())); @@ -280,7 +281,7 @@ impl TestSuite { let Ok(Err(tinywasm::Error::Trap(trap))) = res else { test_group.add_result( &format!("AssertExhaustion({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("expected trap")), ); continue; @@ -289,13 +290,13 @@ impl TestSuite { if !message.starts_with(trap.message()) { test_group.add_result( &format!("AssertExhaustion({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("expected trap: {}, got: {}", message, trap.message())), ); continue; } - test_group.add_result(&format!("AssertExhaustion({i})"), span.linecol_in(wast), Ok(())); + test_group.add_result(&format!("AssertExhaustion({i})"), span.linecol_in(wast_raw), Ok(())); } AssertTrap { exec, message, span } => { @@ -305,10 +306,8 @@ impl TestSuite { let module = parse_module_bytes(&wat.encode().expect("failed to encode module")) .expect("failed to parse module"); let module = tinywasm::Module::from(module); - module.instantiate( - &mut store, - Some(Self::imports(registered_modules.modules()).unwrap()), - )?; + module + .instantiate(&mut store, Some(Self::imports(module_registry.modules()).unwrap()))?; return Ok(()); } wast::WastExecute::Get { module: _, global: _, .. } => { @@ -317,7 +316,7 @@ impl TestSuite { wast::WastExecute::Invoke(invoke) => invoke, }; - let module = registered_modules.get_idx(invoke.module); + let module = module_registry.get_idx(invoke.module); let args = convert_wastargs(invoke.args).expect("failed to convert args"); exec_fn_instance(module, &mut store, invoke.name, &args).map(|_| ()) }); @@ -325,29 +324,29 @@ impl TestSuite { match res { Err(err) => test_group.add_result( &format!("AssertTrap({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("test panicked: {:?}", try_downcast_panic(err))), ), Ok(Err(tinywasm::Error::Trap(trap))) => { if !message.starts_with(trap.message()) { test_group.add_result( &format!("AssertTrap({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("expected trap: {}, got: {}", message, trap.message())), ); continue; } - test_group.add_result(&format!("AssertTrap({i})"), span.linecol_in(wast), Ok(())); + test_group.add_result(&format!("AssertTrap({i})"), span.linecol_in(wast_raw), Ok(())); } Ok(Err(err)) => test_group.add_result( &format!("AssertTrap({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("expected trap, {}, got: {:?}", message, err)), ), Ok(Ok(())) => test_group.add_result( &format!("AssertTrap({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("expected trap {}, got Ok", message)), ), } @@ -358,13 +357,13 @@ impl TestSuite { let module = parse_module_bytes(&module.encode().expect("failed to encode module")) .expect("failed to parse module"); let module = tinywasm::Module::from(module); - module.instantiate(&mut store, Some(Self::imports(registered_modules.modules()).unwrap())) + module.instantiate(&mut store, Some(Self::imports(module_registry.modules()).unwrap())) }); match res { Err(err) => test_group.add_result( &format!("AssertUnlinkable({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("test panicked: {:?}", try_downcast_panic(err))), ), Ok(Err(tinywasm::Error::Linker(err))) => { @@ -374,22 +373,22 @@ impl TestSuite { { test_group.add_result( &format!("AssertUnlinkable({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("expected linker error: {}, got: {}", message, err.message())), ); continue; } - test_group.add_result(&format!("AssertUnlinkable({i})"), span.linecol_in(wast), Ok(())); + test_group.add_result(&format!("AssertUnlinkable({i})"), span.linecol_in(wast_raw), Ok(())); } Ok(Err(err)) => test_group.add_result( &format!("AssertUnlinkable({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("expected linker error, {}, got: {:?}", message, err)), ), Ok(Ok(_)) => test_group.add_result( &format!("AssertUnlinkable({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("expected linker error {}, got Ok", message)), ), } @@ -400,7 +399,7 @@ impl TestSuite { let res: Result, _> = catch_unwind_silent(|| { let args = convert_wastargs(invoke.args)?; - let module = registered_modules.get_idx(invoke.module); + let module = module_registry.get_idx(invoke.module); exec_fn_instance(module, &mut store, invoke.name, &args).map_err(|e| { error!("failed to execute function: {:?}", e); e @@ -409,7 +408,7 @@ impl TestSuite { }); let res = res.map_err(|e| eyre!("test panicked: {:?}", try_downcast_panic(e))).and_then(|r| r); - test_group.add_result(&format!("Invoke({name}-{i})"), span.linecol_in(wast), res); + test_group.add_result(&format!("Invoke({name}-{i})"), span.linecol_in(wast_raw), res); } AssertReturn { span, exec, results } => { @@ -419,11 +418,11 @@ impl TestSuite { let invoke = match match exec { wast::WastExecute::Wat(_) => Err(eyre!("wat not supported")), wast::WastExecute::Get { module: module_id, global, .. } => { - let module = registered_modules.get(module_id, &store); + let module = module_registry.get(module_id, &store); let Some(module) = module else { test_group.add_result( &format!("AssertReturn(unsupported-{i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("no module to get global from")), ); continue; @@ -437,7 +436,7 @@ impl TestSuite { Err(err) => { test_group.add_result( &format!("AssertReturn(unsupported-{i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("failed to get global: {:?}", err)), ); continue; @@ -449,7 +448,7 @@ impl TestSuite { if !module_global.eq_loose(expected) { test_group.add_result( &format!("AssertReturn(unsupported-{i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("global value did not match: {:?} != {:?}", module_global, expected)), ); continue; @@ -457,7 +456,7 @@ impl TestSuite { test_group.add_result( &format!("AssertReturn({global}-{i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Ok(()), ); @@ -470,7 +469,7 @@ impl TestSuite { Err(err) => { test_group.add_result( &format!("AssertReturn(unsupported-{i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("unsupported directive: {:?}", err)), ); continue; @@ -481,7 +480,7 @@ impl TestSuite { let res: Result, _> = catch_unwind_silent(|| { debug!("invoke: {:?}", invoke); let args = convert_wastargs(invoke.args)?; - let module = registered_modules.get_idx(invoke.module); + let module = module_registry.get_idx(invoke.module); let outcomes = exec_fn_instance(module, &mut store, invoke.name, &args).map_err(|e| { error!("failed to execute function: {:?}", e); e @@ -504,11 +503,11 @@ impl TestSuite { }); let res = res.map_err(|e| eyre!("test panicked: {:?}", try_downcast_panic(e))).and_then(|r| r); - test_group.add_result(&format!("AssertReturn({invoke_name}-{i})"), span.linecol_in(wast), res); + test_group.add_result(&format!("AssertReturn({invoke_name}-{i})"), span.linecol_in(wast_raw), res); } _ => test_group.add_result( &format!("Unknown({i})"), - span.linecol_in(wast), + span.linecol_in(wast_raw), Err(eyre!("unsupported directive")), ), } diff --git a/crates/tinywasm/tests/testsuite/util.rs b/crates/tinywasm/tests/testsuite/util.rs index a66a4da..3229455 100644 --- a/crates/tinywasm/tests/testsuite/util.rs +++ b/crates/tinywasm/tests/testsuite/util.rs @@ -8,7 +8,6 @@ pub fn try_downcast_panic(panic: Box) -> String { let info = panic.downcast_ref::().or(None).map(ToString::to_string).clone(); let info_string = panic.downcast_ref::().cloned(); let info_str = panic.downcast::<&str>().ok().map(|s| *s); - info.unwrap_or(info_str.unwrap_or(&info_string.unwrap_or("unknown panic".to_owned())).to_string()) } @@ -171,6 +170,7 @@ enum Bits { U32(u32), U64(u64), } + trait FloatToken { fn bits(&self) -> Bits; fn canonical_nan() -> WasmValue; @@ -182,6 +182,7 @@ trait FloatToken { } } } + impl FloatToken for wast::token::F32 { fn bits(&self) -> Bits { Bits::U32(self.bits) @@ -195,6 +196,7 @@ impl FloatToken for wast::token::F32 { WasmValue::F32(f32::NAN) } } + impl FloatToken for wast::token::F64 { fn bits(&self) -> Bits { Bits::U64(self.bits) diff --git a/crates/wasm-testsuite/Cargo.toml b/crates/wasm-testsuite/Cargo.toml deleted file mode 100644 index 46df77f..0000000 --- a/crates/wasm-testsuite/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name="wasm-testsuite" -version="0.6.0-alpha.0" -description="Mirror of the WebAssembly core testsuite for use in testing WebAssembly implementations" -license="Apache-2.0" -readme="README.md" -edition.workspace=true -authors.workspace=true -repository.workspace=true -rust-version.workspace=true - -[lib] -path="lib.rs" - -[package.metadata.workspaces] -independent=true - -[dependencies] -rust-embed={version="8.4", features=["include-exclude"]} diff --git a/crates/wasm-testsuite/README.md b/crates/wasm-testsuite/README.md deleted file mode 100644 index 51d574c..0000000 --- a/crates/wasm-testsuite/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# `wasm-testsuite` - -This crate embeds the latest version of the [WebAssembly Test Suite](https://github.com/WebAssembly/spec/tree/main/test). It is currently mainly used for testing the `tinywasm-parser` crate. Check out the [documentation](https://docs.rs/wasm-testsuite) for more information. - -## Usage - -```rust -use wasm_testsuite::{MVP_TESTS, get_test_wast}; - -MVP_TESTS.iter().for_each(|test| { - let wast_bytes = get_test_wast(test).expect("Failed to get wast bytes"); - let wast = std::str::from_utf8(&wast_bytes).expect("failed to convert wast to utf8"); - - // Do something with the wast (e.g. parse it using the `wast` crate) -}); -``` - -## License - -This crate is licensed under the [Apache License, Version 2.0](https://github.com/WebAssembly/spec/blob/main/test/LICENSE). \ No newline at end of file diff --git a/crates/wasm-testsuite/data b/crates/wasm-testsuite/data deleted file mode 160000 index 3d176e3..0000000 --- a/crates/wasm-testsuite/data +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3d176e3d5dfe70cb2f95afa2e590119d85e62603 diff --git a/crates/wasm-testsuite/lib.rs b/crates/wasm-testsuite/lib.rs deleted file mode 100644 index b2cc7d2..0000000 --- a/crates/wasm-testsuite/lib.rs +++ /dev/null @@ -1,86 +0,0 @@ -#![doc = include_str!("README.md")] -#![forbid(unsafe_code)] -#![doc(test( - no_crate_inject, - attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_assignments, unused_variables)) -))] -#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)] - -use rust_embed::RustEmbed; -use std::borrow::Cow; - -#[derive(RustEmbed)] -#[folder = "data/"] -#[include = "*.wast"] -struct OfficialTests; - -#[derive(RustEmbed)] -#[folder = "tests/"] -#[include = "*.wast"] -struct CustomTests; - -/// List of all supported proposals. Can be used to filter tests. -/// -/// Includes all proposals from -#[rustfmt::skip] -pub const PROPOSALS: &[&str] = &["annotations", "exception-handling", "extended-const", "function-references", "gc", "memory64", "multi-memory", "relaxed-simd", "tail-call", "threads", "custom-page-sizes", "wide-arithmetic", "wasm-3.0"]; - -/// List of all tests that apply to the MVP (V1) spec -/// Note that the tests are still for the latest spec, so the latest version of Wast is used. -#[rustfmt::skip] // removed: "break-drop.wast", -pub const MVP_TESTS: &[&str] = &["address.wast", "align.wast", "binary-leb128.wast", "binary.wast", "block.wast", "br.wast", "br_if.wast", "br_table.wast", "call.wast", "call_indirect.wast", "comments.wast", "const.wast", "conversions.wast", "custom.wast", "data.wast", "elem.wast", "endianness.wast", "exports.wast", "f32.wast", "f32_bitwise.wast", "f32_cmp.wast", "f64.wast", "f64_bitwise.wast", "f64_cmp.wast", "fac.wast", "float_exprs.wast", "float_literals.wast", "float_memory.wast", "float_misc.wast", "forward.wast", "func.wast", "func_ptrs.wast", "global.wast", "i32.wast", "i64.wast", "if.wast", "imports.wast", "inline-module.wast", "int_exprs.wast", "int_literals.wast", "labels.wast", "left-to-right.wast", "linking.wast", "load.wast", "local_get.wast", "local_set.wast", "local_tee.wast", "loop.wast", "memory.wast", "memory_grow.wast", "memory_redundancy.wast", "memory_size.wast", "memory_trap.wast", "names.wast", "nop.wast", "return.wast", "select.wast", "skip-stack-guard-page.wast", "stack.wast", "start.wast", "store.wast", "switch.wast", "table.wast", "token.wast", "traps.wast", "type.wast", "unreachable.wast", "unreached-valid.wast", "unreached-invalid.wast", "unwind.wast", "utf8-custom-section-id.wast", "utf8-import-field.wast", "utf8-import-module.wast", "utf8-invalid-encoding.wast"]; - -/// List of all tests that apply to the V2 draft 1 spec. -#[rustfmt::skip] -pub const V2_TESTS: &[&str] = &["address.wast", "align.wast", "binary-leb128.wast", "binary.wast", "block.wast", "br.wast", "br_if.wast", "br_table.wast", "bulk.wast", "call.wast", "call_indirect.wast", "comments.wast", "const.wast", "conversions.wast", "custom.wast", "data.wast", "elem.wast", "endianness.wast", "exports.wast", "f32.wast", "f32_bitwise.wast", "f32_cmp.wast", "f64.wast", "f64_bitwise.wast", "f64_cmp.wast", "fac.wast", "float_exprs.wast", "float_literals.wast", "float_memory.wast", "float_misc.wast", "forward.wast", "func.wast", "func_ptrs.wast", "global.wast", "i32.wast", "i64.wast", "if.wast", "imports.wast", "inline-module.wast", "int_exprs.wast", "int_literals.wast", "labels.wast", "left-to-right.wast", "linking.wast", "load.wast", "local_get.wast", "local_set.wast", "local_tee.wast", "loop.wast", "memory.wast", "memory_copy.wast", "memory_fill.wast", "memory_grow.wast", "memory_init.wast", "memory_redundancy.wast", "memory_size.wast", "memory_trap.wast", "names.wast", "nop.wast", "obsolete-keywords.wast", "ref_func.wast", "ref_is_null.wast", "ref_null.wast", "return.wast", "select.wast", "skip-stack-guard-page.wast", "stack.wast", "start.wast", "store.wast", "switch.wast", "table-sub.wast", "table.wast", "table_copy.wast", "table_fill.wast", "table_get.wast", "table_grow.wast", "table_init.wast", "table_set.wast", "table_size.wast", "token.wast", "traps.wast", "type.wast", "unreachable.wast", "unreached-invalid.wast", "unreached-valid.wast", "unwind.wast", "utf8-custom-section-id.wast", "utf8-import-field.wast", "utf8-import-module.wast", "utf8-invalid-encoding.wast"]; - -/// List of all tests that apply to the simd proposal -#[rustfmt::skip] -pub const SIMD_TESTS: &[&str] = &["simd_address.wast", "simd_align.wast", "simd_bit_shift.wast", "simd_bitwise.wast", "simd_boolean.wast", "simd_const.wast", "simd_conversions.wast", "simd_f32x4.wast", "simd_f32x4_arith.wast", "simd_f32x4_cmp.wast", "simd_f32x4_pmin_pmax.wast", "simd_f32x4_rounding.wast", "simd_f64x2.wast", "simd_f64x2_arith.wast", "simd_f64x2_cmp.wast", "simd_f64x2_pmin_pmax.wast", "simd_f64x2_rounding.wast", "simd_i16x8_arith.wast", "simd_i16x8_arith2.wast", "simd_i16x8_cmp.wast", "simd_i16x8_extadd_pairwise_i8x16.wast", "simd_i16x8_extmul_i8x16.wast", "simd_i16x8_q15mulr_sat_s.wast", "simd_i16x8_sat_arith.wast", "simd_i32x4_arith.wast", "simd_i32x4_arith2.wast", "simd_i32x4_cmp.wast", "simd_i32x4_dot_i16x8.wast", "simd_i32x4_extadd_pairwise_i16x8.wast", "simd_i32x4_extmul_i16x8.wast", "simd_i32x4_trunc_sat_f32x4.wast", "simd_i32x4_trunc_sat_f64x2.wast", "simd_i64x2_arith.wast", "simd_i64x2_arith2.wast", "simd_i64x2_cmp.wast", "simd_i64x2_extmul_i32x4.wast", "simd_i8x16_arith.wast", "simd_i8x16_arith2.wast", "simd_i8x16_cmp.wast", "simd_i8x16_sat_arith.wast", "simd_int_to_int_extend.wast", "simd_lane.wast", "simd_linking.wast", "simd_load.wast", "simd_load16_lane.wast", "simd_load32_lane.wast", "simd_load64_lane.wast", "simd_load8_lane.wast", "simd_load_extend.wast", "simd_load_splat.wast", "simd_load_zero.wast", "simd_splat.wast", "simd_store.wast", "simd_store16_lane.wast", "simd_store32_lane.wast", "simd_store64_lane.wast", "simd_store8_lane.wast"]; - -/// List of all tests that apply to a specific proposal. -pub fn get_proposal_tests(proposal: &str) -> impl Iterator + '_ { - OfficialTests::iter().chain(CustomTests::iter()).filter_map(move |x| { - let mut parts = x.split('/'); - if parts.next() == Some("proposals") && parts.next() == Some(proposal) { - Some(format!("{}/{}", proposal, parts.next().unwrap_or_default())) - } else { - None - } - }) -} - -/// Get the WAST file as a byte slice. -pub fn get_test_wast(name: &str) -> Option> { - assert!(name.ends_with(".wast"), "Expected .wast file. Got: {name}"); - - match name.contains('/') { - true => OfficialTests::get(&format!("proposals/{name}")) - .or_else(|| CustomTests::get(&format!("proposals/{name}"))) - .map(|x| x.data), - false => OfficialTests::get(name).or_else(|| CustomTests::get(name)).map(|x| x.data), - } -} - -#[cfg(test)] -mod tests { - use std::collections::HashSet; - - use super::*; - - #[test] - fn test_proposals() { - let mut unique_proposals = HashSet::new(); - - // check that all proposals are present - for proposal in OfficialTests::iter() { - if !proposal.starts_with("proposals/") { - continue; - } - - let proposal = proposal.split('/').nth(1).unwrap(); - unique_proposals.insert(proposal.to_owned()); - assert!(PROPOSALS.contains(&proposal), "Missing proposal: {}", proposal); - } - } -} diff --git a/crates/wasm-testsuite/tests/proposals/custom-page-sizes/custom-page-sizes-invalid.wast b/crates/wasm-testsuite/tests/proposals/custom-page-sizes/custom-page-sizes-invalid.wast deleted file mode 100644 index 150f58b..0000000 --- a/crates/wasm-testsuite/tests/proposals/custom-page-sizes/custom-page-sizes-invalid.wast +++ /dev/null @@ -1,112 +0,0 @@ -;; from https://github.com/WebAssembly/custom-page-sizes/blob/main/test/core/custom-page-sizes/custom-page-sizes-invalid.wast - -;; Page size that is not a power of two. -(assert_malformed - (module quote "(memory 0 (pagesize 3))") - "invalid custom page size" -) - -;; Power-of-two page sizes that are not 1 or 64KiB. -(assert_invalid - (module (memory 0 (pagesize 2))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 4))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 8))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 16))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 32))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 64))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 128))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 256))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 512))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 1024))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 2048))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 4096))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 8192))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 16384))) - "invalid custom page size" -) -(assert_invalid - (module (memory 0 (pagesize 32768))) - "invalid custom page size" -) - -;; Power-of-two page size that is larger than 64KiB. -(assert_invalid - (module (memory 0 (pagesize 0x20000))) - "invalid custom page size" -) - -;; Power of two page size that cannot fit in a u64 to exercise checks against -;; shift overflow. -(assert_malformed - (module binary - "\00asm" "\01\00\00\00" - "\05\04\01" ;; Memory section - - ;; memory 0 - "\08" ;; flags w/ custom page size - "\00" ;; minimum = 0 - "\41" ;; pagesize = 2**65 - ) - "invalid custom page size" -) - -;; Importing a memory with the wrong page size. - -(module $m - (memory (export "small-pages-memory") 0 (pagesize 1)) - (memory (export "large-pages-memory") 0 (pagesize 65536)) -) -(register "m" $m) - -(assert_unlinkable - (module - (memory (import "m" "small-pages-memory") 0 (pagesize 65536)) - ) - "incompatible import type" -) - -(assert_unlinkable - (module - (memory (import "m" "large-pages-memory") 0 (pagesize 1)) - ) - "incompatible import type" -) diff --git a/crates/wasm-testsuite/tests/proposals/custom-page-sizes/custom-page-sizes.wast b/crates/wasm-testsuite/tests/proposals/custom-page-sizes/custom-page-sizes.wast deleted file mode 100644 index f59d52b..0000000 --- a/crates/wasm-testsuite/tests/proposals/custom-page-sizes/custom-page-sizes.wast +++ /dev/null @@ -1,110 +0,0 @@ -;; from https://github.com/WebAssembly/custom-page-sizes/blob/main/test/core/custom-page-sizes/custom-page-sizes.wast - -;; Check all the valid custom page sizes. -(module (memory 1 (pagesize 1))) -(module (memory 1 (pagesize 65536))) - -;; Check them all again with maximums specified. -(module (memory 1 2 (pagesize 1))) -(module (memory 1 2 (pagesize 65536))) - -;; Check the behavior of memories with page size 1. -(module - (memory 0 (pagesize 1)) - (func (export "size") (result i32) - memory.size - ) - (func (export "grow") (param i32) (result i32) - (memory.grow (local.get 0)) - ) - (func (export "load") (param i32) (result i32) - (i32.load8_u (local.get 0)) - ) - (func (export "store") (param i32 i32) - (i32.store8 (local.get 0) (local.get 1)) - ) -) - -(assert_return (invoke "size") (i32.const 0)) -(assert_trap (invoke "load" (i32.const 0)) "out of bounds memory access") - -(assert_return (invoke "grow" (i32.const 65536)) (i32.const 0)) -(assert_return (invoke "size") (i32.const 65536)) -(assert_return (invoke "load" (i32.const 65535)) (i32.const 0)) -(assert_return (invoke "store" (i32.const 65535) (i32.const 1))) -(assert_return (invoke "load" (i32.const 65535)) (i32.const 1)) -(assert_trap (invoke "load" (i32.const 65536)) "out of bounds memory access") - -(assert_return (invoke "grow" (i32.const 65536)) (i32.const 65536)) -(assert_return (invoke "size") (i32.const 131072)) -(assert_return (invoke "load" (i32.const 131071)) (i32.const 0)) -(assert_return (invoke "store" (i32.const 131071) (i32.const 1))) -(assert_return (invoke "load" (i32.const 131071)) (i32.const 1)) -(assert_trap (invoke "load" (i32.const 131072)) "out of bounds memory access") - -;; Although smaller page sizes let us get to memories larger than 2**16 pages, -;; we can't do that with the default page size, even if we explicitly state it -;; as a custom page size. -(module - (memory 0 (pagesize 65536)) - (func (export "size") (result i32) - memory.size - ) - (func (export "grow") (param i32) (result i32) - (memory.grow (local.get 0)) - ) -) -(assert_return (invoke "size") (i32.const 0)) -(assert_return (invoke "grow" (i32.const 65537)) (i32.const -1)) -(assert_return (invoke "size") (i32.const 0)) - -;; Can copy between memories of different page sizes. -(module - (memory $small 10 (pagesize 1)) - (memory $large 1 (pagesize 65536)) - - (data (memory $small) (i32.const 0) "\11\22\33\44") - (data (memory $large) (i32.const 0) "\55\66\77\88") - - (func (export "copy-small-to-large") (param i32 i32 i32) - (memory.copy $large $small (local.get 0) (local.get 1) (local.get 2)) - ) - - (func (export "copy-large-to-small") (param i32 i32 i32) - (memory.copy $small $large (local.get 0) (local.get 1) (local.get 2)) - ) - - (func (export "load8-small") (param i32) (result i32) - (i32.load8_u $small (local.get 0)) - ) - - (func (export "load8-large") (param i32) (result i32) - (i32.load8_u $large (local.get 0)) - ) -) - -(assert_return (invoke "copy-small-to-large" (i32.const 6) (i32.const 0) (i32.const 2))) -(assert_return (invoke "load8-large" (i32.const 6)) (i32.const 0x11)) -(assert_return (invoke "load8-large" (i32.const 7)) (i32.const 0x22)) - -(assert_return (invoke "copy-large-to-small" (i32.const 4) (i32.const 1) (i32.const 3))) -(assert_return (invoke "load8-small" (i32.const 4)) (i32.const 0x66)) -(assert_return (invoke "load8-small" (i32.const 5)) (i32.const 0x77)) -(assert_return (invoke "load8-small" (i32.const 6)) (i32.const 0x88)) - -;; Can link together modules that export and import memories with custom page -;; sizes. - -(module $m - (memory (export "small-pages-memory") 0 (pagesize 1)) - (memory (export "large-pages-memory") 0 (pagesize 65536)) -) -(register "m" $m) - -(module - (memory (import "m" "small-pages-memory") 0 (pagesize 1)) -) - -(module - (memory (import "m" "large-pages-memory") 0 (pagesize 65536)) -)