summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/tinywasm/Cargo.toml1
-rw-r--r--crates/tinywasm/tests/charts/mod.rs2
-rw-r--r--crates/tinywasm/tests/charts/progress.rs76
-rw-r--r--crates/tinywasm/tests/mvp.csv3
-rw-r--r--crates/tinywasm/tests/mvp.rs21
-rw-r--r--crates/tinywasm/tests/progress-mvp.pngbin0 -> 20926 bytes
-rw-r--r--crates/tinywasm/tests/testsuite/mod.rs11
7 files changed, 107 insertions, 7 deletions
diff --git a/crates/tinywasm/Cargo.toml b/crates/tinywasm/Cargo.toml
index e4d6ba5..d39ef6f 100644
--- a/crates/tinywasm/Cargo.toml
+++ b/crates/tinywasm/Cargo.toml
@@ -24,6 +24,7 @@ owo-colors={version="3.5"}
eyre={version="0.6"}
serde_json={version="1.0"}
serde={version="1.0", features=["derive"]}
+plotters={version="0.3"}
[features]
default=["std", "parser", "logging"]
diff --git a/crates/tinywasm/tests/charts/mod.rs b/crates/tinywasm/tests/charts/mod.rs
new file mode 100644
index 0000000..fba287b
--- /dev/null
+++ b/crates/tinywasm/tests/charts/mod.rs
@@ -0,0 +1,2 @@
+mod progress;
+pub use progress::create_progress_chart;
diff --git a/crates/tinywasm/tests/charts/progress.rs b/crates/tinywasm/tests/charts/progress.rs
new file mode 100644
index 0000000..d52170b
--- /dev/null
+++ b/crates/tinywasm/tests/charts/progress.rs
@@ -0,0 +1,76 @@
+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(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<u32> = Vec::new();
+ let mut versions: Vec<String> = 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 failed: u32 = parts[1].parse()?;
+ let passed: u32 = parts[2].parse()?;
+ let total = failed + passed;
+
+ if total > max_tests {
+ max_tests = total;
+ }
+
+ versions.push(version);
+ data.push(passed);
+ }
+ }
+
+ println!("versions: {:?}", versions);
+ println!("data: {:?}", data);
+
+ let root_area = BitMapBackend::new(output_path, (1000, 400)).into_drawing_area();
+ root_area.fill(&WHITE)?;
+
+ let mut chart = ChartBuilder::on(&root_area)
+ .x_label_area_size(35)
+ .y_label_area_size(60)
+ .margin(10)
+ .caption("MVP TESTSUITE", (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()
+ .x_labels((versions.len()).min(4))
+ .y_desc("Tests Passed")
+ .x_desc("TinyWasm Version")
+ .x_label_formatter(&|x| {
+ let SegmentValue::CenterOf(value) = x else {
+ return "".to_string();
+ };
+ versions.get(*value as usize).unwrap_or(&"".to_string()).to_string()
+ })
+ .axis_desc_style((FONT, 15))
+ .draw()?;
+
+ chart.draw_series(
+ Histogram::vertical(&chart)
+ .style(BLUE.mix(0.5).filled())
+ .data(data.iter().enumerate().map(|(x, y)| (x as u32, *y as u32))),
+ )?;
+
+ root_area.present()?;
+
+ Ok(())
+}
diff --git a/crates/tinywasm/tests/mvp.csv b/crates/tinywasm/tests/mvp.csv
index 44d2711..e058f2b 100644
--- a/crates/tinywasm/tests/mvp.csv
+++ b/crates/tinywasm/tests/mvp.csv
@@ -1 +1,2 @@
-00.0.4,9258,7567,[{"name":"address.wast","passed":0,"failed":54},{"name":"align.wast","passed":0,"failed":109},{"name":"binary-leb128.wast","passed":66,"failed":25},{"name":"binary.wast","passed":104,"failed":8},{"name":"block.wast","passed":0,"failed":171},{"name":"br.wast","passed":0,"failed":21},{"name":"br_if.wast","passed":0,"failed":30},{"name":"br_table.wast","passed":0,"failed":25},{"name":"call.wast","passed":0,"failed":22},{"name":"call_indirect.wast","passed":0,"failed":56},{"name":"comments.wast","passed":4,"failed":4},{"name":"const.wast","passed":702,"failed":76},{"name":"conversions.wast","passed":0,"failed":93},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":0,"failed":61},{"name":"elem.wast","passed":0,"failed":76},{"name":"endianness.wast","passed":0,"failed":1},{"name":"exports.wast","passed":21,"failed":73},{"name":"f32.wast","passed":1005,"failed":1509},{"name":"f32_bitwise.wast","passed":1,"failed":363},{"name":"f32_cmp.wast","passed":2401,"failed":6},{"name":"f64.wast","passed":1005,"failed":1509},{"name":"f64_bitwise.wast","passed":1,"failed":363},{"name":"f64_cmp.wast","passed":2401,"failed":6},{"name":"fac.wast","passed":0,"failed":2},{"name":"float_exprs.wast","passed":269,"failed":591},{"name":"float_literals.wast","passed":34,"failed":129},{"name":"float_memory.wast","passed":0,"failed":6},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":4,"failed":75},{"name":"func_ptrs.wast","passed":0,"failed":16},{"name":"global.wast","passed":4,"failed":49},{"name":"i32.wast","passed":0,"failed":96},{"name":"i64.wast","passed":0,"failed":42},{"name":"if.wast","passed":0,"failed":118},{"name":"imports.wast","passed":1,"failed":156},{"name":"inline-module.wast","passed":0,"failed":1},{"name":"int_exprs.wast","passed":38,"failed":70},{"name":"int_literals.wast","passed":5,"failed":46},{"name":"labels.wast","passed":1,"failed":28},{"name":"left-to-right.wast","passed":0,"failed":1},{"name":"linking.wast","passed":1,"failed":66},{"name":"load.wast","passed":0,"failed":60},{"name":"local_get.wast","passed":2,"failed":34},{"name":"local_set.wast","passed":5,"failed":48},{"name":"local_tee.wast","passed":0,"failed":42},{"name":"loop.wast","passed":0,"failed":43},{"name":"memory.wast","passed":0,"failed":34},{"name":"memory_grow.wast","passed":0,"failed":19},{"name":"memory_redundancy.wast","passed":0,"failed":1},{"name":"memory_size.wast","passed":0,"failed":6},{"name":"memory_trap.wast","passed":0,"failed":172},{"name":"names.wast","passed":484,"failed":1},{"name":"nop.wast","passed":0,"failed":5},{"name":"return.wast","passed":0,"failed":21},{"name":"select.wast","passed":0,"failed":32},{"name":"skip-stack-guard-page.wast","passed":0,"failed":11},{"name":"stack.wast","passed":0,"failed":2},{"name":"start.wast","passed":0,"failed":10},{"name":"store.wast","passed":0,"failed":59},{"name":"switch.wast","passed":1,"failed":27},{"name":"token.wast","passed":16,"failed":42},{"name":"traps.wast","passed":3,"failed":33},{"name":"type.wast","passed":1,"failed":2},{"name":"unreachable.wast","passed":0,"failed":59},{"name":"unreached-invalid.wast","passed":0,"failed":118},{"name":"unwind.wast","passed":1,"failed":49},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":0,"failed":176}]
+0.0.3,9258,7567,[{"name":"address.wast","passed":0,"failed":54},{"name":"align.wast","passed":0,"failed":109},{"name":"binary-leb128.wast","passed":66,"failed":25},{"name":"binary.wast","passed":104,"failed":8},{"name":"block.wast","passed":0,"failed":171},{"name":"br.wast","passed":0,"failed":21},{"name":"br_if.wast","passed":0,"failed":30},{"name":"br_table.wast","passed":0,"failed":25},{"name":"call.wast","passed":0,"failed":22},{"name":"call_indirect.wast","passed":0,"failed":56},{"name":"comments.wast","passed":4,"failed":4},{"name":"const.wast","passed":702,"failed":76},{"name":"conversions.wast","passed":0,"failed":93},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":0,"failed":61},{"name":"elem.wast","passed":0,"failed":76},{"name":"endianness.wast","passed":0,"failed":1},{"name":"exports.wast","passed":21,"failed":73},{"name":"f32.wast","passed":1005,"failed":1509},{"name":"f32_bitwise.wast","passed":1,"failed":363},{"name":"f32_cmp.wast","passed":2401,"failed":6},{"name":"f64.wast","passed":1005,"failed":1509},{"name":"f64_bitwise.wast","passed":1,"failed":363},{"name":"f64_cmp.wast","passed":2401,"failed":6},{"name":"fac.wast","passed":0,"failed":2},{"name":"float_exprs.wast","passed":269,"failed":591},{"name":"float_literals.wast","passed":34,"failed":129},{"name":"float_memory.wast","passed":0,"failed":6},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":4,"failed":75},{"name":"func_ptrs.wast","passed":0,"failed":16},{"name":"global.wast","passed":4,"failed":49},{"name":"i32.wast","passed":0,"failed":96},{"name":"i64.wast","passed":0,"failed":42},{"name":"if.wast","passed":0,"failed":118},{"name":"imports.wast","passed":1,"failed":156},{"name":"inline-module.wast","passed":0,"failed":1},{"name":"int_exprs.wast","passed":38,"failed":70},{"name":"int_literals.wast","passed":5,"failed":46},{"name":"labels.wast","passed":1,"failed":28},{"name":"left-to-right.wast","passed":0,"failed":1},{"name":"linking.wast","passed":1,"failed":66},{"name":"load.wast","passed":0,"failed":60},{"name":"local_get.wast","passed":2,"failed":34},{"name":"local_set.wast","passed":5,"failed":48},{"name":"local_tee.wast","passed":0,"failed":42},{"name":"loop.wast","passed":0,"failed":43},{"name":"memory.wast","passed":0,"failed":34},{"name":"memory_grow.wast","passed":0,"failed":19},{"name":"memory_redundancy.wast","passed":0,"failed":1},{"name":"memory_size.wast","passed":0,"failed":6},{"name":"memory_trap.wast","passed":0,"failed":172},{"name":"names.wast","passed":484,"failed":1},{"name":"nop.wast","passed":0,"failed":5},{"name":"return.wast","passed":0,"failed":21},{"name":"select.wast","passed":0,"failed":32},{"name":"skip-stack-guard-page.wast","passed":0,"failed":11},{"name":"stack.wast","passed":0,"failed":2},{"name":"start.wast","passed":0,"failed":10},{"name":"store.wast","passed":0,"failed":59},{"name":"switch.wast","passed":1,"failed":27},{"name":"token.wast","passed":16,"failed":42},{"name":"traps.wast","passed":3,"failed":33},{"name":"type.wast","passed":1,"failed":2},{"name":"unreachable.wast","passed":0,"failed":59},{"name":"unreached-invalid.wast","passed":0,"failed":118},{"name":"unwind.wast","passed":1,"failed":49},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":0,"failed":176}]
+0.0.4,9258,7567,[{"name":"address.wast","passed":0,"failed":54},{"name":"align.wast","passed":0,"failed":109},{"name":"binary-leb128.wast","passed":66,"failed":25},{"name":"binary.wast","passed":104,"failed":8},{"name":"block.wast","passed":0,"failed":171},{"name":"br.wast","passed":0,"failed":21},{"name":"br_if.wast","passed":0,"failed":30},{"name":"br_table.wast","passed":0,"failed":25},{"name":"call.wast","passed":0,"failed":22},{"name":"call_indirect.wast","passed":0,"failed":56},{"name":"comments.wast","passed":4,"failed":4},{"name":"const.wast","passed":702,"failed":76},{"name":"conversions.wast","passed":0,"failed":93},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":0,"failed":61},{"name":"elem.wast","passed":0,"failed":76},{"name":"endianness.wast","passed":0,"failed":1},{"name":"exports.wast","passed":21,"failed":73},{"name":"f32.wast","passed":1005,"failed":1509},{"name":"f32_bitwise.wast","passed":1,"failed":363},{"name":"f32_cmp.wast","passed":2401,"failed":6},{"name":"f64.wast","passed":1005,"failed":1509},{"name":"f64_bitwise.wast","passed":1,"failed":363},{"name":"f64_cmp.wast","passed":2401,"failed":6},{"name":"fac.wast","passed":0,"failed":2},{"name":"float_exprs.wast","passed":269,"failed":591},{"name":"float_literals.wast","passed":34,"failed":129},{"name":"float_memory.wast","passed":0,"failed":6},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":4,"failed":75},{"name":"func_ptrs.wast","passed":0,"failed":16},{"name":"global.wast","passed":4,"failed":49},{"name":"i32.wast","passed":0,"failed":96},{"name":"i64.wast","passed":0,"failed":42},{"name":"if.wast","passed":0,"failed":118},{"name":"imports.wast","passed":1,"failed":156},{"name":"inline-module.wast","passed":0,"failed":1},{"name":"int_exprs.wast","passed":38,"failed":70},{"name":"int_literals.wast","passed":5,"failed":46},{"name":"labels.wast","passed":1,"failed":28},{"name":"left-to-right.wast","passed":0,"failed":1},{"name":"linking.wast","passed":1,"failed":66},{"name":"load.wast","passed":0,"failed":60},{"name":"local_get.wast","passed":2,"failed":34},{"name":"local_set.wast","passed":5,"failed":48},{"name":"local_tee.wast","passed":0,"failed":42},{"name":"loop.wast","passed":0,"failed":43},{"name":"memory.wast","passed":0,"failed":34},{"name":"memory_grow.wast","passed":0,"failed":19},{"name":"memory_redundancy.wast","passed":0,"failed":1},{"name":"memory_size.wast","passed":0,"failed":6},{"name":"memory_trap.wast","passed":0,"failed":172},{"name":"names.wast","passed":484,"failed":1},{"name":"nop.wast","passed":0,"failed":5},{"name":"return.wast","passed":0,"failed":21},{"name":"select.wast","passed":0,"failed":32},{"name":"skip-stack-guard-page.wast","passed":0,"failed":11},{"name":"stack.wast","passed":0,"failed":2},{"name":"start.wast","passed":0,"failed":10},{"name":"store.wast","passed":0,"failed":59},{"name":"switch.wast","passed":1,"failed":27},{"name":"token.wast","passed":16,"failed":42},{"name":"traps.wast","passed":3,"failed":33},{"name":"type.wast","passed":1,"failed":2},{"name":"unreachable.wast","passed":0,"failed":59},{"name":"unreached-invalid.wast","passed":0,"failed":118},{"name":"unwind.wast","passed":1,"failed":49},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":0,"failed":176}]
diff --git a/crates/tinywasm/tests/mvp.rs b/crates/tinywasm/tests/mvp.rs
index 66b6b2e..0174fb7 100644
--- a/crates/tinywasm/tests/mvp.rs
+++ b/crates/tinywasm/tests/mvp.rs
@@ -1,3 +1,4 @@
+mod charts;
mod testsuite;
use eyre::{eyre, Result};
@@ -5,11 +6,29 @@ use testsuite::TestSuite;
#[test]
#[ignore]
+fn generate_charts() -> Result<()> {
+ // Create a line chart
+ charts::create_progress_chart(
+ std::path::Path::new("./tests/mvp.csv"),
+ std::path::Path::new("./tests/progress-mvp.png"),
+ )?;
+
+ // // Create a bar chart
+ // charts::create_bar_chart(
+ // std::path::Path::new("./tests/mvp.csv"),
+ // std::path::Path::new("./tests/mvp_bar_chart.png"),
+ // )?;
+
+ Ok(())
+}
+
+#[test]
+#[ignore]
fn test_mvp() -> Result<()> {
let mut test_suite = TestSuite::new();
test_suite.run(wasm_testsuite::MVP_TESTS)?;
- test_suite.save_csv("./tests/mvp.csv", env!("CARGO_PKG_VERSION").trim_end())?;
+ test_suite.save_csv("./tests/mvp.csv", env!("CARGO_PKG_VERSION"))?;
if test_suite.failed() {
eprintln!("\n\nfailed one or more tests:\n{:#?}", test_suite);
diff --git a/crates/tinywasm/tests/progress-mvp.png b/crates/tinywasm/tests/progress-mvp.png
new file mode 100644
index 0000000..bfa162b
--- /dev/null
+++ b/crates/tinywasm/tests/progress-mvp.png
Binary files differ
diff --git a/crates/tinywasm/tests/testsuite/mod.rs b/crates/tinywasm/tests/testsuite/mod.rs
index ad1a5ee..b31099f 100644
--- a/crates/tinywasm/tests/testsuite/mod.rs
+++ b/crates/tinywasm/tests/testsuite/mod.rs
@@ -12,10 +12,10 @@ mod util;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
-struct TestGroupResult {
- name: String,
- passed: usize,
- failed: usize,
+pub struct TestGroupResult {
+ pub name: String,
+ pub passed: usize,
+ pub failed: usize,
}
pub struct TestSuite(BTreeMap<String, TestGroup>);
@@ -43,10 +43,11 @@ impl TestSuite {
// Check if the last line starts with the current commit
if let Some(last) = last_line {
+ println!("last line: {}", last);
if last.starts_with(version) {
// Truncate the file size to remove the last line
let len_to_truncate = last.len() as i64;
- file.set_len(file.metadata()?.len() - len_to_truncate as u64)?;
+ file.set_len(file.metadata()?.len() - len_to_truncate as u64 - 1)?;
}
}