diff --git a/src/uvwasi.c b/src/uvwasi.c index c08d090..46e50c6 100644 --- a/src/uvwasi.c +++ b/src/uvwasi.c @@ -2259,6 +2259,11 @@ uvwasi_errno_t uvwasi_poll_oneoff(uvwasi_t* uvwasi, uvwasi_event_t* out, size_t nsubscriptions, size_t* nevents) { + if (uvwasi == NULL || in == NULL || out == NULL || + nsubscriptions == 0 || nevents == NULL) { + return UVWASI_EINVAL; + } + /* TODO(cjihrig): Implement this. */ return UVWASI_ENOTSUP; } diff --git a/test/test-einval-input-validation.c b/test/test-einval-input-validation.c index e246ae3..3bb0b75 100644 --- a/test/test-einval-input-validation.c +++ b/test/test-einval-input-validation.c @@ -20,6 +20,8 @@ int main(void) { uvwasi_prestat_t test_prestat; uvwasi_dircookie_t test_dircookie = 0; uvwasi_filesize_t test_filesize; + uvwasi_subscription_t test_sub; + uvwasi_event_t test_event; uvwasi_fd_t test_fd; test_void = (void*) &test_fdstat; @@ -145,7 +147,11 @@ int main(void) { CHECK(uvwasi_path_unlink_file(NULL, 3, test_str, 10)); CHECK(uvwasi_path_unlink_file(&uvw, 3, NULL, 10)); - /* TODO(cjihrig): Add uvwasi_poll_oneoff() tests. */ + CHECK(uvwasi_poll_oneoff(NULL, &test_sub, &test_event, 5, &test_size)); + CHECK(uvwasi_poll_oneoff(&uvw, NULL, &test_event, 5, &test_size)); + CHECK(uvwasi_poll_oneoff(&uvw, &test_sub, NULL, 5, &test_size)); + CHECK(uvwasi_poll_oneoff(&uvw, &test_sub, &test_event, 0, &test_size)); + CHECK(uvwasi_poll_oneoff(&uvw, &test_sub, &test_event, 5, NULL)); CHECK(uvwasi_proc_raise(NULL, UVWASI_SIGUSR2)); diff --git a/test/test-enotsup-apis.c b/test/test-enotsup-apis.c index 95bac35..fdf0c0d 100644 --- a/test/test-enotsup-apis.c +++ b/test/test-enotsup-apis.c @@ -3,7 +3,6 @@ int main(void) { /* TODO(cjihrig): This test is intended to be temporary. */ - assert(UVWASI_ENOTSUP == uvwasi_poll_oneoff(NULL, NULL, NULL, 0, NULL)); assert(UVWASI_ENOTSUP == uvwasi_sock_recv(NULL, 0, NULL, 0, 0, NULL, NULL)); assert(UVWASI_ENOTSUP == uvwasi_sock_send(NULL, 0, NULL, 0, 0, NULL)); assert(UVWASI_ENOTSUP == uvwasi_sock_shutdown(NULL, 0, 0));