Skip to content

Commit 815a161

Browse files
committed
test: Add test for select without PROXY_TO_PTHREAD
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
1 parent af19ab5 commit 815a161

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

test/core/test_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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9665,6 +9665,10 @@ def test_syscall_intercept(self):
96659665
def test_pthread_select_timeout(self):
96669666
self.do_runf('core/test_pthread_select_timeout.c', cflags=['-pthread', '-sPROXY_TO_PTHREAD=1', '-sEXIT_RUNTIME=1', '-Wno-pthreads-mem-growth'])
96679667

9668+
def test_select(self):
9669+
self.do_runf('core/test_select.c')
9670+
self.do_runf('core/test_select.c', cflags=['-pthread'])
9671+
96689672
@also_without_bigint
96699673
def test_jslib_i64_params(self):
96709674
# Tests the defineI64Param and receiveI64ParamAsI53 helpers that are

0 commit comments

Comments
 (0)