wasmer/spectests/README.md

149 lines
5.0 KiB
Markdown
Raw Normal View History

2018-10-19 09:42:51 +00:00
This directory contains tests for the core WebAssembly semantics, as described in [Semantics.md](https://github.com/WebAssembly/design/blob/master/Semantics.md) and specified by the [spec interpreter](https://github.com/WebAssembly/spec/blob/master/interpreter/spec).
This files should be a direct copy of the original [WebAssembly spec tests](https://github.com/WebAssembly/spec/tree/master/test/core).
Tests are written in the [S-Expression script format](https://github.com/WebAssembly/spec/blob/master/interpreter/README.md#s-expression-syntax) defined by the interpreter.
## Autogenerated Rust test cases
This files will serve as base for autogenerating Rust testcases
2018-10-23 21:54:07 +00:00
when `WASM_GENERATE_SPECTESTS=1 cargo build` is executed
([src/build_spectests.rs](https://github.com/wasmerio/wasmer/blob/master/src/build_spectests.rs)).
2018-10-19 09:42:51 +00:00
The result autogenerated spectests live in the [src/spectests](https://github.com/wasmerio/wasmer/tree/master/src/spectests)
2018-10-19 09:42:51 +00:00
directory.
## Testcases
Currently supported command assertions:
- [x] Module _mostly implemented_ (it should support named modules `(module $Xx)`).
- [x] AssertReturn _mostly implemented_ (it should support calls to named modules `(invoke $Xx "call")`).
- [x] AssertReturnCanonicalNan _fully implemented_
- [x] AssertReturnArithmeticNan _fully implemented_
- [x] AssertTrap _fully implemented_
- [x] AssertInvalid _Fully implemented_ (it should not require to do validation separate from compilation)
- [x] AssertMalformed _Fully implemented_
2018-10-29 13:10:42 +00:00
- [ ] AssertUninstantiable _not implemented yet_
- [ ] AssertExhaustion _not implemented yet_
- [ ] Register _not implemented yet_
- [x] PerformAction _partially implemented, only function invokations for now_
2018-10-29 14:38:02 +00:00
### Covered spectests
This spectests are currently covered:
- address.wast ✅
- align.wast ✅
2018-10-29 23:32:53 +00:00
- binary.wast ✅
2018-10-29 14:38:02 +00:00
- block.wast ✅
- br.wast ✅
- br_if.wast ✅
- br_table.wast ✅
- break-drop.wast ✅
- call.wast ✅
- call_indirect.wast ✅
2018-10-29 23:34:46 +00:00
- comments.wast ✅
2018-10-29 14:38:02 +00:00
- const.wast ✅
- conversions.wast ✅
2018-10-30 11:05:00 +00:00
- custom.wast ✅
2018-10-29 14:38:02 +00:00
- data.wast ✅
- elem.wast
- endianness.wast ✅
- exports.wast ✅
- f32.wast ✅
- f32_bitwise.wast ✅
- f32_cmp.wast ✅
- f64.wast ✅
- f64_bitwise.wast ✅
- f64_cmp.wast ✅
2018-10-30 10:59:51 +00:00
- fac.wast ✅
2018-10-30 11:02:50 +00:00
- float_exprs.wast ✅
2018-10-29 14:38:02 +00:00
- float_literals.wast ✅
2018-10-30 11:07:00 +00:00
- float_memory.wast ✅
2018-10-30 11:09:07 +00:00
- float_misc.wast ✅
2018-10-30 11:10:48 +00:00
- forward.wast ✅
2018-10-29 23:39:26 +00:00
- func.wast ✅
2018-10-29 14:38:02 +00:00
- func_ptrs.wast ✅
- get_local.wast ✅
- globals.wast ✅
- i32.wast ✅
- i64.wast ✅
2018-10-29 15:15:42 +00:00
- if.wast ✅
2018-10-29 14:38:02 +00:00
- imports.wast
- inline-module.wast
2018-10-30 11:13:15 +00:00
- int_exprs.wast ✅
2018-10-30 11:15:47 +00:00
- int_literals.wast ✅
2018-10-29 14:38:02 +00:00
- labels.wast ✅
- left-to-right.wast ✅
- linking.wast
- loop.wast ✅
- memory.wast ✅
2018-11-18 19:13:20 +00:00
- memory_grow.wast ✅
2018-10-29 14:38:02 +00:00
- memory_redundancy.wast ✅
- memory_trap.wast
- names.wast ✅
2018-10-30 11:19:45 +00:00
- nop.wast ✅
2018-10-29 14:38:02 +00:00
- return.wast ✅
- select.wast ✅
- set_local.wast ✅
- skip-stack-guard-page.wast
2018-10-30 11:21:03 +00:00
- stack.wast ✅
2018-10-29 22:44:43 +00:00
- start.wast ✅
2018-10-30 11:23:37 +00:00
- store_retval.wast ✅
2018-10-29 14:38:02 +00:00
- switch.wast ✅
- tee_local.wast ✅
2018-11-14 01:41:29 +00:00
- token.wast ✅
2018-11-14 01:39:07 +00:00
- traps.wast ✅
2018-10-29 14:38:02 +00:00
- type.wast ✅
2018-10-30 11:25:31 +00:00
- typecheck.wast ✅
2018-10-29 14:38:02 +00:00
- unreachable.wast
- unreached-invalid.wast
- unwind.wast
- utf8-custom-section-id.wast
- utf8-import-field.wast
- utf8-import-module.wast
- utf8-invalid-encoding.wast
### Specific non-supported cases
There are some cases that we decided to skip for now to fasten the time to release:
2018-10-29 23:16:00 +00:00
- `SKIP_MUTABLE_GLOBALS`: Right now the WASM parser can't validate a module with imported/exported mut globals. We decided to skip the tests until Cranelift and wasmparser can handle this (original spec proposal: https://github.com/WebAssembly/mutable-global). Spectests affected:
- `globals.wast`
- `SKIP_CALL_INDIRECT_TYPE_MISMATCH`: we implemented traps in a fast way. We haven't covered yet the type mismatch on `call_indirect`. Specs affected:
2018-11-18 19:13:20 +00:00
- `call_indirect.wast`
- `SKIP_CALL_UNDEFINED_ELEMENT`
2018-11-18 19:13:20 +00:00
Tables are imported into every spec module, even for modules that don't expect it. We need to figure out a way to prevent import of objects that are not explicitly imported into the module.
Currently cranelift_wasm::ModuleEnvironment does not provide `declare_table_import`, etc. so there is no meaningful way of fixing this yet.
2018-11-18 19:13:20 +00:00
- `call_indirect.wast`
- `SKIP_SHARED_TABLE` [elem.wast]
2018-11-18 19:13:20 +00:00
Currently sharing tables between instances/modules does not work. Below are some of the reasons it is hard to achieve.
- Rust naturally prevents such because of the possibility of race conditions
- ImportObject is just a wrapper, what we really care about is references to its content.
- Instance::new contains a mutation points, the part where after getting the object (memory or table) we push values to it
table[table_element_index] = func_addr
- Instance has its own created memories and tables and references to them must outlive Instance::new()
- Possible strategy
2018-11-18 19:13:20 +00:00
```rust
// ImportObject should be passed by ref
Instance::new<'a>(..., &ImportObject);
// Add OwnedData to Instance struct
struct OwnedData;
// For parts where mutatation is really needed
fn get_mut(&import) -> &mut ImportObject {
unsafe { transmute::<&ImportObject, &mut ImportObject>(import) }
}
```
2018-11-18 19:13:20 +00:00
- `elem.wast`