add swifi to the build/install.
[minix.git] / test / test40.c
blobc238dce93f3f9bde8cc7682d3ec4daa5c08f6990
1 /* Test40.c
3 * Test select(...) system call
5 */
7 #include <sys/types.h>
8 #include <sys/wait.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include <stdarg.h>
14 int main(int argc, char **argv) {
15 char *tests[] = {"t40a", "t40b", "t40c", "t40d", "t40e", "t40f"};
16 int no_tests, i, forkres, status = 0, errorct = 0;
18 no_tests = sizeof(tests) / sizeof(char *);
20 printf("Test 40 ");
21 fflush(stdout);
23 for(i = 0; i < no_tests; i++) {
24 char subtest[2];
25 sprintf(subtest, "%d", i+1);
27 forkres = fork();
28 if(forkres == 0) { /* Child */
29 execl(tests[i], tests[i], subtest, (char *) 0);
30 printf("Failed to execute subtest %s\n", tests[i]);
31 exit(-2);
32 } else if(forkres > 0) { /* Parent */
33 if(waitpid(forkres, &status, 0) > 0 && WEXITSTATUS(status) < 20) {
34 errorct += WEXITSTATUS(status); /* Count errors */
36 status = 0; /* Reset */
37 } else {
38 printf("Failed to fork\n");
39 exit(-2);
43 if(errorct == 0) {
44 printf("ok\n");
45 exit(0);
46 } else {
47 printf("%d error(s)\n", errorct);
48 exit(1);
51 return (-1); /* Impossible */