Thanks to visit codestin.com
Credit goes to github.com

Skip to content

test: make tests work on more targets #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ 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"
103 changes: 88 additions & 15 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,25 @@ on:
branches: [main]

jobs:
build-wasm:
name: Build wasm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- 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
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: wasm
path: examples/rust/out

test-std:
needs: build-wasm
name: Test with default features on stable Rust
runs-on: ubuntu-latest

Expand All @@ -16,15 +34,14 @@ 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@v4
with:
name: wasm
path: examples/rust/out

- name: Build (stable)
run: cargo +stable build --workspace
Expand All @@ -36,6 +53,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

Expand All @@ -44,14 +62,14 @@ jobs:
with:
submodules: true

- name: Install 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@v4
with:
name: wasm
path: examples/rust/out

- name: Build (nightly, no default features)
run: cargo +nightly build --workspace --no-default-features
Expand All @@ -61,3 +79,58 @@ jobs:

- name: Run MVP testsuite (nightly)
run: cargo +nightly test-mvp

test-m1:
needs: build-wasm
name: Test on arm64 (Apple M1)
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install stable Rust toolchain
run: rustup update stable

- name: Load wasm
uses: actions/download-artifact@v4
with:
name: wasm
path: examples/rust/out

- name: Build (stable)
run: cargo +stable build
- name: Run tests (stable)
run: cargo +stable test
- name: Run MVP testsuite
run: cargo +stable test-mvp

test-armv7:
needs: build-wasm
name: Test on armv7 (32-Bit Raspberry Pi)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Load wasm
uses: actions/download-artifact@v4
with:
name: wasm
path: examples/rust/out

- name: Run all tests (for the default workspace members)
uses: houseabsolute/[email protected]
with:
command: test
target: armv7-unknown-linux-gnueabihf
toolchain: nightly

- name: Run MVP testsuite
uses: houseabsolute/[email protected]
with:
command: test
args: "-p tinywasm --test test-mvp --release -- --enable"
target: armv7-unknown-linux-gnueabihf
toolchain: nightly
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ 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
- 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

Expand Down Expand Up @@ -75,7 +78,7 @@ 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
- Support for `br_table`
- Memory trapping improvements
- Implicit function label scopes
- else Instructions
Expand Down
25 changes: 16 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members=["crates/*"]
members=["crates/*", "benchmarks", "scripts"]
default-members=[".", "crates/tinywasm", "crates/types", "crates/parser"]
resolver="2"

Expand Down Expand Up @@ -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"}
2 changes: 1 addition & 1 deletion crates/benchmarks/Cargo.toml → benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
1 change: 0 additions & 1 deletion crates/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ tinywasm-types={version="0.5.0", path="../types", default-features=false}
default=["std", "logging"]
logging=["log"]
std=["tinywasm-types/std"]

5 changes: 0 additions & 5 deletions crates/tinywasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/tinywasm/src/runtime/stack/block_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use alloc::vec::Vec;
use tinywasm_types::BlockArgs;

#[derive(Debug, Clone, Default)]
pub(crate) struct BlockStack(Vec<BlockFrame>); // TODO: maybe Box<[LabelFrame]> by analyzing the lable count when parsing the module?
pub(crate) struct BlockStack(Vec<BlockFrame>); // TODO: maybe Box<[LabelFrame]> by analyzing the label count when parsing the module?

impl BlockStack {
#[inline]
Expand Down
2 changes: 0 additions & 2 deletions crates/tinywasm/tests/charts/mod.rs

This file was deleted.

31 changes: 0 additions & 31 deletions crates/tinywasm/tests/generate-charts.rs

This file was deleted.

Loading