Merge pull request #2896 from bytecodealliance/pch/wasi_stdio_test_timeout

wasi stdio tests: increase timeout
This commit is contained in:
Pat Hickey
2021-05-11 10:39:23 -07:00
committed by GitHub
2 changed files with 8 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ use std::collections::HashMap;
use std::mem::MaybeUninit; use std::mem::MaybeUninit;
use wasi_tests::{assert_errno, STDERR_FD, STDIN_FD, STDOUT_FD}; use wasi_tests::{assert_errno, STDERR_FD, STDIN_FD, STDOUT_FD};
const TIMEOUT: u64 = 20_000_000u64; // 20 milliseconds, required to satisfy slow execution in CI
const CLOCK_ID: wasi::Userdata = 0x0123_45678; const CLOCK_ID: wasi::Userdata = 0x0123_45678;
const STDIN_ID: wasi::Userdata = 0x8765_43210; const STDIN_ID: wasi::Userdata = 0x8765_43210;
@@ -18,7 +19,7 @@ unsafe fn poll_oneoff_impl(r#in: &[wasi::Subscription]) -> Result<Vec<wasi::Even
unsafe fn test_stdin_read() { unsafe fn test_stdin_read() {
let clock = wasi::SubscriptionClock { let clock = wasi::SubscriptionClock {
id: wasi::CLOCKID_MONOTONIC, id: wasi::CLOCKID_MONOTONIC,
timeout: 5_000_000u64, // 5 milliseconds timeout: TIMEOUT,
precision: 0, precision: 0,
flags: 0, flags: 0,
}; };
@@ -95,7 +96,7 @@ unsafe fn test_stdout_stderr_write() {
u: wasi::SubscriptionUU { u: wasi::SubscriptionUU {
clock: wasi::SubscriptionClock { clock: wasi::SubscriptionClock {
id: wasi::CLOCKID_MONOTONIC, id: wasi::CLOCKID_MONOTONIC,
timeout: 10_000_000u64, // 10 milliseconds timeout: TIMEOUT,
precision: 0, precision: 0,
flags: 0, flags: 0,
}, },

View File

@@ -8,6 +8,8 @@ use wasi_common::{
}; };
use wasi_tokio::{clocks_ctx, sched::poll_oneoff, Dir}; use wasi_tokio::{clocks_ctx, sched::poll_oneoff, Dir};
const TIMEOUT: Duration = Duration::from_millis(20); // Required for slow execution in CI
#[tokio::test(flavor = "multi_thread")] #[tokio::test(flavor = "multi_thread")]
async fn empty_file_readable() -> Result<(), Error> { async fn empty_file_readable() -> Result<(), Error> {
let clocks = clocks_ctx(); let clocks = clocks_ctx();
@@ -40,7 +42,7 @@ async fn empty_file_readable() -> Result<(), Error> {
clocks clocks
.monotonic .monotonic
.now(clocks.monotonic.resolution()) .now(clocks.monotonic.resolution())
.checked_add(Duration::from_millis(10)) .checked_add(TIMEOUT)
.unwrap(), .unwrap(),
clocks.monotonic.resolution(), clocks.monotonic.resolution(),
Userdata::from(0), Userdata::from(0),
@@ -82,7 +84,7 @@ async fn empty_file_writable() -> Result<(), Error> {
clocks clocks
.monotonic .monotonic
.now(clocks.monotonic.resolution()) .now(clocks.monotonic.resolution())
.checked_add(Duration::from_millis(10)) .checked_add(TIMEOUT)
.unwrap(), .unwrap(),
clocks.monotonic.resolution(), clocks.monotonic.resolution(),
Userdata::from(0), Userdata::from(0),
@@ -109,7 +111,7 @@ async fn stdio_readable() -> Result<(), Error> {
let deadline = clocks let deadline = clocks
.monotonic .monotonic
.now(clocks.monotonic.resolution()) .now(clocks.monotonic.resolution())
.checked_add(Duration::from_millis(10)) .checked_add(TIMEOUT)
.unwrap(); .unwrap();
let mut waiting_on: HashMap<u64, Box<dyn WasiFile>> = vec![ let mut waiting_on: HashMap<u64, Box<dyn WasiFile>> = vec![