Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit bf0d3ec

Browse files
authored
add stackless poll and yield tests (#80)
...and fix a bug with the former. This also refactors some existing tests to reduce duplication. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent 4c5d1d8 commit bf0d3ec

16 files changed

Lines changed: 476 additions & 390 deletions

File tree

Cargo.lock

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -300,24 +300,24 @@ system-interface = { version = "0.27.1", features = ["cap_std_impls"] }
300300
io-lifetimes = { version = "2.0.3", default-features = false }
301301
io-extras = "0.18.1"
302302
rustix = "0.38.43"
303-
# TODO: switch back to upstream release:
304-
wit-bindgen = { git = "https://github.com/dicej/wit-bindgen", branch = "spec-sync", default-features = false }
305-
wit-bindgen-rt = { git = "https://github.com/dicej/wit-bindgen", branch = "spec-sync", default-features = false }
306-
wit-bindgen-rust-macro = { git = "https://github.com/dicej/wit-bindgen", branch = "spec-sync", default-features = false }
303+
# TODO: switch back to release:
304+
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "3df706cf", default-features = false }
305+
wit-bindgen-rt = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "3df706cf", default-features = false }
306+
wit-bindgen-rust-macro = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "3df706cf", default-features = false }
307307

308308
# wasm-tools family:
309-
# TODO: switch back to upstream release:
310-
wasmparser = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update", default-features = false, features = ['simd'] }
311-
wat = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
312-
wast = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
313-
wasmprinter = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
314-
wasm-encoder = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
315-
wasm-smith = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
316-
wasm-mutate = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
317-
wit-parser = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
318-
wit-component = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
319-
wasm-wave = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
320-
wasm-compose = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
309+
# TODO: switch back to release:
310+
wasmparser = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041", default-features = false, features = ['simd'] }
311+
wat = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
312+
wast = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
313+
wasmprinter = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
314+
wasm-encoder = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
315+
wasm-smith = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
316+
wasm-mutate = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
317+
wit-parser = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
318+
wit-component = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
319+
wasm-wave = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
320+
wasm-compose = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
321321

322322
# Non-Bytecode Alliance maintained dependencies:
323323
# --------------------------
@@ -572,16 +572,17 @@ inherits = "release"
572572
codegen-units = 1
573573
lto = true
574574

575+
# TODO: remove this once we've switched to a wasm-tools release:
575576
[patch.crates-io]
576-
wasmparser = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
577-
wat = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
578-
wast = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
579-
wasmprinter = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
580-
wasm-encoder = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
581-
wasm-smith = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
582-
wasm-mutate = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
583-
wit-parser = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
584-
wit-component = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
585-
wasm-wave = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
586-
wasm-compose = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
587-
wasm-metadata = { git = "https://github.com/dicej/wasm-tools", branch = "callback-sig-update" }
577+
wasmparser = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
578+
wat = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
579+
wast = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
580+
wasmprinter = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
581+
wasm-encoder = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
582+
wasm-smith = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
583+
wasm-mutate = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
584+
wit-parser = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
585+
wit-component = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
586+
wasm-wave = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
587+
wasm-compose = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }
588+
wasm-metadata = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "43556041" }

crates/environ/src/component/translate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,8 @@ impl<'a, 'data> Translator<'a, 'data> {
646646
core_func_index += 1;
647647
LocalInitializer::ResourceRep(resource, ty)
648648
}
649-
wasmparser::CanonicalFunction::ThreadSpawn { .. }
649+
wasmparser::CanonicalFunction::ThreadSpawnRef { .. }
650+
| wasmparser::CanonicalFunction::ThreadSpawnIndirect { .. }
650651
| wasmparser::CanonicalFunction::ThreadAvailableParallelism => {
651652
bail!("unsupported intrinsic")
652653
}

crates/misc/component-async-tests/tests/scenario/transmit.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ use component_async_tests::util::{compose, init_logger, test_run};
1515
use component_async_tests::{transmit, Ctx};
1616

1717
#[tokio::test]
18-
pub async fn async_poll() -> Result<()> {
19-
test_run(&fs::read(test_programs_artifacts::ASYNC_POLL_COMPONENT).await?).await
18+
pub async fn async_poll_synchronous() -> Result<()> {
19+
test_run(&fs::read(test_programs_artifacts::ASYNC_POLL_SYNCHRONOUS_COMPONENT).await?).await
20+
}
21+
22+
#[tokio::test]
23+
pub async fn async_poll_stackless() -> Result<()> {
24+
test_run(&fs::read(test_programs_artifacts::ASYNC_POLL_STACKLESS_COMPONENT).await?).await
2025
}
2126

2227
#[tokio::test]

crates/misc/component-async-tests/tests/scenario/yield_.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@ use tokio::fs;
33

44
use component_async_tests::util::{compose, test_run};
55

6-
// No-op function; we only test this by composing it in `async_yield_caller`
6+
// No-op function; we only test this by composing it in
7+
// `async_yield_callee_synchronous` and `async_yield_callee_stackful`
78
#[allow(
89
dead_code,
910
reason = "here only to make the `assert_test_exists` macro happy"
1011
)]
11-
pub fn async_yield_callee() {}
12+
pub fn async_yield_caller() {}
1213

1314
#[tokio::test]
14-
pub async fn async_yield_caller() -> Result<()> {
15+
pub async fn async_yield_callee_synchronous() -> Result<()> {
1516
let caller = &fs::read(test_programs_artifacts::ASYNC_YIELD_CALLER_COMPONENT).await?;
16-
let callee = &fs::read(test_programs_artifacts::ASYNC_YIELD_CALLEE_COMPONENT).await?;
17+
let callee =
18+
&fs::read(test_programs_artifacts::ASYNC_YIELD_CALLEE_SYNCHRONOUS_COMPONENT).await?;
19+
test_run(&compose(caller, callee).await?).await
20+
}
21+
22+
#[tokio::test]
23+
pub async fn async_yield_callee_stackless() -> Result<()> {
24+
let caller = &fs::read(test_programs_artifacts::ASYNC_YIELD_CALLER_COMPONENT).await?;
25+
let callee = &fs::read(test_programs_artifacts::ASYNC_YIELD_CALLEE_STACKLESS_COMPONENT).await?;
1726
test_run(&compose(caller, callee).await?).await
1827
}

crates/misc/component-async-tests/tests/test_all.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ use scenario::round_trip_many::{
3131
async_round_trip_many_synchronous, async_round_trip_many_wait,
3232
};
3333
use scenario::streams::async_closed_streams;
34-
use scenario::transmit::{async_poll, async_transmit_callee, async_transmit_caller};
34+
use scenario::transmit::{
35+
async_poll_stackless, async_poll_synchronous, async_transmit_callee, async_transmit_caller,
36+
};
3537
use scenario::unit_stream::{async_unit_stream_callee, async_unit_stream_caller};
36-
use scenario::yield_::{async_yield_callee, async_yield_caller};
38+
use scenario::yield_::{
39+
async_yield_callee_stackless, async_yield_callee_synchronous, async_yield_caller,
40+
};

0 commit comments

Comments
 (0)