forked from wasmerio/wasmer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'bc376544cf1ea8dcff406f9d621f390a668183ea' as 'tests/was…
…i-wast'
- Loading branch information
Showing
147 changed files
with
10,081 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "wasi-test-generator" | ||
version = "0.17.0" | ||
description = "Tests for our WASI implementation" | ||
license = "MIT" | ||
authors = ["The Wasmer Engineering Team <[email protected]>"] | ||
edition = "2018" | ||
publish = false | ||
|
||
[dependencies] | ||
glob = "0.3" | ||
gumdrop = "0.8" | ||
tempfile = "3" | ||
serde = { version = "1", features = ["derive"] } | ||
serde_json = "1" | ||
wast = "20" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# WASI test suite | ||
|
||
WASI test files with expected output in a custom WAST format. | ||
|
||
## Setup | ||
|
||
In order to run the test generator properly you will need: | ||
|
||
- `rustup` installed and on your PATH | ||
- `wasm-opt` and `wasm-strip` from `wabt` installed and on your PATH | ||
|
||
## Usage | ||
|
||
``` | ||
Optional arguments: | ||
-a, --all-versions Whether or not to do operations for all versions of WASI or just the latest. | ||
-g, --generate-wasm Whether or not the Wasm will be generated. | ||
-s, --set-up-toolchain Whether or not the logic to install the needed Rust compilers is run. | ||
-h, --help Print the help message | ||
``` | ||
|
||
And here's an example of how to generate these tests: | ||
|
||
```bash | ||
cargo run -- -as # set up the toolchains for all targets | ||
cargo run -- -ag # generate the WASI tests for all targets | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#[macro_use] | ||
extern crate serde; | ||
|
||
mod set_up_toolchain; | ||
mod util; | ||
mod wasi_version; | ||
mod wasitests; | ||
|
||
pub use crate::set_up_toolchain::install_toolchains; | ||
pub use crate::wasi_version::{WasiVersion, ALL_WASI_VERSIONS, LATEST_WASI_VERSION}; | ||
pub use crate::wasitests::{build, WasiOptions, WasiTest}; | ||
|
||
use gumdrop::Options; | ||
|
||
#[derive(Debug, Options)] | ||
pub struct TestGenOptions { | ||
/// Whether or not to do operations for all versions of WASI or just the latest. | ||
all_versions: bool, | ||
/// Whether or not the Wasm will be generated. | ||
generate_wasm: bool, | ||
/// Whether or not the logic to install the needed Rust compilers is run. | ||
set_up_toolchain: bool, | ||
/// Print the help message | ||
help: bool, | ||
} | ||
|
||
fn main() { | ||
let opts = TestGenOptions::parse_args_default_or_exit(); | ||
|
||
if opts.help { | ||
println!("{}", TestGenOptions::usage()); | ||
std::process::exit(0); | ||
} | ||
|
||
let generate_all = opts.all_versions; | ||
let set_up_toolchain = opts.set_up_toolchain; | ||
let generate_wasm = opts.generate_wasm; | ||
let wasi_versions = if generate_all { | ||
ALL_WASI_VERSIONS | ||
} else { | ||
LATEST_WASI_VERSION | ||
}; | ||
|
||
// Install the Rust WASI toolchains for each of the versions | ||
if set_up_toolchain { | ||
install_toolchains(wasi_versions); | ||
} | ||
|
||
// Generate the WASI Wasm files | ||
if generate_wasm { | ||
build(wasi_versions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use super::util; | ||
use super::wasi_version::*; | ||
|
||
use std::process::Command; | ||
|
||
fn install_toolchain(toolchain_name: &str) { | ||
println!("Installing rustup toolchain: {}", toolchain_name); | ||
let rustup_out = Command::new("rustup") | ||
.arg("toolchain") | ||
.arg("install") | ||
.arg(toolchain_name) | ||
.output() | ||
.expect("Failed to install toolchain with rustup"); | ||
util::print_info_on_error(&rustup_out, "TOOLCHAIN INSTALL FAILED"); | ||
|
||
println!("Installing rustup WASI target"); | ||
let rustup_out = Command::new("rustup") | ||
.arg("target") | ||
.arg("add") | ||
.arg("wasm32-wasi") | ||
.arg("--toolchain") | ||
.arg(toolchain_name) | ||
.output() | ||
.expect("Failed to wasi target in Rust toolchain"); | ||
util::print_info_on_error(&rustup_out, "WASI TARGET IN TOOLCHAIN INSTALL FAILED"); | ||
} | ||
|
||
pub fn install_toolchains(wasi_versions: &[WasiVersion]) { | ||
println!("Setting up system to generate the WASI tests."); | ||
println!("WARNING: this may use a lot of disk space."); | ||
|
||
for wasi_version in wasi_versions { | ||
install_toolchain(wasi_version.get_compiler_toolchain()); | ||
} | ||
} |
Oops, something went wrong.