Skip to content

Commit 5f87ddb

Browse files
committed
test: Add test for select without PROXY_TO_PTHREAD
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
1 parent 5521c03 commit 5f87ddb

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

test/core/test_pipe_select.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <sys/select.h>
2+
#include <time.h>
3+
#include <assert.h>
4+
#include <stdio.h>
5+
#include <unistd.h>
6+
#include <string.h>
7+
8+
int pipe_a[2];
9+
10+
int main() {
11+
fd_set readfds;
12+
const char *t = "test\n";
13+
14+
assert(pipe(pipe_a) == 0);
15+
FD_ZERO(&readfds);
16+
FD_SET(pipe_a[0], &readfds);
17+
write(pipe_a[1], t, strlen(t));
18+
assert(select(pipe_a[0] + 1, &readfds, NULL, NULL, NULL) == 1);
19+
assert(FD_ISSET(pipe_a[0], &readfds));
20+
21+
close(pipe_a[0]); close(pipe_a[1]);
22+
23+
return 0;
24+
}

test/test_core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9668,6 +9668,13 @@ def test_syscall_intercept(self):
96689668
def test_select_blocking(self):
96699669
self.do_runf('core/test_select_blocking.c', cflags=['-pthread', '-sPROXY_TO_PTHREAD=1', '-sEXIT_RUNTIME=1', '-Wno-pthreads-mem-growth'])
96709670

9671+
@parameterized({
9672+
'': ([],),
9673+
'pthread': (['-pthread'],),
9674+
})
9675+
def test_pipe_select(self, args):
9676+
self.do_runf('core/test_pipe_select.c', cflags=args)
9677+
96719678
@also_without_bigint
96729679
def test_jslib_i64_params(self):
96739680
# Tests the defineI64Param and receiveI64ParamAsI53 helpers that are

0 commit comments

Comments
 (0)