forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bytecodealliance#76 from dhil/wasmfx-merge
Merge with upstream. Notably this patch uses the latest wasmfx-tools-1.0.55 release.
- Loading branch information
Showing
31 changed files
with
548 additions
and
123 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,6 @@ | |
end | ||
drop | ||
) | ||
(table (;0;) 16 anyfunc) | ||
(table (;0;) 16 funcref) | ||
(elem (i32.const 0)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use test_programs::wasi::cli::{stdin, stdout}; | ||
|
||
fn main() { | ||
match std::env::var("PIPED_SIDE") | ||
.expect("piped tests require the PIPED_SIDE env var") | ||
.as_str() | ||
{ | ||
"PRODUCER" => producer(), | ||
"CONSUMER" => consumer(), | ||
side => panic!("unknown piped test side: {side}"), | ||
} | ||
} | ||
|
||
fn producer() { | ||
let out = stdout::get_stdout(); | ||
let out_pollable = out.subscribe(); | ||
|
||
for i in 1..100 { | ||
let message = format!("{i}"); | ||
loop { | ||
let available = out.check_write().unwrap() as usize; | ||
if available >= message.len() { | ||
break; | ||
} | ||
|
||
out_pollable.block(); | ||
assert!(out_pollable.ready()); | ||
} | ||
|
||
out.write(message.as_bytes()).unwrap() | ||
} | ||
|
||
drop(out_pollable); | ||
} | ||
|
||
fn consumer() { | ||
let stdin = stdin::get_stdin(); | ||
let stdin_pollable = stdin.subscribe(); | ||
|
||
for i in 1..100 { | ||
let expected = format!("{i}"); | ||
|
||
stdin_pollable.block(); | ||
assert!(stdin_pollable.ready()); | ||
|
||
let bytes = stdin.read(expected.len() as u64).unwrap(); | ||
assert_eq!(&bytes, expected.as_bytes()); | ||
} | ||
|
||
drop(stdin_pollable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use test_programs::wasi::cli::{stdin, stdout}; | ||
|
||
fn main() { | ||
match std::env::var("PIPED_SIDE") | ||
.expect("piped tests require the PIPED_SIDE env var") | ||
.as_str() | ||
{ | ||
"PRODUCER" => producer(), | ||
"CONSUMER" => consumer(), | ||
side => panic!("unknown piped test side: {side}"), | ||
} | ||
} | ||
|
||
const CHUNK: &[u8] = &[b'a'; 50]; | ||
|
||
fn producer() { | ||
let out = stdout::get_stdout(); | ||
let n = out.check_write().unwrap() as usize; | ||
assert!(n > CHUNK.len()); | ||
out.write(CHUNK).unwrap(); | ||
} | ||
|
||
fn consumer() { | ||
let stdin = stdin::get_stdin(); | ||
let stdin_pollable = stdin.subscribe(); | ||
stdin_pollable.block(); | ||
assert!(stdin_pollable.ready()); | ||
let bytes = stdin.read(CHUNK.len() as u64).unwrap(); | ||
assert_eq!(&bytes, CHUNK); | ||
} |
22 changes: 19 additions & 3 deletions
22
crates/test-programs/src/bin/preview2_stream_pollable_correct.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
use test_programs::wasi::cli::stdin; | ||
use test_programs::wasi::io::streams; | ||
use test_programs::wasi::cli::{stdin, stdout}; | ||
|
||
fn main() { | ||
let stdin: streams::InputStream = stdin::get_stdin(); | ||
let stdin = stdin::get_stdin(); | ||
let stdin_pollable = stdin.subscribe(); | ||
stdin_pollable.block(); | ||
assert!(stdin_pollable.ready(), "after blocking, pollable is ready"); | ||
drop(stdin_pollable); | ||
drop(stdin); | ||
|
||
// Pollables can be used many times over their lifetime | ||
let stdout = stdout::get_stdout(); | ||
let stdout_pollable = stdout.subscribe(); | ||
|
||
let chunk = [b'a'; 50]; | ||
for _ in 1..10 { | ||
stdout_pollable.block(); | ||
assert!(stdout_pollable.ready(), "after blocking, pollable is ready"); | ||
|
||
let n = stdout.check_write().unwrap() as usize; | ||
assert!(n >= chunk.len()); | ||
stdout.write(&chunk).unwrap(); | ||
} | ||
|
||
drop(stdout_pollable); | ||
drop(stdout); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.