etc/services - sync with NetBSD-8
[minix.git] / minix / tests / test40.c
blobc4b84e8ede8f217cbe28e9f932282122458e63ad
1 /* Test40.c
3 * Test select(...) system call
5 */
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>
15 int max_error = 5;
16 #include "common.h"
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;
24 no_tests = sizeof(tests) / sizeof(char *);
26 start(40);
28 for(i = 0; i < no_tests; i++) {
29 char subtest[2];
30 snprintf(subtest, 2, "%d", i+1);
32 /* Copy subtest */
33 snprintf(copy_command, 8 + PATH_MAX, "cp ../%s .", tests[i]);
34 system(copy_command);
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 */
45 status = 0; /* Reset */
46 } else {
47 printf("Failed to fork\n");
48 exit(-2);
52 quit();
54 return (-1); /* Impossible */