Skip to content

Commit

Permalink
Add a test for empty poll.
Browse files Browse the repository at this point in the history
  • Loading branch information
marmistrz committed Jan 17, 2020
1 parent b572a32 commit a77c3b9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ unsafe fn poll_oneoff_impl(r#in: &[wasi::Subscription], nexpected: usize) -> Vec
out
}

unsafe fn test_empty_poll() {
let r#in = [];
let mut out: Vec<wasi::Event> = Vec::new();
let error = wasi::poll_oneoff(r#in.as_ptr(), out.as_mut_ptr(), r#in.len())
.expect_err("empty poll_oneoff should fail");
assert_eq!(
error.raw_error(),
wasi::ERRNO_INVAL,
"error should be EINVAL"
);
}

unsafe fn test_timeout() {
let clock = wasi::SubscriptionClock {
id: wasi::CLOCKID_MONOTONIC,
Expand Down Expand Up @@ -220,6 +232,7 @@ unsafe fn test_fd_readwrite_invalid_fd() {

unsafe fn test_poll_oneoff(dir_fd: wasi::Fd) {
test_timeout();
test_empty_poll();
// NB we assume that stdin/stdout/stderr are valid and open
// for the duration of the test case
test_stdin_read();
Expand Down

0 comments on commit a77c3b9

Please sign in to comment.