Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
119 changes: 119 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ members = [
"crates/bench-api",
"crates/c-api/artifact",
"crates/environ/fuzz",
"crates/misc/component-async-tests",
"crates/test-programs",
"crates/wasi-preview1-component-adapter",
"crates/wasi-preview1-component-adapter/verify",
Expand Down Expand Up @@ -304,6 +305,7 @@ test-programs-artifacts = { path = 'crates/test-programs/artifacts' }
wasmtime-test-util = { path = "crates/test-util" }
byte-array-literals = { path = "crates/wasi-preview1-component-adapter/byte-array-literals" }
pulley-interpreter-fuzz = { path = 'pulley/fuzz' }
component-async-tests = { path = "crates/misc/component-async-tests" }

# Bytecode Alliance maintained dependencies:
# ---------------------------
Expand Down
5 changes: 3 additions & 2 deletions ci/miri-provenance-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
set -ex

compile() {
cargo run --no-default-features --features compile,pulley,wat,gc-drc,component-model \
cargo run --no-default-features --features compile,pulley,wat,gc-drc,component-model,component-model-async \
compile --target pulley64 $1 \
-o ${1%.wat}.cwasm \
-O memory-reservation=$((1 << 20)) \
-O memory-guard-size=0 \
-O signals-based-traps=n \
-W function-references
-W function-references,component-model-async,component-model-async-stackful,component-model-async-builtins,component-model-error-context
}

compile ./tests/all/pulley_provenance_test.wat
compile ./tests/all/pulley_provenance_test_component.wat
compile ./tests/all/pulley_provenance_test_async_component.wat

MIRIFLAGS="$MIRIFLAGS -Zmiri-disable-isolation -Zmiri-permissive-provenance" \
cargo miri test --test all -- \
Expand Down
38 changes: 38 additions & 0 deletions crates/misc/component-async-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "component-async-tests"
authors = ["The Wasmtime Project Developers"]
license = "Apache-2.0 WITH LLVM-exception"
version = "0.0.0"
edition.workspace = true
rust-version.workspace = true
publish = false

[lints]
workspace = true

[dependencies]
anyhow = { workspace = true }
futures = { workspace = true }
env_logger = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = [
"fs",
"process",
"macros",
"rt-multi-thread",
"time",
] }
wasm-compose = { workspace = true }
wasmparser = { workspace = true }
wasmtime = { workspace = true, features = [
"default",
"pulley",
"cranelift",
"component-model-async",
] }
wasmtime-wasi = { workspace = true }

[dev-dependencies]
test-programs-artifacts = { workspace = true }
bytes = { workspace = true }
once_cell = { version = "1.12.0" }
42 changes: 42 additions & 0 deletions crates/misc/component-async-tests/src/borrowing_host.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use anyhow::Result;
use wasmtime::component::Resource;
use wasmtime_wasi::p2::IoView;

use super::Ctx;

pub mod bindings {
wasmtime::component::bindgen!({
path: "wit",
world: "borrowing-host",
trappable_imports: true,
concurrent_imports: true,
concurrent_exports: true,
async: {
only_imports: []
},
with: {
"local:local/borrowing-types/x": super::MyX,
}
});
}

/// Used as the borrowing type (`local:local/borrowing-types/x`)
pub struct MyX;

impl bindings::local::local::borrowing_types::HostX for &mut Ctx {
fn new(&mut self) -> Result<Resource<MyX>> {
Ok(IoView::table(self).push(MyX)?)
}

fn foo(&mut self, x: Resource<MyX>) -> Result<()> {
_ = IoView::table(self).get(&x)?;
Ok(())
}

fn drop(&mut self, x: Resource<MyX>) -> Result<()> {
IoView::table(self).delete(x)?;
Ok(())
}
}

impl bindings::local::local::borrowing_types::Host for &mut Ctx {}
14 changes: 14 additions & 0 deletions crates/misc/component-async-tests/src/closed_streams.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub mod bindings {
wasmtime::component::bindgen!({
path: "wit",
world: "closed-streams",
concurrent_imports: true,
concurrent_exports: true,
async: {
only_imports: [
"local:local/closed#read-stream",
"local:local/closed#read-future",
]
},
});
}
42 changes: 42 additions & 0 deletions crates/misc/component-async-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#![expect(clippy::allow_attributes_without_reason)]

use std::sync::{Arc, Mutex};
use std::task::Waker;

use wasmtime::component::{HasData, ResourceTable};
use wasmtime_wasi::p2::{IoView, WasiCtx, WasiView};

pub mod borrowing_host;
pub mod closed_streams;
pub mod resource_stream;
pub mod round_trip;
pub mod round_trip_direct;
pub mod round_trip_many;
pub mod sleep;
pub mod transmit;
pub mod util;
pub mod yield_host;

/// Host implementation, usable primarily by tests
pub struct Ctx {
pub wasi: WasiCtx,
pub table: ResourceTable,
pub wakers: Arc<Mutex<Option<Vec<Waker>>>>,
pub continue_: bool,
}

impl IoView for Ctx {
fn table(&mut self) -> &mut ResourceTable {
&mut self.table
}
}

impl WasiView for Ctx {
fn ctx(&mut self) -> &mut WasiCtx {
&mut self.wasi
}
}

impl HasData for Ctx {
type Data<'a> = &'a mut Self;
}
Loading
Loading