3 * Test select on character driver that does not support select
5 * We use /dev/zero for this right now. If the memory driver ever implements
6 * select support, this test should be changed to use another character driver.
12 #include <sys/types.h>
13 #include <sys/select.h>
25 main(int argc
, char **argv
)
30 /* Get subtest number */
31 if (argc
!= 2 || sscanf(argv
[1], "%d", &subtest
) != 1) {
32 printf("Usage: %s subtest_no\n", argv
[0]);
37 * Do a select on /dev/zero, with the expectation that it will fail
38 * with an EBADF error code.
40 fd
= open("/dev/zero", O_RDONLY
);
41 if (fd
< 0) em(1, "unable to open /dev/zero");
46 retval
= select(fd
+ 1, &set
, NULL
, NULL
, NULL
);
47 if (retval
!= -1) em(2, "select call was expected to fail");
48 if (errno
!= EBADF
) em(3, "error code other than EBADF returned");
49 if (!FD_ISSET(fd
, &set
)) em(4, "file descriptor set was modified");