2 * Rudimentary test suite used while implementing pselect(2).
13 static int alarm_flag = 0;
23 set_alarm_flag(int signo)
30 * Try to detect regressions in select(2).
38 struct timeval timeout;
43 printf("test_select\n");
46 * It is always possible to write to stdout (if not redirected).
52 r = select(2, NULL, &wset, NULL, NULL);
54 assert(FD_ISSET(1, &wset));
57 * Write to a pipe and check a select on the read end does not block.
64 FD_SET(des[0], &rset);
67 r = write(des[1], buf, 1);
70 r = select(des[0]+1, &rset, NULL, NULL, NULL);
72 assert(FD_ISSET(des[0], &rset));
74 r = read(des[0], buf, 1);
76 assert(buf[0] == 'f');
79 * Block until signal reception.
86 FD_SET(des[0], &rset);
88 r = select(des[0]+1, &rset, NULL, NULL, NULL);
90 assert(errno == EINTR);
93 * Block until timeout.
97 FD_SET(des[0], &rset);
101 r = select(des[0]+1, &rset, NULL, NULL, &timeout);
105 * When the timeout is zero, the call should not block.
111 FD_SET(des[0], &rset);
113 r = select(des[0]+1, &rset, NULL, NULL, &timeout);