45 lines
1.3 KiB
C
45 lines
1.3 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
int i, pass = 0, fail = 0, skip = 0, total, ret, read = 0;
|
|
FILE *pipe;
|
|
char cmd[100], output[500];
|
|
|
|
total = argc-1;
|
|
printf("\n\t=== \033[0;33mRunning %i tests\033[0m ===\n", total);
|
|
for (i = 1; i < argc; i++) {
|
|
snprintf(cmd, 100, "./%s", argv[i]);
|
|
printf("%-25s", argv[i]);
|
|
pipe = popen(cmd, "w");
|
|
read = fread(&output, 1, 500, pipe);
|
|
ret = pclose(pipe);
|
|
if (read) {
|
|
fail++;
|
|
printf("\033[0;31mFailed\033[0m\n");
|
|
fprintf(stderr, "%s\n", &output);
|
|
continue;
|
|
}
|
|
switch (WEXITSTATUS(ret)) {
|
|
case 0:
|
|
pass++;
|
|
printf("\033[0;32mSuccess\033[0m\n");
|
|
break;
|
|
case 255:
|
|
skip++;
|
|
printf("Skipped\n");
|
|
break;
|
|
default:
|
|
fail++;
|
|
printf("\033[0;31mFailed\033[0m\n");
|
|
}
|
|
}
|
|
if (fail) {
|
|
printf("\nResults: \033[0;31mFAILED\033[0m %i succeeded; %i failed; %i skipped\n",
|
|
pass, fail, skip);
|
|
} else {
|
|
printf("\nResults: \033[0;32mOk\033[0m %i succeeded; %i failed; %i skipped\n",
|
|
pass, fail, skip);
|
|
}
|
|
return 0;
|
|
}
|