Skip to content

Commit b6cb74d

Browse files
huseyinacacak-janeamarco-ippolito
authored andcommitted
test: split wasi poll test for windows
PR-URL: #52538 Fixes: #51822 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent c0c60d1 commit b6cb74d

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

test/wasi/c/poll.c

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ int main(void) {
3131
assert(ret == 0);
3232
assert(now - before >= 2);
3333

34+
// V8 has a bug that allows unsupported parts of this test to run,
35+
// causing the test to fail. poll_win.c is a workaround.
36+
// https://github.com/nodejs/node/issues/51822
3437
// The rest of the test is unsupported on Windows.
3538
if (is_win)
3639
return 0;

test/wasi/c/poll_win.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <assert.h>
2+
#include <poll.h>
3+
#include <time.h>
4+
#include <unistd.h>
5+
6+
int main(void) {
7+
struct pollfd fds[4];
8+
time_t before, now;
9+
int ret;
10+
11+
// Test sleep() behavior.
12+
time(&before);
13+
sleep(1);
14+
time(&now);
15+
assert(now - before >= 1);
16+
17+
// Test poll() timeout behavior.
18+
fds[0] = (struct pollfd){.fd = -1, .events = 0, .revents = 0};
19+
time(&before);
20+
ret = poll(fds, 1, 2000);
21+
time(&now);
22+
assert(ret == 0);
23+
assert(now - before >= 2);
24+
25+
return 0;
26+
}

test/wasi/test-wasi-poll.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
require('../common');
33
const { testWasiPreview1 } = require('../common/wasi');
44

5-
testWasiPreview1(['poll']);
5+
testWasiPreview1([process.platform === 'win32' ? 'poll_win' : 'poll']);

test/wasi/wasi.status

-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,3 @@ prefix wasi
66

77
[true] # This section applies to all platforms
88

9-
# Windows on ARM
10-
[$system==win32 && $arch==arm64]
11-
# https://github.com/nodejs/node/issues/51822
12-
test-wasi-poll: PASS, FLAKY

test/wasi/wasm/poll_win.wasm

31 KB
Binary file not shown.

0 commit comments

Comments
 (0)