pkgin_all: script to auto-install all packages
[minix.git] / test / test40.c
blob74593e1a20ebb12a7db6735475b463c25afbe3b6
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 #define MAX_ERROR 5
15 #include "common.c"
17 int main(int argc, char **argv) {
18 char *tests[] = {"t40a", "t40b", "t40c", "t40d", "t40e", "t40f"};
19 char copy_command[8+PATH_MAX+1];
20 int no_tests, i, forkres, status = 0, errorct = 0;
22 no_tests = sizeof(tests) / sizeof(char *);
24 start(40);
26 for(i = 0; i < no_tests; i++) {
27 char subtest[2];
28 snprintf(subtest, 2, "%d", i+1);
30 /* Copy subtest */
31 snprintf(copy_command, 8 + PATH_MAX, "cp ../%s .", tests[i]);
32 system(copy_command);
34 forkres = fork();
35 if(forkres == 0) { /* Child */
36 execl(tests[i], tests[i], subtest, (char *) 0);
37 printf("Failed to execute subtest %s\n", tests[i]);
38 exit(-2);
39 } else if(forkres > 0) { /* Parent */
40 if(waitpid(forkres, &status, 0) > 0 && WEXITSTATUS(status) < 20) {
41 errorct += WEXITSTATUS(status); /* Count errors */
43 status = 0; /* Reset */
44 } else {
45 printf("Failed to fork\n");
46 exit(-2);
50 quit();
52 return (-1); /* Impossible */