summaryrefslogtreecommitdiff
path: root/scripts/test/wasm2js.py
Commit message (Collapse)AuthorAgeFilesLines
* [wasm2js] Run LLVM nontrapping fptoint lowering when running for emscripten ↵Derek Schuff2024-11-261-4/+5
| | | | | | (#7116) Lower away saturating fptoint operations when we know we are using emscripten.
* [tests] Fix wasm2js test command line generation (#7114)Derek Schuff2024-11-251-2/+2
| | | | | | | | | --emscripten is added to the command line if the filename contains the string 'emscripten', but the current logic includes the cwd, so it fails if the tests are run from a directory with 'emscripten' in the name. Fix it so the test only includes the basename.
* Support `ref.extern n` in spec tests (#6858)Thomas Lively2024-08-211-0/+1
| | | | | | | | | | | | | | | | | Spec tests pass the value `ref.extern n`, where `n` is some integer, into exported functions that expect to receive externrefs and receive such values back out as return values. The payload serves to distinguish externrefs so the test can assert that the correct one was returned. Parse these values in wast scripts and represent them as externalized i31refs carrying the payload. We will need a different representation eventually, since some tests explicitly expect these externrefs to not be i31refs, but this suffices to get several new tests passing. To get the memory64 version of table_grow.wast passing, additionally fix the interpreter to handle growing 64-bit tables correctly. Delete the local versions of the upstream tests that can now be run successfully.
* Add the upstream spec testsuite as a submodule (#6853)Thomas Lively2024-08-201-3/+6
| | | | | | Run the upstream tests by default, except for a large list of them that do not successfully run. Remove the local version of those that do successfully run where the local version is entirely subsumed by the upstream version.
* [test] Port tests in test/ to test/lit/basic/ (#6160)Heejin Ahn2023-12-131-5/+5
| | | | | | | | | | | | | | | | | | | | | This ports all tests from `test/` to `test/lit/basic/`. The set of commands and `CHECK` lines used are the same as the ones in #6159. Now we use `lit` to test these, this also deletes all `.wast`, `.wast.from-wast`, `.wast.fromBinary`, and `.wast.fromBinary.noDebugInfo` files from `test/` and all related test routines from the python scripts. All `CHECK` lines are generated by `update_lit_checks.py --all-items`. This also deletes these three multi-memory tests in `test/lit/`, because they seem to contain the same code with the ones in `test/`, which have been ported to `test/lit/basic/` along with other tests. - `test/lit/multi-memories-atomics64.wast` - `test/lit/multi-memories-basics.wast` - `test/lit/multi-memories-simd.wast` This also adds newlines between `(func`s in case there are none to make `CHECK` lines easy to view, and removes some extra existing newlines here and there.
* [test] Fix wasm2js stale check failure (#6168)Heejin Ahn2023-12-111-2/+2
| | | | | | | I tried to exclude wasm2js asserts tests from `check_for_stale_files` in #6164, but ended up doing it incorrectly. The file I checked for was `wasm2js.wast.asserts`, while the output I should have excluded was `wasm2js.asserts.js`. This fixes the code so we now check the prefix and not the filename.
* [test] Remove / move *.js tests from test/ (#6163)Heejin Ahn2023-12-111-4/+4
| | | | | | | | | | | | | `wasm2js.asserts.js` and `wasm2js.traps.js` seem to be used in wasm2js asserts test: https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L28 https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L126-L127 But other `*.js` tests in `test/` don't seem to be used anywhere. Please let me know if they are actually being used. This moves `wasm2js.asserts.js` and `wasm2js.traps.js`, which are only used in wasmjs tests, to `test/wasm2js/`, and deletes all other `*.js` tests in `test/`.
* [test] Make get_tests return only files (#6164)Heejin Ahn2023-12-111-0/+2
| | | | | | | | | | | | | | | | | | | | Currently `get_tests` returns files and directories, especially when the extension is not given. This makes `get_tests` return a directory like `test/wasm2js/` as a test. `wasm2js.py`'s `check_for_stale_files` errors out when there are files within `test/wasm2js/` whose basenames don't match any files within any of `test/`, `test/spec/`, `test/wasm2js/`. https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L33-L46 `wasm2js.wast.asserts` is apparently a special case for asserts test: https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L28 and this doesn't seem to have the matching `wast` tests in the three test directories. But it just happened to not error out because `get_tests` returns directory names too and one of them was `wasm2js` (`test/wasm2js/` directory). This makes `get_tests` return only files, and make files in `assert_tests` not error out additionally.
* Remove various testing spam (#6109)Alon Zakai2023-11-141-1/+2
| | | | | Avoid some common warnings and stop printing various stdout/stderr stuff. Helps #6104
* Move `auto_update_tests.py` into scripts directory. NFC (#4879)Sam Clegg2022-08-111-2/+2
| | | | So it lives alongside `update_lit_checks.py` and `update_help_checks.py`
* wasm2js: override incoming memory's grow method (#3185)Sam Clegg2020-09-301-0/+3
| | | | | | | | | | This will allow for the completely removal of `__growWasmMemory` as a followup. We currently unconditionally generate this function in `generateMemoryGrowthFunction`. See #3180
* Remove stale test output (#3157)Sam Clegg2020-09-211-0/+14
| | | | | | | | | | | | These test output files are ignored and so contain stale output that is neither checked during `check.py` not updated during `auto_update_tests.py`. There are three clases to tests here: 1. Spec tests that end in 64.wast are ignored by scripts/test/wasm2js.py 2. Spec tests that are globallyi ignoed by shared.py:SPEC_TESTS_TO_SKIP 3. hello_world.2asm.js.. I cant tell where this came remove it seems like an anomaly.
* Initial implementation of "Memory64" proposal (#3130)Wouter van Oortmerssen2020-09-181-0/+3
| | | Also includes a lot of new spec tests that eventually need to go into the spec repo
* Skip tests that fail on windows and enable all the rest (#3035)Alon Zakai2020-08-111-0/+2
| | | | | | | | | | | | | | This lets us run most tests at least on that platform. Add a new function for skipping those tests, skip_if_on_windows, so that it's easy to find which tests are disabled on windows for later fixing efforts. This fixes a few minor issues for windows, like comparisons should ignore \r in some cases. Rename all passes tests that use --dwarfdump to contain "dwarf" in their name, which makes it easy to skip those (and is clearer anyhow).
* Disable nodejs warnings in test suite (#2973)rathann2020-07-221-1/+1
| | | | | | | | | | | | Fixes issue #2970 Avoids "Exception: 'run_command unexpected stderr'" when running wasm2js tests with nodejs-14.5.0+, which is due to extra warnings from that node: $ cd out/test/ $ /usr/bin/node --experimental-modules --loader /builddir/build/BUILD/binaryen-version_95/scripts/test/node-esm-loader.mjs a.2asm.mjs (node:187299) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time (Use `node --trace-warnings ...` to show where the warning was created)
* wasm2js testing improvements before bulk-memory (#2918)Alon Zakai2020-06-201-9/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Necessary preparations for a later PR that adds bulk memory support to wasm2js (splitting this out so the next PR is less big): * Fix logging of print functions in wasm2js spec tests, there was an extra space in the output (which console.log adds automatically between items). * Don't assume the output is always empty, as some tests (like bulk memory) do have expected output. * Rename test/bulk-memory.wast as it "conflicts" with test/spec/bulk-memory.wast - the problem is that we scan both places, and emit files in test/wasm2js/*, so those would collide if the names overlap. * Extend the parsing and emitting of JS for (assert.. ) lines such as (assert_return (invoke "foo" (i32.const 1)) (i32.const 2)) to also handle (invoke "foo" (i32.const 1)) (i32.const 2)) Without this, we skip (invoke ..) lines in spec tests, which normally is fine, but in bulk memory at least they have side effects we need - we must run them before the later assertions.
* Add --deterministic flag to wasm2js, for fuzzing (#2757)Alon Zakai2020-04-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | In wasm2js we ignore things that trap in wasm that we can't really handle, like a load from memory out of bounds would trap in wasm, but in JS we don't want to emit a bounds check on each load. So wasm2js focuses on programs that don't trap. However, this is annoying in the fuzzer as it turns out that our behavior for places where wasm would trap was not deterministic. That is, wasm would trap, wasm2js would not trap and do behavior X, and wasm2js with optimizations would also not trap but do behavior Y != X. This produced false positives in the fuzzer (and might be annoying in manual debugging too). As a workaround, this adds a --deterministic flag to wasm2js, which tries to be deterministic about what it does for cases where wasm would trap. This handles the case of an int division by 0 which traps in wasm but without this flag could have different behavior in wasm2js with or without opts (see details in the patch).
* Remove executable bit from test scripts (#2734)Sam Clegg2020-04-091-6/+0
| | | | | | | | | | | | | | | | | | These are no all driven by only by the two top level scripts: check.py auto_update_tests.py What is more all of them were broken when run isolation due to relative import rules in python3. e.g.: ``` $ scripts/test/binaryenjs.py Traceback (most recent call last): File "scripts/test/binaryenjs.py", line 21, in <module> from . import shared ImportError: cannot import name 'shared' from '__main__' (scripts/test/binaryenjs.py) ```
* Add EH support for EffectAnalyzer (#2631)Heejin Ahn2020-02-031-4/+11
| | | | | | | | | | | | | | | | | | | | This adds EH support to `EffectAnalyzer`. Before `throw` and `rethrow` conservatively set property. Now `EffectAnalyzer` has a new property `throws` to represent an expression that can throw, and expression that can throw sets `throws` correctly. When EH is enabled, any calls can throw too, so we cannot reorder them with another expression with any side effects, meaning all calls should be treated in the same way as branches when evaluating `invalidate`. This prevents many reorderings, so this patch sets `throws` for calls only when the exception handling features is enabled. This is also why I passed `--disable-exception-handling` to `wasm2js` tests. Most of code changes outside of `EffectAnalyzer` class was made in order to pass `FeatureSet` to it. `throws` isn't always set whenever an expression contains a throwable instruction. When an throwable instruction is within an inner try, it will be caught by the corresponding inner catch, so it does not set `throws`.
* Update spec test suite (#2484)Heejin Ahn2019-11-291-1/+1
| | | | | | | | | | | | | This updates spec test suite to that of the current up-to-date version of https://github.com/WebAssembly/spec repo. - All failing tests are added in `BLACKLIST` in shared.py with reasons. - For tests that already existed and was passing and started failing after the update, we add the new test to the blacklist and preserve the old file by renaming it to 'old_[FILENAME].wast' not to lose test coverage. When the cause of the error is fixed or the unsupported construct gets support so the new test passes, we can delete the corresponding 'old_[FILENAME].wast' file. - Adds support for `spectest.print_[type] style imports.
* Use package name in imports (NFC) (#2462)Heejin Ahn2019-11-221-44/+41
| | | | | Don't directly import names from shared.py and support.py, and use prefixes instead. Also this reorders imports based on PEP recommendation.
* Fix syntax errors from #2457 (#2460)Heejin Ahn2019-11-201-1/+1
|
* Simplify test scripts (NFC) (#2457)Heejin Ahn2019-11-201-23/+15
| | | | | | | | This makes test scripts simpler by reducing loop depths and extracting repeating code into methods or variables. - `get_tests` returns a list of tests with specified extensions. This includes files with a full path rather than just file names. - Reduces loop depths by using early exits and `get_tests`.
* Upgrade the build container for linux releases (#2405)Alex Crichton2019-10-251-1/+1
| | | | | | | | This is a continued effort to try and track down #2273 which came up again and is still present in the current release binaries. Issues like crystal-lang/crystal#4276 may indicate that C++ exceptions are just somewhat broken with static linking when using alpine, but I've at least locally been able to verify that upgrading the container produces working binaries which previously segfaulted on some wasm files.
* [wasm2js] Fix memory.size (#2330)Alon Zakai2019-09-051-2/+2
| | | | | | | We emitted the __wasm_memory_size function only when memory growth was enabled, but it can be used without that too. In theory we could only emit it if either memory growth or memory.size is used, but I think we can expect JS minifiers to do that later. Also fix a test suite bug - the check/auto_update script didn't run all the wasm2js tests when you run it with argument wasm2js (it used that as the list of tests, instead of the list of files, which confused me here for a while...).
* Allow all features on wasm2js and add atomic tests (#2311)Heejin Ahn2019-08-281-4/+4
| | | | | | This adds `-all` argument to wasm2js testing and fixes wasm2js to actually take that argument (currently it doesn't, when it takes a wast file). This also adds a wasm2js test for `atomic.fence` instruction that was added in #2307.
* Fix auto_update_tests.py after #2114 (#2306)Sam Clegg2019-08-261-2/+2
|
* Remove test output from source tree (#2114)Sam Clegg2019-08-211-1/+2
|
* Switch python indentation from 2-space to 4-space (#2299)Sam Clegg2019-08-161-110/+110
| | | | | | | | pep8 specifies 4 space indentation. The use of 2 spaces is, I believe a historical anomaly where certain large organizations such as google chose 2 over 4 and have yet to make the switch. Since there isn't too much code in binaryen today it seems reasonable to make the switch.
* Python3-ify check.py and auto_update_tests.py (#2270)Alon Zakai2019-07-311-14/+12
| | | | | I fixed flatten.bin.txt which seems to have just had some corrupted data, and I removed some fancy unicode from the spec comments tests, which I'm not sure it's important enough to figure out how to fix. Fixes #1691
* wasm2js: run full optimizations during the pipeline (#2071)Alon Zakai2019-04-301-70/+80
| | | | | We flatten for the i64 lowering etc. passes, and it is worth optimizing afterwards, to clean up stuff they created. That is run if the user ran wasm2js with an optimization level (like wasm2js -O3). Split the test files to check both optimized and unoptimized code.
* wasm2js: start to optionally optimize the JS (#2046)Alon Zakai2019-04-241-2/+2
| | | Removes redundant | 0s and similar things. (Apparently closure compiler doesn't do that, so makes sense to do here.)
* wasm2js: unreachability fixes (#2037)Alon Zakai2019-04-221-1/+3
| | | Also test in pass-debug mode, for better coverage.
* Wasm2js memory fixes (#2003)Alon Zakai2019-04-121-30/+50
| | | | | | | | * I64ToI32Lowering - don't assume address 0 is a hardcoded location for scratch memory. Import __tempMemory__ for that. * RemoveNonJSOps - also use __tempMemory__. Oddly here the address was a hardcoded 1024 (perhaps where the rust program put a static global?). * Support imported ints in wasm2js, coercing them as needed. * Add "env" import support in the tests, since now we emit imports from there. * Make wasm2js tests split out multi-module tests using split_wast which is more robust and avoids emitting multiple outputs in one file (which makes no sense for ES6 modules)
* wasm2js: emscripten glue option (#2000)Alon Zakai2019-04-111-0/+4
| | | | | | Add a wasm2js option for the glue to be in emscripten-compatible format (as opposed to ES6). This does a few things so far: * Emit START_FUNCTIONS, END_FUNCTIONS markers in the code, for future use in the optimizer. * Emit the glue as a function to be called from emscripten.
* Improve test scripts (#1959)* Improve test scripts * feedback [skip ci]Sam Clegg2019-03-211-0/+46
| | | | | - Move auto_update_tests.py code into respective scripts - Use shared argument parsing in generate_lld_tests.py - Use wasm-ld rather than passing -flavor
* Rename `wasm2asm` to `wasm2js`, emit ESM by default (#1642)Alex Crichton2018-08-301-0/+110
* Rename the `wasm2asm` tool to `wasm2js` This commit performs a relatively simple rename of the `wasm2asm` tool to `wasm2js`. The functionality of the tool doesn't change just yet but it's intended that we'll start generating an ES module instead of just an `asm.js` function soon. * wasm2js: Support `*.wasm` input files Previously `wasm2js` only supported `*.wast` files but to make it a bit easier to use in tooling pipelines this commit adds support for reading in a `*.wasm` file directly. Determining which parser to use depends on the input filename, where the binary parser is used with `*.wasm` files and the wast parser is used for all other files. * wasm2js: Emit ESM imports/exports by default This commit alters the default behavior of `wasm2js` to emit an ESM by default, either importing items from the environment or exporting. Items like initialization of memory are also handled here.