accept fdread event as valid behavior of stdin poll

This commit is contained in:
Pat Hickey
2021-02-01 15:25:00 -08:00
parent 0c4aec391e
commit bb3e391a27
2 changed files with 20 additions and 28 deletions

View File

@@ -1,5 +1,4 @@
use anyhow::Context;
use std::convert::TryInto;
use std::path::Path;
use wasi_cap_std_sync::WasiCtxBuilder;
use wasi_common::pipe::{ReadPipe, WritePipe};
@@ -89,21 +88,6 @@ pub fn instantiate_inherit_stdio(
let r = {
let store = Store::default();
// Tests assume that stdin does not have any bytes available to read. Make sure this is the
// case, regardless of the test environment:
use std::io::Read;
use system_interface::io::ReadReady;
let nbytes = std::io::stdin()
.num_ready_bytes()
.expect("get stdin's ready bytes");
if nbytes > 0 {
let mut stdin_contents = Vec::new();
stdin_contents.resize(nbytes.try_into().expect("ready bytes fits in memory"), 0);
std::io::stdin()
.read(stdin_contents.as_mut_slice())
.expect("read stdin to end");
}
// Create our wasi context.
// Additionally register any preopened directories if we have them.
let mut builder = WasiCtxBuilder::new();