test: split wasi poll test for windows

PR-URL: https://github.com/nodejs/node/pull/52538
Fixes: https://github.com/nodejs/node/issues/51822
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
This commit is contained in:
Hüseyin Açacak 2024-04-17 16:01:15 +03:00 committed by GitHub
parent 97627da32b
commit b41347e496
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 5 deletions

View File

@ -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;

26
test/wasi/c/poll_win.c Normal file
View File

@ -0,0 +1,26 @@
#include <assert.h>
#include <poll.h>
#include <time.h>
#include <unistd.h>
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;
}

View File

@ -2,4 +2,4 @@
require('../common');
const { testWasiPreview1 } = require('../common/wasi');
testWasiPreview1(['poll']);
testWasiPreview1([process.platform === 'win32' ? 'poll_win' : 'poll']);

View File

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

Binary file not shown.