2009-07-14 11:43:33 +02:00
|
|
|
/* Test40.c
|
|
|
|
*
|
|
|
|
* Test select(...) system call
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2013-04-16 18:04:46 +02:00
|
|
|
int max_error = 5;
|
|
|
|
#include "common.h"
|
|
|
|
|
2011-04-21 15:18:00 +02:00
|
|
|
|
2009-07-14 11:43:33 +02:00
|
|
|
int main(int argc, char **argv) {
|
2013-09-11 01:13:59 +02:00
|
|
|
char *tests[] = {"t40a", "t40b", "t40c", "t40d", "t40e", "t40f", "t40g"};
|
2011-04-21 15:18:00 +02:00
|
|
|
char copy_command[8+PATH_MAX+1];
|
2013-09-11 01:13:59 +02:00
|
|
|
int no_tests, i, forkres, status = 0;
|
2009-07-14 11:43:33 +02:00
|
|
|
|
|
|
|
no_tests = sizeof(tests) / sizeof(char *);
|
|
|
|
|
2011-04-21 15:18:00 +02:00
|
|
|
start(40);
|
2009-07-14 11:43:33 +02:00
|
|
|
|
|
|
|
for(i = 0; i < no_tests; i++) {
|
|
|
|
char subtest[2];
|
2011-04-21 15:18:00 +02:00
|
|
|
snprintf(subtest, 2, "%d", i+1);
|
2009-07-14 11:43:33 +02:00
|
|
|
|
2011-04-21 15:18:00 +02:00
|
|
|
/* Copy subtest */
|
|
|
|
snprintf(copy_command, 8 + PATH_MAX, "cp ../%s .", tests[i]);
|
|
|
|
system(copy_command);
|
|
|
|
|
2009-07-14 11:43:33 +02:00
|
|
|
forkres = fork();
|
|
|
|
if(forkres == 0) { /* Child */
|
|
|
|
execl(tests[i], tests[i], subtest, (char *) 0);
|
|
|
|
printf("Failed to execute subtest %s\n", tests[i]);
|
|
|
|
exit(-2);
|
|
|
|
} else if(forkres > 0) { /* Parent */
|
|
|
|
if(waitpid(forkres, &status, 0) > 0 && WEXITSTATUS(status) < 20) {
|
2013-09-11 01:13:59 +02:00
|
|
|
errct += WEXITSTATUS(status); /* Count errors */
|
2009-07-14 11:43:33 +02:00
|
|
|
}
|
|
|
|
status = 0; /* Reset */
|
|
|
|
} else {
|
|
|
|
printf("Failed to fork\n");
|
|
|
|
exit(-2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-21 15:18:00 +02:00
|
|
|
quit();
|
2009-07-14 11:43:33 +02:00
|
|
|
|
|
|
|
return (-1); /* Impossible */
|
|
|
|
}
|
|
|
|
|