MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / test_select

Function test_select

test/unistd/pipe.c:48–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46// result.
47
48void test_select(int *fd, bool data_available) {
49 fd_set rfds;
50 FD_ZERO(&rfds);
51 FD_SET(fd[0], &rfds);
52 FD_SET(fd[1], &rfds);
53
54 fd_set wfds;
55 FD_ZERO(&wfds);
56 FD_SET(fd[0], &wfds);
57 FD_SET(fd[1], &wfds);
58
59 // Don't block at all
60 struct timeval tv = { 0, 0};
61 int maxfd = MAX(fd[0], fd[1]) + 1;
62 int ret = select(maxfd, &rfds, &wfds, NULL, &tv);
63
64 if (data_available) {
65 assert(ret == 2);
66 assert(FD_ISSET(fd[0], &rfds));
67 } else {
68 assert(ret == 1);
69 assert(!FD_ISSET(fd[0], &rfds));
70 }
71
72 assert(FD_ISSET(fd[1], &wfds));
73}
74
75void test_poll(int *fd, int data_available) {
76 struct pollfd pfds[2];

Callers 1

test_pollFunction · 0.85

Calls 2

selectFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected