xref: /minix/minix/tests/test40.c (revision 7f5f010b)
1 /* Test40.c
2  *
3  * Test select(...) system call
4  *
5  */
6 
7 #include <sys/types.h>
8 #include <sys/wait.h>
9 #include <sys/syslimits.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <stdarg.h>
14 
15 int max_error = 5;
16 #include "common.h"
17 
18 
19 int main(int argc, char **argv) {
20   char *tests[] = {"t40a", "t40b", "t40c", "t40d", "t40e", "t40f", "t40g"};
21   char copy_command[8+PATH_MAX+1];
22   int no_tests, i, forkres, status = 0;
23 
24   no_tests = sizeof(tests) / sizeof(char *);
25 
26   start(40);
27 
28   for(i = 0; i < no_tests; i++) {
29     char subtest[2];
30     snprintf(subtest, 2, "%d", i+1);
31 
32     /* Copy subtest */
33     snprintf(copy_command, 8 + PATH_MAX, "cp ../%s .", tests[i]);
34     system(copy_command);
35 
36     forkres = fork();
37     if(forkres == 0) { /* Child */
38       execl(tests[i], tests[i], subtest, (char *) 0);
39       printf("Failed to execute subtest %s\n", tests[i]);
40       exit(-2);
41     } else if(forkres > 0) { /* Parent */
42       if(waitpid(forkres, &status, 0) > 0 && WEXITSTATUS(status) < 20) {
43 	errct += WEXITSTATUS(status); /* Count errors */
44       }
45       status = 0; /* Reset */
46     } else {
47       printf("Failed to fork\n");
48       exit(-2);
49     }
50   }
51 
52   quit();
53 
54   return (-1); /* Impossible */
55 }
56 
57