summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/etc/wasm
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--js/src/jit-test/etc/wasm/Makefile26
-rw-r--r--js/src/jit-test/etc/wasm/README.md113
-rw-r--r--js/src/jit-test/etc/wasm/config-lock.toml15
-rw-r--r--js/src/jit-test/etc/wasm/config.toml68
4 files changed, 222 insertions, 0 deletions
diff --git a/js/src/jit-test/etc/wasm/Makefile b/js/src/jit-test/etc/wasm/Makefile
new file mode 100644
index 0000000000..688aeb83da
--- /dev/null
+++ b/js/src/jit-test/etc/wasm/Makefile
@@ -0,0 +1,26 @@
+.PHONY: update run expectations
+
+warning = '\# Wasm Spec Tests\n\nThese tests are autogenerated using a tool, do not edit.\n\nSee `jit-test/etc/wasm/` for more information.'
+
+update:
+ [ -d ./wasm-generate-testsuite ] || git clone https://github.com/eqrion/wasm-generate-testsuite ./wasm-generate-testsuite
+ cp ./config.toml ./wasm-generate-testsuite/config.toml
+ cp ./config-lock.toml ./wasm-generate-testsuite/config-lock.toml
+ (cd ./wasm-generate-testsuite && RUST_LOG=info cargo run)
+ cp ./wasm-generate-testsuite/config-lock.toml ./config-lock.toml
+ rm -r ../../tests/wasm/spec
+ cp -R wasm-generate-testsuite/tests/js ../../tests/wasm/spec
+ echo $(warning) > ../../tests/wasm/spec/README.md
+ [ ! -d ./spec-tests.patch ] || (cd ../../tests/wasm/spec && patch -u -p7 < ../../../etc/wasm/spec-tests.patch)
+ rm -r ../../../../../testing/web-platform/mozilla/tests/wasm
+ cp -R wasm-generate-testsuite/tests/wpt ../../../../../testing/web-platform/mozilla/tests/wasm
+ echo $(warning) > ../../../../../testing/web-platform/mozilla/tests/wasm/README.md
+
+run:
+ @[ -z $(MOZCONFIG) ] && echo "You need to define the MOZCONFIG env variable first."
+ @[ -z $(MOZCONFIG) ] || ../../../../../mach wpt /_mozilla/wasm
+
+expectations:
+ @[ -z $(MOZCONFIG) ] && echo "You need to define the MOZCONFIG env variable first." || true
+ @[ -z $(MOZCONFIG) ] || ../../../../../mach wpt /_mozilla/wasm --log-raw /tmp/expectations.log || true
+ @[ -z $(MOZCONFIG) ] || ../../../../../mach wpt-update /tmp/expectations.log --no-patch
diff --git a/js/src/jit-test/etc/wasm/README.md b/js/src/jit-test/etc/wasm/README.md
new file mode 100644
index 0000000000..bc1ad8bdac
--- /dev/null
+++ b/js/src/jit-test/etc/wasm/README.md
@@ -0,0 +1,113 @@
+# Wasm Spec Tests
+
+This directory contains scripts and configs to manage the in-tree import of the
+wasm spec testsuite.
+
+## Format of tests
+
+Spec tests are given in `test/core` of the `spec` repository as `.wast` files.
+A `.wast` file is a superset of the `.wat` format with commands for running
+tests.
+
+The spec interpreter can natively consume `.wast` files to run the tests, or
+generate `.js` files which rely on the WebAssembly JS-API plus a harness file
+to implement unit-test functionality.
+
+We rely on the spec interpreter to generate `.js` files for us to run.
+
+## Running tests
+
+Tests are imported to `jit-test` and `wpt` to be run in both the JS shell or the
+browser.
+
+To run under `jit-test`:
+```bash
+cd js/src
+./jit-test.py path_to_build/dist/bin/js wasm/spec/
+```
+
+To run under `wpt` (generally not necessary):
+```bash
+./mach web-platform-test testing/web-platform/mozilla/tests/wasm/
+```
+
+## Test importing
+
+There are many proposals in addition to the canonical spec. Each proposal is a
+fork of the canonical spec and may modify any amount of files.
+
+This causes a challenge for any engine implementing multiple proposals, as any
+proposal may conflict (and often will) with each other. This makes it
+infeasible to merge all spec and proposal repos together.
+
+Testing each proposal separately in full isn't an attractive option either, as
+most tests are unchanged and that would cause a significant amount of wasted
+computation time.
+
+For this reason, we use a tool [1] to generate a set of separate test-suites
+that are 'pruned' to obtain a minimal set of tests. The tool works by merging
+each proposal with the proposal it is based off of and removing tests that
+have not changed.
+
+[1] https://github.com/eqrion/wasm-generate-testsuite
+
+### Configuration
+
+The import tool relies on `config.toml` for the list of proposals to import,
+and `config-lock.toml` for a list of commits to use for each proposal.
+
+The lock file makes test importing deterministic and controllable. This is
+useful as proposals often make inconvenient and breaking changes.
+
+### Operation
+
+```bash
+# Add, remove, or modify proposals
+vim config.toml
+# Remove locks for any proposals you wish to pull the latest changes on
+vim config-lock.toml
+# Import the tests
+make update
+# View the tests that were imported
+hg stat
+# Run the imported tests and note failures
+./jit-test.py dist/bin/js wasm/spec/
+# Exclude test failures
+vim config.toml
+# Re-import the tests to exclude failing tests
+make update
+# Commit the changes
+hg commit
+```
+
+### Debugging test failures
+
+Imported tests use the binary format, which is inconvenient for understanding
+why a test is failing.
+
+Luckily, each assertion in an imported test contains the line of the source file
+that it corresponds with.
+
+Unfortunately, the '.wast' files are not commited in the tree and so you must
+use the import tool to get the original source.
+
+Follow the steps in 'Operation' to get a `wasm-generate-testsuite` repo with
+the '.wast' files of each proposal. All proposals are stored in a single git
+repo named `specs/`. Each proposal is a branch, and you can find all tests
+under `test/core`.
+
+### Debugging import failures
+
+Proposals can often have conflicts with their upstream proposals. This is okay,
+and the test importer will fallback to building tests on an unmerged tree.
+
+This will likely result in extra tests being imported due to spurious
+differences between the proposal and upstream, but generally is okay.
+
+It's also possible that a proposal is 'broken' and fails to generate '.js' test
+files with the spec interpreter. The best way to debug this is to check out the
+proposal repo and debug why `./test/build.py` is failing.
+
+The import tool uses `RUST_LOG` to output debug information. `Makefile`
+automatically uses `RUST_LOG=info`. Change that to `RUST_LOG=debug` to get
+verbose output of all the commands run.
diff --git a/js/src/jit-test/etc/wasm/config-lock.toml b/js/src/jit-test/etc/wasm/config-lock.toml
new file mode 100644
index 0000000000..308f4138af
--- /dev/null
+++ b/js/src/jit-test/etc/wasm/config-lock.toml
@@ -0,0 +1,15 @@
+[[repos]]
+name = 'threads'
+commit = 'dfdcb81a'
+
+[[repos]]
+name = 'bulk-memory-operations'
+commit = '66d90a7d'
+
+[[repos]]
+name = 'reference-types'
+commit = '9df8a3e3'
+
+[[repos]]
+name = 'spec'
+commit = '7c4cbf32'
diff --git a/js/src/jit-test/etc/wasm/config.toml b/js/src/jit-test/etc/wasm/config.toml
new file mode 100644
index 0000000000..4d2667b00b
--- /dev/null
+++ b/js/src/jit-test/etc/wasm/config.toml
@@ -0,0 +1,68 @@
+# Standard 'directives.txt' prologues for jit-tests
+harness_directive = "|jit-test| skip-if: true"
+directive = "|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm-testharness.js; local-include:harness/sync_index.js"
+
+# Failing tests across all testsuites
+excluded_tests = [
+ # false-positive windows-specific failures
+ "align.wast",
+ # bulk-memory-operations/issues/133 (data.wast:161)
+ "data.wast",
+ # testing that multiple tables fail (imports.wast:309)
+ "imports.wast",
+ # bulk-memory-operations/issues/133 (linking.wast:206)
+ "linking.wast",
+ # bulk-memory-operations/issues/133 (elem.wast:142)
+ "elem.wast",
+ # test harness doesn't acquire global values correctly
+ "exports.wast",
+ # false-positive windows-specific failure
+ "memory_trap.wast",
+ # false-positive error on duplicate export name (names.wast:19)
+ "names.wast",
+ # false-positive error on invalid UTF-8 custom section name (utf8-custom-section-id.wast:6)
+ "utf8-custom-section-id.wast",
+ # invalid table maximum length for web embeddings
+ "table.wast",
+ # fails after a bottom-type has been added to validation
+ "unreached-invalid.wast",
+]
+
+[[repos]]
+name = "spec"
+url = "https://github.com/WebAssembly/spec"
+excluded_tests = []
+
+[[repos]]
+name = "threads"
+url = "https://github.com/WebAssembly/threads"
+parent = "spec"
+excluded_tests = [
+ "atomic.wast",
+ # testing that multi-value isn't implemented (func.wast:492)
+ "func.wast",
+ # testing that multi-value isn't implemented (type.wast:52)
+ "type.wast"
+]
+# Skip in WPT where we can't guard on features being enabled
+skip_wpt = true
+# Skip in jit-test when it's not enabled
+directive = "; skip-if: !wasmThreadsEnabled()"
+
+[[repos]]
+name = "bulk-memory-operations"
+url = "https://github.com/WebAssembly/bulk-memory-operations"
+parent = "spec"
+excluded_tests = []
+# Skip in WPT where we can't guard on features being enabled
+skip_wpt = true
+
+[[repos]]
+name = "reference-types"
+url = "https://github.com/WebAssembly/reference-types"
+parent = "spec"
+excluded_tests = []
+# Skip in WPT where we can't guard on features being enabled
+skip_wpt = true
+# Skip in jit-test when it's not enabled
+directive = "; skip-if: !wasmReftypesEnabled()"