minix/test/select/test00.c
Ben Gras 42050e39f8 kernel and servers send diagnostic messages to IS; IS sends them to TTY
and the new log driver if enabled.

new usyslogd is started from /usr/etc/rc. New device created by
MAKEDEV.sh. /var/log created by etc/mtree/minix.tree (on root for
now). Made select() slightly more generic, with less code duplication.
2005-07-08 17:30:01 +00:00

58 lines
1.1 KiB
C

/*
* Test name: test00.c
*
* Objetive: The purpose of this test is to make sure that the bitmap
* manipulation macros work without problems.
*
* Description: This tests first fills a fd_set bit by bit, and shows it, then
* it clears the fd_set bit by bit as well.
*
* Jose M. Gomez
*/
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/select.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main(int argc, char *argv[]) {
fd_set fds;
int i,j;
FD_ZERO(&fds);
for (i=0;i<FD_SETSIZE;i++) {
/* see if SET works */
FD_SET(i, &fds);
if(!FD_ISSET(i, &fds))
return 1;
}
FD_ZERO(&fds);
for (i=0;i<FD_SETSIZE;i++) {
/* see if ZERO works */
if(FD_ISSET(i, &fds))
return 1;
}
for (i=0;i<FD_SETSIZE;i++) {
FD_SET(i, &fds);
for(j = 0; j <= i; j++)
if(!FD_ISSET(j, &fds))
return 1;
for(; j < FD_SETSIZE; j++)
if(FD_ISSET(j, &fds))
return 1;
}
for (i=0;i<FD_SETSIZE;i++) {
FD_CLR(i, &fds);
for(j = 0; j <= i; j++)
if(FD_ISSET(j, &fds))
return 1;
for(; j < FD_SETSIZE; j++)
if(!FD_ISSET(j, &fds))
return 1;
}
printf("ok\n");
return 0;
}