From 33ba80d9ee58102d9e5bd9f40d758e13507b1a97 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 16:46:14 +0100 Subject: [PATCH 01/11] fix: make tests work on cross-compiled platforms Signed-off-by: Henry Gressmann --- .cargo/config.toml | 5 +- Cargo.lock | 9 ++- Cargo.toml | 2 +- {crates/benchmarks => benchmarks}/Cargo.toml | 2 +- .../benches/argon2id.rs | 2 +- .../benches/fibonacci.rs | 2 +- .../benches/selfhosted.rs | 4 +- .../benches/util/mod.rs | 2 +- crates/tinywasm/Cargo.toml | 5 -- crates/tinywasm/tests/generate-charts.rs | 31 -------- crates/wasm-testsuite/Cargo.toml | 2 +- examples/rust/rust-toolchain.toml | 2 +- rust-toolchain.toml | 2 +- scripts/Cargo.toml | 8 ++ scripts/src/bin/generate-charts/main.rs | 35 +++++++++ scripts/src/bin/generate-charts/progress.rs | 77 +++++++++++++++++++ 16 files changed, 142 insertions(+), 48 deletions(-) rename {crates/benchmarks => benchmarks}/Cargo.toml (86%) rename {crates/benchmarks => benchmarks}/benches/argon2id.rs (96%) rename {crates/benchmarks => benchmarks}/benches/fibonacci.rs (97%) rename {crates/benchmarks => benchmarks}/benches/selfhosted.rs (95%) rename {crates/benchmarks => benchmarks}/benches/util/mod.rs (96%) delete mode 100644 crates/tinywasm/tests/generate-charts.rs create mode 100644 scripts/Cargo.toml create mode 100644 scripts/src/bin/generate-charts/main.rs create mode 100644 scripts/src/bin/generate-charts/progress.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index bfe56dd..3c6bc81 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,5 +5,8 @@ test-mvp="test --package tinywasm --test test-mvp --release -- --enable " test-2="test --package tinywasm --test test-two --release -- --enable " test-wast="test --package tinywasm --test test-wast -- --enable " test-wast-release="test --package tinywasm --test test-wast --release -- --enable " -generate-charts="test --package tinywasm --test generate-charts -- --enable " +generate-charts="run --package scripts --bin generate-charts --release" benchmark="bench -p benchmarks --bench" + +[target.armv7-unknown-linux-gnueabihf] +linker="arm-none-linux-gnueabihf-gcc" diff --git a/Cargo.lock b/Cargo.lock index 739a1e2..e83e2f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1796,6 +1796,14 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scripts" +version = "0.0.0" +dependencies = [ + "eyre", + "plotters", +] + [[package]] name = "seahash" version = "4.1.0" @@ -2043,7 +2051,6 @@ dependencies = [ "libm", "log", "owo-colors 4.0.0", - "plotters", "pretty_env_logger", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 17d1404..9cd5d17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members=["crates/*"] +members=["crates/*", "benchmarks", "scripts"] default-members=[".", "crates/tinywasm", "crates/types", "crates/parser"] resolver="2" diff --git a/crates/benchmarks/Cargo.toml b/benchmarks/Cargo.toml similarity index 86% rename from crates/benchmarks/Cargo.toml rename to benchmarks/Cargo.toml index b9225c1..a374713 100644 --- a/crates/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -5,7 +5,7 @@ edition.workspace=true [dependencies] criterion={version="0.5", features=["html_reports"]} -tinywasm={path="../../crates/tinywasm", features=["unsafe"]} +tinywasm={path="../crates/tinywasm", features=["unsafe"]} wat={version="1.0"} wasmi={version="0.31", features=["std"]} wasmer={version="4.2", features=["cranelift", "singlepass"]} diff --git a/crates/benchmarks/benches/argon2id.rs b/benchmarks/benches/argon2id.rs similarity index 96% rename from crates/benchmarks/benches/argon2id.rs rename to benchmarks/benches/argon2id.rs index 7c1ffc5..3046dee 100644 --- a/crates/benchmarks/benches/argon2id.rs +++ b/benchmarks/benches/argon2id.rs @@ -36,7 +36,7 @@ fn run_native(params: (i32, i32, i32)) { run_native(params.0, params.1, params.2) } -const ARGON2ID: &[u8] = include_bytes!("../../../examples/rust/out/argon2id.wasm"); +const ARGON2ID: &[u8] = include_bytes!("../../examples/rust/out/argon2id.wasm"); fn criterion_benchmark(c: &mut Criterion) { let twasm = wasm_to_twasm(ARGON2ID); let params = (1000, 2, 1); diff --git a/crates/benchmarks/benches/fibonacci.rs b/benchmarks/benches/fibonacci.rs similarity index 97% rename from crates/benchmarks/benches/fibonacci.rs rename to benchmarks/benches/fibonacci.rs index 8a4dab2..b391285 100644 --- a/crates/benchmarks/benches/fibonacci.rs +++ b/benchmarks/benches/fibonacci.rs @@ -45,7 +45,7 @@ fn run_native_recursive(n: i32) -> i32 { run_native_recursive(n - 1) + run_native_recursive(n - 2) } -const FIBONACCI: &[u8] = include_bytes!("../../../examples/rust/out/fibonacci.wasm"); +const FIBONACCI: &[u8] = include_bytes!("../../examples/rust/out/fibonacci.wasm"); fn criterion_benchmark(c: &mut Criterion) { let twasm = wasm_to_twasm(FIBONACCI); diff --git a/crates/benchmarks/benches/selfhosted.rs b/benchmarks/benches/selfhosted.rs similarity index 95% rename from crates/benchmarks/benches/selfhosted.rs rename to benchmarks/benches/selfhosted.rs index 94dfdce..02d44ac 100644 --- a/crates/benchmarks/benches/selfhosted.rs +++ b/benchmarks/benches/selfhosted.rs @@ -4,7 +4,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; fn run_native() { use tinywasm::*; - let module = tinywasm::Module::parse_bytes(include_bytes!("../../../examples/rust/out/print.wasm")).expect("parse"); + let module = tinywasm::Module::parse_bytes(include_bytes!("../../examples/rust/out/print.wasm")).expect("parse"); let mut store = Store::default(); let mut imports = Imports::default(); imports.define("env", "printi32", Extern::typed_func(|_: FuncContext<'_>, _: i32| Ok(()))).expect("define"); @@ -51,7 +51,7 @@ fn run_wasmer(wasm: &[u8]) { hello.call(&mut store, &[]).expect("call"); } -const TINYWASM: &[u8] = include_bytes!("../../../examples/rust/out/tinywasm.wasm"); +const TINYWASM: &[u8] = include_bytes!("../../examples/rust/out/tinywasm.wasm"); fn criterion_benchmark(c: &mut Criterion) { { let mut group = c.benchmark_group("selfhosted-parse"); diff --git a/crates/benchmarks/benches/util/mod.rs b/benchmarks/benches/util/mod.rs similarity index 96% rename from crates/benchmarks/benches/util/mod.rs rename to benchmarks/benches/util/mod.rs index 0df2a52..f75ce66 100644 --- a/crates/benchmarks/benches/util/mod.rs +++ b/benchmarks/benches/util/mod.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use tinywasm::{self, parser::Parser, types::TinyWasmModule}; +use tinywasm::{parser::Parser, types::TinyWasmModule}; pub fn parse_wasm(wasm: &[u8]) -> TinyWasmModule { let parser = Parser::new(); diff --git a/crates/tinywasm/Cargo.toml b/crates/tinywasm/Cargo.toml index dc0f525..3f42ca0 100644 --- a/crates/tinywasm/Cargo.toml +++ b/crates/tinywasm/Cargo.toml @@ -25,7 +25,6 @@ owo-colors={version="4.0"} eyre={version="0.6"} serde_json={version="1.0"} serde={version="1.0", features=["derive"]} -plotters={version="0.3"} pretty_env_logger="0.5" [features] @@ -36,10 +35,6 @@ parser=["tinywasm-parser"] unsafe=["tinywasm-types/unsafe"] archive=["tinywasm-types/archive"] -[[test]] -name="generate-charts" -harness=false - [[test]] name="test-mvp" harness=false diff --git a/crates/tinywasm/tests/generate-charts.rs b/crates/tinywasm/tests/generate-charts.rs deleted file mode 100644 index ec48703..0000000 --- a/crates/tinywasm/tests/generate-charts.rs +++ /dev/null @@ -1,31 +0,0 @@ -mod charts; -use eyre::Result; - -fn main() -> Result<()> { - generate_charts() -} - -fn generate_charts() -> Result<()> { - let args = std::env::args().collect::>(); - if args.len() < 2 || args[1] != "--enable" { - return Ok(()); - } - - charts::create_progress_chart( - "WebAssembly 1.0 Test Suite", - std::path::Path::new("./tests/generated/mvp.csv"), - std::path::Path::new("./tests/generated/progress-mvp.svg"), - )?; - - println!("created progress chart: ./tests/generated/progress-mvp.svg"); - - charts::create_progress_chart( - "WebAssembly 2.0 Test Suite", - std::path::Path::new("./tests/generated/2.0.csv"), - std::path::Path::new("./tests/generated/progress-2.0.svg"), - )?; - - println!("created progress chart: ./tests/generated/progress-2.0.svg"); - - Ok(()) -} diff --git a/crates/wasm-testsuite/Cargo.toml b/crates/wasm-testsuite/Cargo.toml index 97c1f58..2e2fc21 100644 --- a/crates/wasm-testsuite/Cargo.toml +++ b/crates/wasm-testsuite/Cargo.toml @@ -15,4 +15,4 @@ path="lib.rs" independent=true [dependencies] -rust-embed={version="8.1.0", features=["include-exclude"]} +rust-embed={version="8.3", features=["include-exclude"]} diff --git a/examples/rust/rust-toolchain.toml b/examples/rust/rust-toolchain.toml index 6c22ba5..0b04107 100644 --- a/examples/rust/rust-toolchain.toml +++ b/examples/rust/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel="nightly-2024-02-11" +channel="nightly-2024-03-08" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6c22ba5..0b04107 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel="nightly-2024-02-11" +channel="nightly-2024-03-08" diff --git a/scripts/Cargo.toml b/scripts/Cargo.toml new file mode 100644 index 0000000..5217729 --- /dev/null +++ b/scripts/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name="scripts" +publish=false +edition.workspace=true + +[dependencies] +plotters={version="0.3"} +eyre={version="0.6"} diff --git a/scripts/src/bin/generate-charts/main.rs b/scripts/src/bin/generate-charts/main.rs new file mode 100644 index 0000000..c5def88 --- /dev/null +++ b/scripts/src/bin/generate-charts/main.rs @@ -0,0 +1,35 @@ +mod progress; +use std::{path::PathBuf, str::FromStr}; + +use eyre::Result; + +fn main() -> Result<()> { + generate_charts() +} + +fn generate_charts() -> Result<()> { + let results_dir = PathBuf::from_str("../crates/tinywasm/tests/generated")?; + + // check if the folder exists + if !results_dir.exists() { + return Err(eyre::eyre!( + "This script should be run from the root of the project, and the test results should be generated first." + )); + } + + progress::create_progress_chart( + "WebAssembly 1.0 Test Suite", + &results_dir.join("mvp.csv"), + &results_dir.join("progress-mvp.svg"), + )?; + println!("created progress chart: {}", results_dir.join("progress-mvp.svg").display()); + + progress::create_progress_chart( + "WebAssembly 2.0 Test Suite", + &results_dir.join("2.0.csv"), + &results_dir.join("progress-2.0.svg"), + )?; + println!("created progress chart: {}", results_dir.join("progress-2.0.svg").display()); + + Ok(()) +} diff --git a/scripts/src/bin/generate-charts/progress.rs b/scripts/src/bin/generate-charts/progress.rs new file mode 100644 index 0000000..1ecc09c --- /dev/null +++ b/scripts/src/bin/generate-charts/progress.rs @@ -0,0 +1,77 @@ +use eyre::Result; +use plotters::prelude::*; +use std::fs::File; +use std::io::{self, BufRead}; +use std::path::Path; + +const FONT: &str = "Victor Mono"; + +pub fn create_progress_chart(name: &str, csv_path: &Path, output_path: &Path) -> Result<()> { + let file = File::open(csv_path)?; + let reader = io::BufReader::new(file); + + let mut max_tests = 0; + let mut data: Vec = Vec::new(); + let mut versions: Vec = Vec::new(); + + for line in reader.lines() { + let line = line?; + let parts: Vec<&str> = line.split(',').collect(); + + if parts.len() > 3 { + let version = format!("v{}", parts[0]); + let passed: u32 = parts[1].parse()?; + let failed: u32 = parts[2].parse()?; + let total = failed + passed; + + if total > max_tests { + max_tests = total; + } + + versions.push(version); + data.push(passed); + } + } + + let root_area = SVGBackend::new(output_path, (1000, 400)).into_drawing_area(); + root_area.fill(&WHITE)?; + + let mut chart = ChartBuilder::on(&root_area) + .x_label_area_size(45) + .y_label_area_size(70) + .margin(10) + .margin_top(20) + .caption(name, (FONT, 30.0, FontStyle::Bold)) + .build_cartesian_2d((0..(versions.len() - 1) as u32).into_segmented(), 0..max_tests)?; + + chart + .configure_mesh() + .light_line_style(TRANSPARENT) + .bold_line_style(BLACK.mix(0.3)) + .max_light_lines(10) + .disable_x_mesh() + .y_desc("Tests Passed") + .y_label_style((FONT, 15)) + .x_desc("TinyWasm Version") + .x_labels((versions.len()).min(4)) + .x_label_style((FONT, 15)) + .x_label_formatter(&|x| { + let SegmentValue::CenterOf(value) = x else { + return "".to_string(); + }; + let v = versions.get(*value as usize).unwrap_or(&"".to_string()).to_string(); + format!("{} ({})", v, data[*value as usize]) + }) + .axis_desc_style((FONT, 15, FontStyle::Bold)) + .draw()?; + + chart.draw_series( + Histogram::vertical(&chart) + .style(BLUE.mix(0.5).filled()) + .data(data.iter().enumerate().map(|(x, y)| (x as u32, *y))), + )?; + + root_area.present()?; + + Ok(()) +} From 8b7081f72ce63b40b1db73124802a3b3482043a1 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 17:01:35 +0100 Subject: [PATCH 02/11] add changelog entry Signed-off-by: Henry Gressmann --- .cargo/config.toml | 3 --- CHANGELOG.md | 10 ++++++---- crates/tinywasm/src/runtime/stack/block_stack.rs | 2 +- crates/types/src/instructions.rs | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 3c6bc81..df52e1c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -7,6 +7,3 @@ test-wast="test --package tinywasm --test test-wast -- --enable " test-wast-release="test --package tinywasm --test test-wast --release -- --enable " generate-charts="run --package scripts --bin generate-charts --release" benchmark="bench -p benchmarks --bench" - -[target.armv7-unknown-linux-gnueabihf] -linker="arm-none-linux-gnueabihf-gcc" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f06127..690d34c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Improved documentation and added more tests +- Tests can now be run on more targets +- Nightly version has been updated to fix broken builds in some cases ### Removed @@ -31,7 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Reduced the overhead of control flow instructions - Reduced the size of bytecode instructions - Fixed issues on the latest nightly Rust compiler -- Simpliefied a lot of the internal macros +- Simplified a lot of the internal macros ### Removed @@ -74,9 +76,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 **All Commits**: https://github.com/explodingcamera/tinywasm/compare/v0.1.0...v0.2.0 -- Support for br_table -- Memory trapping improvments -- Implicit function lable scopes +- Support for `br_table` +- Memory trapping improvements +- Implicit function label scopes - else Instructions - All Memory instructions - Imports diff --git a/crates/tinywasm/src/runtime/stack/block_stack.rs b/crates/tinywasm/src/runtime/stack/block_stack.rs index 4fe7690..edaf2d1 100644 --- a/crates/tinywasm/src/runtime/stack/block_stack.rs +++ b/crates/tinywasm/src/runtime/stack/block_stack.rs @@ -3,7 +3,7 @@ use alloc::vec::Vec; use tinywasm_types::BlockArgs; #[derive(Debug, Clone, Default)] -pub(crate) struct BlockStack(Vec); // TODO: maybe Box<[LabelFrame]> by analyzing the lable count when parsing the module? +pub(crate) struct BlockStack(Vec); // TODO: maybe Box<[LabelFrame]> by analyzing the label count when parsing the module? impl BlockStack { #[inline] diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index 9923116..c932704 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -72,7 +72,7 @@ pub enum ConstInstruction { /// Wasm Bytecode can map to multiple of these instructions. /// /// # Differences to the spec -/// * `br_table` stores the jump lables in the following `br_label` instructions to keep this enum small. +/// * `br_table` stores the jump labels in the following `br_label` instructions to keep this enum small. /// * Lables/Blocks: we store the label end offset in the instruction itself and /// have seperate EndBlockFrame and EndFunc instructions to mark the end of a block or function. /// This makes it easier to implement the label stack iteratively. From eec947050a3b52d467a6574ac63077169b2b71c0 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 17:07:43 +0100 Subject: [PATCH 03/11] cleanup Signed-off-by: Henry Gressmann --- Cargo.lock | 16 ++-- Cargo.toml | 2 +- crates/parser/Cargo.toml | 1 - crates/tinywasm/tests/charts/mod.rs | 2 - crates/tinywasm/tests/charts/progress.rs | 77 ------------------- .../tinywasm/tests/generated/progress-2.0.svg | 25 +++--- .../tinywasm/tests/generated/progress-mvp.svg | 35 ++++----- scripts/src/bin/generate-charts/main.rs | 2 +- 8 files changed, 39 insertions(+), 121 deletions(-) delete mode 100644 crates/tinywasm/tests/charts/mod.rs delete mode 100644 crates/tinywasm/tests/charts/progress.rs diff --git a/Cargo.lock b/Cargo.lock index e83e2f9..5369adc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1432,8 +1432,8 @@ dependencies = [ [[package]] name = "pathfinder_simd" -version = "0.5.2" -source = "git+https://github.com/explodingcamera/pathfinder?rev=4ada8c2484f6bdd2a57546f055000c2df8e65eab#4ada8c2484f6bdd2a57546f055000c2df8e65eab" +version = "0.5.3" +source = "git+https://github.com/servo/pathfinder?rev=30419d07660dc11a21e42ef4a7fa329600cff152#30419d07660dc11a21e42ef4a7fa329600cff152" dependencies = [ "rustc_version", ] @@ -1545,9 +1545,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -1981,18 +1981,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 9cd5d17..bb3275c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,4 +40,4 @@ debug=true [patch.crates-io] # https://github.com/servo/pathfinder/pull/548 & https://github.com/servo/pathfinder/issues/558 -pathfinder_simd={git="https://github.com/explodingcamera/pathfinder", rev="4ada8c2484f6bdd2a57546f055000c2df8e65eab"} +pathfinder_simd={git="https://github.com/servo/pathfinder", rev="30419d07660dc11a21e42ef4a7fa329600cff152"} diff --git a/crates/parser/Cargo.toml b/crates/parser/Cargo.toml index b21c0ac..197023d 100644 --- a/crates/parser/Cargo.toml +++ b/crates/parser/Cargo.toml @@ -17,4 +17,3 @@ tinywasm-types={version="0.5.0", path="../types", default-features=false} default=["std", "logging"] logging=["log"] std=["tinywasm-types/std"] - diff --git a/crates/tinywasm/tests/charts/mod.rs b/crates/tinywasm/tests/charts/mod.rs deleted file mode 100644 index fba287b..0000000 --- a/crates/tinywasm/tests/charts/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod progress; -pub use progress::create_progress_chart; diff --git a/crates/tinywasm/tests/charts/progress.rs b/crates/tinywasm/tests/charts/progress.rs deleted file mode 100644 index 1ecc09c..0000000 --- a/crates/tinywasm/tests/charts/progress.rs +++ /dev/null @@ -1,77 +0,0 @@ -use eyre::Result; -use plotters::prelude::*; -use std::fs::File; -use std::io::{self, BufRead}; -use std::path::Path; - -const FONT: &str = "Victor Mono"; - -pub fn create_progress_chart(name: &str, csv_path: &Path, output_path: &Path) -> Result<()> { - let file = File::open(csv_path)?; - let reader = io::BufReader::new(file); - - let mut max_tests = 0; - let mut data: Vec = Vec::new(); - let mut versions: Vec = Vec::new(); - - for line in reader.lines() { - let line = line?; - let parts: Vec<&str> = line.split(',').collect(); - - if parts.len() > 3 { - let version = format!("v{}", parts[0]); - let passed: u32 = parts[1].parse()?; - let failed: u32 = parts[2].parse()?; - let total = failed + passed; - - if total > max_tests { - max_tests = total; - } - - versions.push(version); - data.push(passed); - } - } - - let root_area = SVGBackend::new(output_path, (1000, 400)).into_drawing_area(); - root_area.fill(&WHITE)?; - - let mut chart = ChartBuilder::on(&root_area) - .x_label_area_size(45) - .y_label_area_size(70) - .margin(10) - .margin_top(20) - .caption(name, (FONT, 30.0, FontStyle::Bold)) - .build_cartesian_2d((0..(versions.len() - 1) as u32).into_segmented(), 0..max_tests)?; - - chart - .configure_mesh() - .light_line_style(TRANSPARENT) - .bold_line_style(BLACK.mix(0.3)) - .max_light_lines(10) - .disable_x_mesh() - .y_desc("Tests Passed") - .y_label_style((FONT, 15)) - .x_desc("TinyWasm Version") - .x_labels((versions.len()).min(4)) - .x_label_style((FONT, 15)) - .x_label_formatter(&|x| { - let SegmentValue::CenterOf(value) = x else { - return "".to_string(); - }; - let v = versions.get(*value as usize).unwrap_or(&"".to_string()).to_string(); - format!("{} ({})", v, data[*value as usize]) - }) - .axis_desc_style((FONT, 15, FontStyle::Bold)) - .draw()?; - - chart.draw_series( - Histogram::vertical(&chart) - .style(BLUE.mix(0.5).filled()) - .data(data.iter().enumerate().map(|(x, y)| (x as u32, *y))), - )?; - - root_area.present()?; - - Ok(()) -} diff --git a/crates/tinywasm/tests/generated/progress-2.0.svg b/crates/tinywasm/tests/generated/progress-2.0.svg index 6424367..32eee9e 100644 --- a/crates/tinywasm/tests/generated/progress-2.0.svg +++ b/crates/tinywasm/tests/generated/progress-2.0.svg @@ -41,19 +41,24 @@ TinyWasm Version - + v0.3.0 (26722) - - + + v0.4.0 (27549) - - -v0.4.1 (27552) + + +v0.4.1 (27551) - - - - + + +v0.5.0 (27551) + + + + + + diff --git a/crates/tinywasm/tests/generated/progress-mvp.svg b/crates/tinywasm/tests/generated/progress-mvp.svg index 2a26dd5..dcb1838 100644 --- a/crates/tinywasm/tests/generated/progress-mvp.svg +++ b/crates/tinywasm/tests/generated/progress-mvp.svg @@ -36,27 +36,20 @@ TinyWasm Version - + v0.0.4 (9258) - - -v0.1.0 (17630) - - - -v0.3.0 (20254) - - - -v0.4.1 (20257) - - - - - - - - - + + +v0.4.0 (20254) + + + + + + + + + + diff --git a/scripts/src/bin/generate-charts/main.rs b/scripts/src/bin/generate-charts/main.rs index c5def88..1206e5f 100644 --- a/scripts/src/bin/generate-charts/main.rs +++ b/scripts/src/bin/generate-charts/main.rs @@ -8,7 +8,7 @@ fn main() -> Result<()> { } fn generate_charts() -> Result<()> { - let results_dir = PathBuf::from_str("../crates/tinywasm/tests/generated")?; + let results_dir = PathBuf::from_str("./crates/tinywasm/tests/generated")?; // check if the folder exists if !results_dir.exists() { From 40db1c7cee8fe53317c75eec8c80d476d72e7d20 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 17:59:41 +0100 Subject: [PATCH 04/11] ci: add aarch64-apple-darwin and armv7-unknown-linux-gnueabihf Signed-off-by: Henry Gressmann --- .github/workflows/test.yaml | 42 ++++++++++++++++++++++++++++++++++++- CHANGELOG.md | 1 + 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9061eb8..540d07b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -44,7 +44,7 @@ jobs: with: submodules: true - - name: Install nightly Rust toolchain & Binaryen + - name: Install latest nightly Rust toolchain & Binaryen run: | rustup update nightly rustup target add wasm32-unknown-unknown @@ -61,3 +61,43 @@ jobs: - name: Run MVP testsuite (nightly) run: cargo +nightly test-mvp + + test-m1: + name: Test on arm64 (Apple M1) + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Install stable Rust toolchain & Binaryen + run: | + rustup update + rustup target add aarch64-apple-darwin + - name: Build (stable) + run: cargo +stable build --workspace --target aarch64-apple-darwin + - name: Run tests (stable) + run: cargo +stable test --workspace --target aarch64-apple-darwin + - name: Run MVP testsuite + run: cargo +stable test-mvp --target aarch64-apple-darwin + + test-armv7: + name: Test on armv7 (32-Bit Raspberry Pi) + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Run all tests (for the default workspace members) + uses: houseabsolute/actions-rust-cross@v0.0.12 + with: + command: test + target: armv7-unknown-linux-gnueabihf + + - name: Run MVP testsuite + uses: houseabsolute/actions-rust-cross@v0.0.12 + with: + command: test + args: "-p tinywasm --test test-mvp --release -- --enable" + target: armv7-unknown-linux-gnueabihf diff --git a/CHANGELOG.md b/CHANGELOG.md index 78c7219..e68cd55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Tests can now be run on more targets - Nightly version has been updated to fix broken builds in some cases - Enhance support for scripted language bindings by making Imports and Module cloneable +- Add `aarch64-apple-darwin` and `armv7-unknown-linux-gnueabihf` targets to CI ### Removed From 8668ed9a98af7c190e51b47a69f17fc24077369b Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 18:06:54 +0100 Subject: [PATCH 05/11] fix ci Signed-off-by: Henry Gressmann --- .github/workflows/test.yaml | 6 ++++-- examples/rust/rust-toolchain.toml | 2 +- rust-toolchain.toml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 540d07b..938e81e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -71,8 +71,8 @@ jobs: submodules: true - name: Install stable Rust toolchain & Binaryen run: | - rustup update - rustup target add aarch64-apple-darwin + rustup update stable + rustup +stable target add aarch64-apple-darwin - name: Build (stable) run: cargo +stable build --workspace --target aarch64-apple-darwin - name: Run tests (stable) @@ -94,6 +94,7 @@ jobs: with: command: test target: armv7-unknown-linux-gnueabihf + toolchain: nightly - name: Run MVP testsuite uses: houseabsolute/actions-rust-cross@v0.0.12 @@ -101,3 +102,4 @@ jobs: command: test args: "-p tinywasm --test test-mvp --release -- --enable" target: armv7-unknown-linux-gnueabihf + toolchain: nightly diff --git a/examples/rust/rust-toolchain.toml b/examples/rust/rust-toolchain.toml index 0b04107..7d876a7 100644 --- a/examples/rust/rust-toolchain.toml +++ b/examples/rust/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel="nightly-2024-03-08" +channel="nightly-2024-03-11" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 0b04107..7d876a7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel="nightly-2024-03-08" +channel="nightly-2024-03-11" From 5c8da44ca0b0ebc1cec66f201495b74267001fac Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 18:18:13 +0100 Subject: [PATCH 06/11] store generated wasm in artifact Signed-off-by: Henry Gressmann --- .github/workflows/test.yaml | 72 ++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 938e81e..a31f113 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,7 +7,27 @@ on: branches: [main] jobs: + build-wasm: + name: Build wasm + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Install Binaryen + run: sudo apt-get install -y binaryen wabt + - name: Build wasm + run: | + ./examples/rust/build.sh + tar -czf wasm.tar.gz examples/rust/out + - name: Save artifacts + uses: actions/upload-artifact@v2 + with: + name: wasm + path: examples/rust/out + test-std: + needs: build-wasm name: Test with default features on stable Rust runs-on: ubuntu-latest @@ -16,15 +36,16 @@ jobs: with: submodules: true - - name: Install stable Rust toolchain & Binaryen - run: | - rustup update stable - rustup update nightly - rustup target add wasm32-unknown-unknown - sudo apt-get install -y binaryen wabt + - name: Install latest stable Rust toolchain + run: rustup update stable - - name: Build wasm - run: ./examples/rust/build.sh + - name: Load wasm + uses: actions/download-artifact@v2 + with: + name: wasm + + - name: Unpack wasm + run: tar -xzf wasm.tar.gz - name: Build (stable) run: cargo +stable build --workspace @@ -36,6 +57,7 @@ jobs: run: cargo +stable test-mvp test-no-std: + needs: build-wasm name: Test without default features on nightly Rust runs-on: ubuntu-latest @@ -44,14 +66,15 @@ jobs: with: submodules: true - - name: Install latest nightly Rust toolchain & Binaryen - run: | - rustup update nightly - rustup target add wasm32-unknown-unknown - sudo apt-get install -y binaryen wabt + - name: Install latest nightly Rust toolchain + run: rustup update nightly - - name: Build wasm - run: ./examples/rust/build.sh + - name: Load wasm + uses: actions/download-artifact@v2 + with: + name: wasm + - name: Unpack wasm + run: tar -xzf wasm.tar.gz - name: Build (nightly, no default features) run: cargo +nightly build --workspace --no-default-features @@ -69,10 +92,19 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - name: Install stable Rust toolchain & Binaryen + - name: Install stable Rust toolchain run: | rustup update stable rustup +stable target add aarch64-apple-darwin + + - name: Load wasm + uses: actions/download-artifact@v2 + with: + name: wasm + + - name: Unpack wasm + run: tar -xzf wasm.tar.gz + - name: Build (stable) run: cargo +stable build --workspace --target aarch64-apple-darwin - name: Run tests (stable) @@ -89,6 +121,14 @@ jobs: with: submodules: true + - name: Load wasm + uses: actions/download-artifact@v2 + with: + name: wasm + + - name: Unpack wasm + run: tar -xzf wasm.tar.gz + - name: Run all tests (for the default workspace members) uses: houseabsolute/actions-rust-cross@v0.0.12 with: From ef2793374301a0c4f5366713276e79157a2ef726 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 18:24:42 +0100 Subject: [PATCH 07/11] fix ci Signed-off-by: Henry Gressmann --- .github/workflows/test.yaml | 7 +++++-- examples/rust/rust-toolchain.toml | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 examples/rust/rust-toolchain.toml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a31f113..c6fadf7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -14,8 +14,8 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - name: Install Binaryen - run: sudo apt-get install -y binaryen wabt + - name: Install Rust toolchain & Binaryen + run: rustup update && sudo apt-get install -y binaryen wabt - name: Build wasm run: | ./examples/rust/build.sh @@ -73,6 +73,7 @@ jobs: uses: actions/download-artifact@v2 with: name: wasm + - name: Unpack wasm run: tar -xzf wasm.tar.gz @@ -86,6 +87,7 @@ jobs: run: cargo +nightly test-mvp test-m1: + needs: build-wasm name: Test on arm64 (Apple M1) runs-on: macos-latest steps: @@ -113,6 +115,7 @@ jobs: run: cargo +stable test-mvp --target aarch64-apple-darwin test-armv7: + needs: build-wasm name: Test on armv7 (32-Bit Raspberry Pi) runs-on: ubuntu-latest diff --git a/examples/rust/rust-toolchain.toml b/examples/rust/rust-toolchain.toml deleted file mode 100644 index 7d876a7..0000000 --- a/examples/rust/rust-toolchain.toml +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -channel="nightly-2024-03-11" From 65a2d36865743451e87fc1d5ec87ad03b922394c Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 18:26:12 +0100 Subject: [PATCH 08/11] ci: add missing target Signed-off-by: Henry Gressmann --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c6fadf7..94aaeb4 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,7 +15,7 @@ jobs: with: submodules: true - name: Install Rust toolchain & Binaryen - run: rustup update && sudo apt-get install -y binaryen wabt + run: rustup update && rustup target add wasm32-unknown-unknown && sudo apt-get install -y binaryen wabt - name: Build wasm run: | ./examples/rust/build.sh From 560c34fa2692c50317c21ba42c4e6485ed074236 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 18:29:31 +0100 Subject: [PATCH 09/11] ci: fix artifact paths Signed-off-by: Henry Gressmann --- .github/workflows/test.yaml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 94aaeb4..80bf328 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -17,9 +17,7 @@ jobs: - name: Install Rust toolchain & Binaryen run: rustup update && rustup target add wasm32-unknown-unknown && sudo apt-get install -y binaryen wabt - name: Build wasm - run: | - ./examples/rust/build.sh - tar -czf wasm.tar.gz examples/rust/out + run: ./examples/rust/build.sh - name: Save artifacts uses: actions/upload-artifact@v2 with: @@ -43,9 +41,7 @@ jobs: uses: actions/download-artifact@v2 with: name: wasm - - - name: Unpack wasm - run: tar -xzf wasm.tar.gz + path: examples/rust/out - name: Build (stable) run: cargo +stable build --workspace @@ -73,9 +69,7 @@ jobs: uses: actions/download-artifact@v2 with: name: wasm - - - name: Unpack wasm - run: tar -xzf wasm.tar.gz + path: examples/rust/out - name: Build (nightly, no default features) run: cargo +nightly build --workspace --no-default-features @@ -103,9 +97,7 @@ jobs: uses: actions/download-artifact@v2 with: name: wasm - - - name: Unpack wasm - run: tar -xzf wasm.tar.gz + path: examples/rust/out - name: Build (stable) run: cargo +stable build --workspace --target aarch64-apple-darwin @@ -128,9 +120,7 @@ jobs: uses: actions/download-artifact@v2 with: name: wasm - - - name: Unpack wasm - run: tar -xzf wasm.tar.gz + path: examples/rust/out - name: Run all tests (for the default workspace members) uses: houseabsolute/actions-rust-cross@v0.0.12 From bd4c58c0ffb80d8660fb07a53f15d217eaf0d522 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 18:36:41 +0100 Subject: [PATCH 10/11] ci: don't build scripts on osx Signed-off-by: Henry Gressmann --- .github/workflows/test.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 80bf328..62d3f92 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ jobs: - name: Build wasm run: ./examples/rust/build.sh - name: Save artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: wasm path: examples/rust/out @@ -38,7 +38,7 @@ jobs: run: rustup update stable - name: Load wasm - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: wasm path: examples/rust/out @@ -66,7 +66,7 @@ jobs: run: rustup update nightly - name: Load wasm - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: wasm path: examples/rust/out @@ -94,15 +94,15 @@ jobs: rustup +stable target add aarch64-apple-darwin - name: Load wasm - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: wasm path: examples/rust/out - name: Build (stable) - run: cargo +stable build --workspace --target aarch64-apple-darwin + run: cargo +stable build --target aarch64-apple-darwin - name: Run tests (stable) - run: cargo +stable test --workspace --target aarch64-apple-darwin + run: cargo +stable test --target aarch64-apple-darwin - name: Run MVP testsuite run: cargo +stable test-mvp --target aarch64-apple-darwin @@ -117,7 +117,7 @@ jobs: submodules: true - name: Load wasm - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: wasm path: examples/rust/out From 262ab9c9e5aa3298ac3ea57e8e14bba9d3e28bf4 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 12 Mar 2024 18:43:49 +0100 Subject: [PATCH 11/11] ci: use native m1 Signed-off-by: Henry Gressmann --- .github/workflows/test.yaml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 62d3f92..d2b60d1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -83,15 +83,13 @@ jobs: test-m1: needs: build-wasm name: Test on arm64 (Apple M1) - runs-on: macos-latest + runs-on: macos-14 steps: - uses: actions/checkout@v4 with: submodules: true - name: Install stable Rust toolchain - run: | - rustup update stable - rustup +stable target add aarch64-apple-darwin + run: rustup update stable - name: Load wasm uses: actions/download-artifact@v4 @@ -100,11 +98,11 @@ jobs: path: examples/rust/out - name: Build (stable) - run: cargo +stable build --target aarch64-apple-darwin + run: cargo +stable build - name: Run tests (stable) - run: cargo +stable test --target aarch64-apple-darwin + run: cargo +stable test - name: Run MVP testsuite - run: cargo +stable test-mvp --target aarch64-apple-darwin + run: cargo +stable test-mvp test-armv7: needs: build-wasm