mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-29 06:32:17 +00:00
test suite support iniital
This commit is contained in:
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[submodule "spec/wabt"]
|
||||||
|
path = spec/wabt
|
||||||
|
url = https://github.com/WebAssembly/wabt
|
||||||
|
[submodule "spec/testsuite"]
|
||||||
|
path = spec/testsuite
|
||||||
|
url = https://github.com/WebAssembly/testsuite
|
@ -9,7 +9,7 @@ homepage = "https://github.com/nikvolf/parity-wasm"
|
|||||||
documentation = "https://nikvolf.github.io/parity-wasm/parity_wasm/"
|
documentation = "https://nikvolf.github.io/parity-wasm/parity_wasm/"
|
||||||
description = "WebAssembly binary format serialization/deserialization/interpreter"
|
description = "WebAssembly binary format serialization/deserialization/interpreter"
|
||||||
keywords = ["wasm", "webassembly", "bytecode", "serde", "interpreter"]
|
keywords = ["wasm", "webassembly", "bytecode", "serde", "interpreter"]
|
||||||
exclude = [ "res/*" ]
|
exclude = [ "res/*", "spec/*" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
byteorder = "1.0"
|
byteorder = "1.0"
|
||||||
|
25
spec/Cargo.toml
Normal file
25
spec/Cargo.toml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
[package]
|
||||||
|
name = "parity-wasm-testsuite"
|
||||||
|
version = "0.5.6"
|
||||||
|
authors = ["NikVolf <nikvolf@gmail.com>"]
|
||||||
|
license = "MIT/Apache-2.0"
|
||||||
|
readme = "README.md"
|
||||||
|
repository = "https://github.com/nikvolf/parity-wasm"
|
||||||
|
homepage = "https://github.com/nikvolf/parity-wasm"
|
||||||
|
description = "parity-wasm testsuite"
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
cmake = "0.1"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
parity-wasm = { path = ".." }
|
||||||
|
serde_json = "1.0"
|
||||||
|
serde_derive = "1.0"
|
||||||
|
serde = "1.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
parity-wasm = { path = ".." }
|
||||||
|
serde_json = "1.0"
|
||||||
|
serde_derive = "1.0"
|
||||||
|
serde = "1.0"
|
8
spec/build.rs
Normal file
8
spec/build.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
extern crate cmake;
|
||||||
|
use cmake::Config;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _dst = Config::new("wabt")
|
||||||
|
.define("BUILD_TESTS", "OFF")
|
||||||
|
.build();
|
||||||
|
}
|
7
spec/src/lib.rs
Normal file
7
spec/src/lib.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#[macro_use] extern crate serde_derive;
|
||||||
|
extern crate parity_wasm;
|
||||||
|
extern crate serde;
|
||||||
|
extern crate serde_json;
|
||||||
|
|
||||||
|
mod run;
|
||||||
|
mod test;
|
35
spec/src/run.rs
Normal file
35
spec/src/run.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#![cfg(test)]
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::process::Command;
|
||||||
|
use std::fs::File;
|
||||||
|
|
||||||
|
use serde_json;
|
||||||
|
use test;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn i32_tests() {
|
||||||
|
let outdir = env::var("OUT_DIR").unwrap();
|
||||||
|
println!("outdir {}", outdir);
|
||||||
|
|
||||||
|
let spec_name = "i32";
|
||||||
|
|
||||||
|
let mut wast2wasm_path = PathBuf::from(outdir.clone());
|
||||||
|
wast2wasm_path.push("bin");
|
||||||
|
wast2wasm_path.push("wast2wasm");
|
||||||
|
|
||||||
|
let mut json_spec_path = PathBuf::from(outdir.clone());
|
||||||
|
json_spec_path.push(&format!("{}.json", spec_name));
|
||||||
|
|
||||||
|
let _output = Command::new(wast2wasm_path)
|
||||||
|
.arg("--spec")
|
||||||
|
.arg("-o")
|
||||||
|
.arg(&json_spec_path)
|
||||||
|
.arg(&format!("./testsuite/{}.wast", spec_name))
|
||||||
|
.output()
|
||||||
|
.expect("Failed to execute process");
|
||||||
|
|
||||||
|
let mut f = File::open(&format!("{}/{}.json", outdir, spec_name)).unwrap();
|
||||||
|
let commands: test::Commands = serde_json::from_reader(&mut f).unwrap();
|
||||||
|
}
|
40
spec/src/test.rs
Normal file
40
spec/src/test.rs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#![cfg(test)]
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct RuntimeValue {
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
value_type: String,
|
||||||
|
value: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
pub enum Action {
|
||||||
|
#[serde(rename = "invoke")]
|
||||||
|
Invoke { field: String, args: Vec<RuntimeValue> }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
pub enum Command {
|
||||||
|
#[serde(rename = "module")]
|
||||||
|
Module { line: u64, filename: String },
|
||||||
|
#[serde(rename = "assert_return")]
|
||||||
|
AssertReturn {
|
||||||
|
line: u64,
|
||||||
|
action: Action,
|
||||||
|
expected: Vec<RuntimeValue>,
|
||||||
|
},
|
||||||
|
#[serde(rename = "assert_trap")]
|
||||||
|
AssertTrap {
|
||||||
|
line: u64,
|
||||||
|
action: Action,
|
||||||
|
text: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct Commands {
|
||||||
|
source_filename: String,
|
||||||
|
commands: Vec<Command>,
|
||||||
|
}
|
1
spec/testsuite
Submodule
1
spec/testsuite
Submodule
Submodule spec/testsuite added at 434fe2f1cb
1
spec/wabt
Submodule
1
spec/wabt
Submodule
Submodule spec/wabt added at 7425bcc31e
Reference in New Issue
Block a user