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
This commit is contained in:
Pat Hickey
2021-01-14 17:41:27 -08:00
parent f667263d9c
commit b84c4d7488

View File

@@ -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) {