From b84c4d748826837fb532fa64bf32ac6b50690d77 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 14 Jan 2021 17:41:27 -0800 Subject: [PATCH] poll_oneoff test: if you subscribe to a badf, the whole call fails with badf rather than the results telling you an individual file was a badf. why? i think the old behavior was too clever, and makes it harder to write a scheduler. * what should the call do when you pass it some badf and some not-badf? i don't think anything besides exiting early is the correct answer. * the results vector tells you something that the scheduler had to say about the file, not about your inputs. the errno of the function always says what the validity of the inputs was --- .../wasi-tests/src/bin/poll_oneoff.rs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs b/crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs index 93343374bf..914c54d024 100644 --- a/crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs +++ b/crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs @@ -247,7 +247,31 @@ unsafe fn test_fd_readwrite_valid_fd(dir_fd: wasi::Fd) { } unsafe fn test_fd_readwrite_invalid_fd() { - test_fd_readwrite(wasi::Fd::max_value(), wasi::ERRNO_BADF) + let fd_readwrite = wasi::SubscriptionFdReadwrite { + file_descriptor: wasi::Fd::max_value(), + }; + let r#in = [ + wasi::Subscription { + userdata: 1, + u: wasi::SubscriptionU { + tag: wasi::EVENTTYPE_FD_READ, + u: wasi::SubscriptionUU { + fd_read: fd_readwrite, + }, + }, + }, + wasi::Subscription { + userdata: 2, + u: wasi::SubscriptionU { + tag: wasi::EVENTTYPE_FD_WRITE, + u: wasi::SubscriptionUU { + fd_write: fd_readwrite, + }, + }, + }, + ]; + let err = poll_oneoff_impl(&r#in).unwrap_err(); + assert_eq!(err.raw_error(), wasi::ERRNO_BADF) } unsafe fn test_poll_oneoff(dir_fd: wasi::Fd) {