| Rev | Line | |
|---|
| [9] | 1 | /*
|
|---|
| 2 | * Test name: test00.c
|
|---|
| 3 | *
|
|---|
| 4 | * Objetive: The purpose of this test is to make sure that the bitmap
|
|---|
| 5 | * manipulation macros work without problems.
|
|---|
| 6 | *
|
|---|
| 7 | * Description: This tests first fills a fd_set bit by bit, and shows it, then
|
|---|
| 8 | * it clears the fd_set bit by bit as well.
|
|---|
| 9 | *
|
|---|
| 10 | * Jose M. Gomez
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 | #include <sys/types.h>
|
|---|
| 14 | #include <fcntl.h>
|
|---|
| 15 | #include <unistd.h>
|
|---|
| 16 | #include <sys/select.h>
|
|---|
| 17 | #include <stdio.h>
|
|---|
| 18 | #include <stdlib.h>
|
|---|
| 19 | #include <limits.h>
|
|---|
| 20 |
|
|---|
| 21 | int main(int argc, char *argv[]) {
|
|---|
| 22 | fd_set fds;
|
|---|
| 23 | int i,j;
|
|---|
| 24 |
|
|---|
| 25 | FD_ZERO(&fds);
|
|---|
| 26 | for (i=0;i<FD_SETSIZE;i++) {
|
|---|
| 27 | /* see if SET works */
|
|---|
| 28 | FD_SET(i, &fds);
|
|---|
| 29 | if(!FD_ISSET(i, &fds))
|
|---|
| 30 | return 1;
|
|---|
| 31 | }
|
|---|
| 32 | FD_ZERO(&fds);
|
|---|
| 33 | for (i=0;i<FD_SETSIZE;i++) {
|
|---|
| 34 | /* see if ZERO works */
|
|---|
| 35 | if(FD_ISSET(i, &fds))
|
|---|
| 36 | return 1;
|
|---|
| 37 | }
|
|---|
| 38 | for (i=0;i<FD_SETSIZE;i++) {
|
|---|
| 39 | FD_SET(i, &fds);
|
|---|
| 40 | for(j = 0; j <= i; j++)
|
|---|
| 41 | if(!FD_ISSET(j, &fds))
|
|---|
| 42 | return 1;
|
|---|
| 43 | for(; j < FD_SETSIZE; j++)
|
|---|
| 44 | if(FD_ISSET(j, &fds))
|
|---|
| 45 | return 1;
|
|---|
| 46 | }
|
|---|
| 47 | for (i=0;i<FD_SETSIZE;i++) {
|
|---|
| 48 | FD_CLR(i, &fds);
|
|---|
| 49 | for(j = 0; j <= i; j++)
|
|---|
| 50 | if(FD_ISSET(j, &fds))
|
|---|
| 51 | return 1;
|
|---|
| 52 | for(; j < FD_SETSIZE; j++)
|
|---|
| 53 | if(!FD_ISSET(j, &fds))
|
|---|
| 54 | return 1;
|
|---|
| 55 | }
|
|---|
| 56 | printf("ok\n");
|
|---|
| 57 | return 0;
|
|---|
| 58 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.