minix/test/test40.c
David van Moolenbroek 701f2b4dd5 VFS: select(2) fixes
- check each file descriptor's open access mode (filp_mode);
- treat an error returned by a character driver as a select error;
- check all filps in each set before finishing select;
- do not copy back file descriptor sets if an error occurred;
- remove the hardcoded list of supported character major devices,
  since all drivers should now be capable of responding properly;
- add tests to test40 and fix its error count aggregation.

Change-Id: I57ef58d3afb82640fc50b59c859ee4b25f02db17
2014-03-01 09:04:51 +01:00

55 lines
1.2 KiB
C

/* 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>
int max_error = 5;
#include "common.h"
int main(int argc, char **argv) {
char *tests[] = {"t40a", "t40b", "t40c", "t40d", "t40e", "t40f", "t40g"};
char copy_command[8+PATH_MAX+1];
int no_tests, i, forkres, status = 0;
no_tests = sizeof(tests) / sizeof(char *);
start(40);
for(i = 0; i < no_tests; i++) {
char subtest[2];
snprintf(subtest, 2, "%d", i+1);
/* Copy subtest */
snprintf(copy_command, 8 + PATH_MAX, "cp ../%s .", tests[i]);
system(copy_command);
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) {
errct += WEXITSTATUS(status); /* Count errors */
}
status = 0; /* Reset */
} else {
printf("Failed to fork\n");
exit(-2);
}
}
quit();
return (-1); /* Impossible */
}