Skip to content

Commit 1d46cc3

Browse files
committed
Add a small test checking that pollables can be used many times
1 parent 446a7f5 commit 1d46cc3

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
use test_programs::wasi::cli::stdin;
2-
use test_programs::wasi::io::streams;
1+
use test_programs::wasi::cli::{stdin, stdout};
32

43
fn main() {
5-
let stdin: streams::InputStream = stdin::get_stdin();
4+
let stdin = stdin::get_stdin();
65
let stdin_pollable = stdin.subscribe();
76
stdin_pollable.block();
87
assert!(stdin_pollable.ready(), "after blocking, pollable is ready");
98
drop(stdin_pollable);
109
drop(stdin);
10+
11+
// Pollables can be used many times over their lifetime
12+
let stdout = stdout::get_stdout();
13+
let stdout_pollable = stdout.subscribe();
14+
15+
let chunk = [b'a'; 50];
16+
for _ in 1..10 {
17+
stdout_pollable.block();
18+
assert!(stdout_pollable.ready(), "after blocking, pollable is ready");
19+
20+
let n = stdout.check_write().unwrap() as usize;
21+
assert!(n >= chunk.len());
22+
stdout.write(&chunk).unwrap();
23+
}
24+
25+
drop(stdout_pollable);
26+
drop(stdout);
1127
}

0 commit comments

Comments
 (0)