test suite support iniital

This commit is contained in:
NikVolf
2017-06-03 17:45:03 +03:00
parent b9edc13cd0
commit 5bb4559bf8
9 changed files with 125 additions and 2 deletions

6
.gitmodules vendored Normal file
View 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

View File

@ -9,7 +9,7 @@ homepage = "https://github.com/nikvolf/parity-wasm"
documentation = "https://nikvolf.github.io/parity-wasm/parity_wasm/"
description = "WebAssembly binary format serialization/deserialization/interpreter"
keywords = ["wasm", "webassembly", "bytecode", "serde", "interpreter"]
exclude = [ "res/*" ]
exclude = [ "res/*", "spec/*" ]
[dependencies]
byteorder = "1.0"

25
spec/Cargo.toml Normal file
View 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
View 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
View 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
View 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
View 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

Submodule spec/testsuite added at 434fe2f1cb

1
spec/wabt Submodule

Submodule spec/wabt added at 7425bcc31e