Skip to content

Commit

Permalink
test: split wasi poll test for windows
Browse files Browse the repository at this point in the history
PR-URL: #52538
Fixes: #51822
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
huseyinacacak-janea authored and marco-ippolito committed May 3, 2024
1 parent c0c60d1 commit b6cb74d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions test/wasi/c/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions test/wasi/c/poll_win.c
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion test/wasi/test-wasi-poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
require('../common');
const { testWasiPreview1 } = require('../common/wasi');

testWasiPreview1(['poll']);
testWasiPreview1([process.platform === 'win32' ? 'poll_win' : 'poll']);
4 changes: 0 additions & 4 deletions test/wasi/wasi.status
Original file line number Diff line number Diff line change
Expand Up @@ -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 added test/wasi/wasm/poll_win.wasm
Binary file not shown.

0 comments on commit b6cb74d

Please sign in to comment.