diff --git a/test/wasi/c/poll.c b/test/wasi/c/poll.c index bd2ff62613ea23..ba12f442654b4c 100644 --- a/test/wasi/c/poll.c +++ b/test/wasi/c/poll.c @@ -31,6 +31,9 @@ int main(void) { assert(ret == 0); assert(now - before >= 2); + // V8 has a bug that allows unsupported parts of this test to run, + // causing the test to fail. poll_win.c is a workaround. + // https://github.com/nodejs/node/issues/51822 // The rest of the test is unsupported on Windows. if (is_win) return 0; diff --git a/test/wasi/c/poll_win.c b/test/wasi/c/poll_win.c new file mode 100644 index 00000000000000..9a22082f0eeb9e --- /dev/null +++ b/test/wasi/c/poll_win.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +int main(void) { + struct pollfd fds[4]; + time_t before, now; + int ret; + + // Test sleep() behavior. + time(&before); + sleep(1); + time(&now); + assert(now - before >= 1); + + // Test poll() timeout behavior. + fds[0] = (struct pollfd){.fd = -1, .events = 0, .revents = 0}; + time(&before); + ret = poll(fds, 1, 2000); + time(&now); + assert(ret == 0); + assert(now - before >= 2); + + return 0; +} diff --git a/test/wasi/test-wasi-poll.js b/test/wasi/test-wasi-poll.js index 7448f626dca9b2..212aa1bf192e6b 100644 --- a/test/wasi/test-wasi-poll.js +++ b/test/wasi/test-wasi-poll.js @@ -2,4 +2,4 @@ require('../common'); const { testWasiPreview1 } = require('../common/wasi'); -testWasiPreview1(['poll']); +testWasiPreview1([process.platform === 'win32' ? 'poll_win' : 'poll']); diff --git a/test/wasi/wasi.status b/test/wasi/wasi.status index 500040c0c2a037..2870fc67f1c776 100644 --- a/test/wasi/wasi.status +++ b/test/wasi/wasi.status @@ -6,7 +6,3 @@ prefix wasi [true] # This section applies to all platforms -# Windows on ARM -[$system==win32 && $arch==arm64] -# https://github.com/nodejs/node/issues/51822 -test-wasi-poll: PASS, FLAKY diff --git a/test/wasi/wasm/poll_win.wasm b/test/wasi/wasm/poll_win.wasm new file mode 100644 index 00000000000000..f1f06db75469c3 Binary files /dev/null and b/test/wasi/wasm/poll_win.wasm differ