Style
This commit is contained in:
parent
59f1ce0f44
commit
fa439e7bbc
@ -36,7 +36,8 @@ int run_test(test_entry_t *test) {
|
||||
if (helper->is_helper &&
|
||||
strcmp(test->test_name, helper->test_name) == 0) {
|
||||
if (process_start(helper->process_name, &processes[process_count]) == -1) {
|
||||
snprintf((char*)&errmsg, sizeof(errmsg), "process `%s` failed to start.", helper->process_name);
|
||||
snprintf((char*)&errmsg, sizeof(errmsg),
|
||||
"process `%s` failed to start.", helper->process_name);
|
||||
goto finalize;
|
||||
}
|
||||
process_count++;
|
||||
@ -45,7 +46,8 @@ int run_test(test_entry_t *test) {
|
||||
|
||||
/* Start the main test process. */
|
||||
if (process_start(test->process_name, &processes[process_count]) == -1) {
|
||||
snprintf((char*)&errmsg, sizeof(errmsg), "process `%s` failed to start.", test->process_name);
|
||||
snprintf((char*)&errmsg, sizeof(errmsg), "process `%s` failed to start.",
|
||||
test->process_name);
|
||||
goto finalize;
|
||||
}
|
||||
main_process = &processes[process_count];
|
||||
@ -72,26 +74,31 @@ int run_test(test_entry_t *test) {
|
||||
|
||||
finalize:
|
||||
/* Kill all (helper) processes that are still running. */
|
||||
for (i = 0; i < process_count; i++)
|
||||
for (i = 0; i < process_count; i++) {
|
||||
/* If terminate fails the process is probably already closed. */
|
||||
process_terminate(&processes[i]);
|
||||
}
|
||||
|
||||
/* Wait until all processes have really terminated. */
|
||||
if (process_wait((process_info_t*)&processes, process_count, -1) < 0)
|
||||
if (process_wait((process_info_t*)&processes, process_count, -1) < 0) {
|
||||
FATAL("process_wait failed");
|
||||
}
|
||||
|
||||
/* Show error and output from processes if the test failed. */
|
||||
if (!success) {
|
||||
LOG("===============================================================================\n");
|
||||
LOG("=============================================================\n");
|
||||
LOGF("Test `%s` failed: %s\n", test->test_name, errmsg);
|
||||
|
||||
for (i = 0; i < process_count; i++) {
|
||||
switch (process_output_size(&processes[i])) {
|
||||
case -1:
|
||||
LOGF("Output from process `%s`: << unavailable >>\n", process_get_name(&processes[i]));
|
||||
LOGF("Output from process `%s`: << unavailable >>\n",
|
||||
process_get_name(&processes[i]));
|
||||
break;
|
||||
|
||||
case 0:
|
||||
LOGF("Output from process `%s`: << no output >>\n", process_get_name(&processes[i]));
|
||||
LOGF("Output from process `%s`: << no output >>\n",
|
||||
process_get_name(&processes[i]));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -104,15 +111,17 @@ finalize:
|
||||
}
|
||||
|
||||
/* Clean up all process handles. */
|
||||
for (i = 0; i < process_count; i++)
|
||||
for (i = 0; i < process_count; i++) {
|
||||
process_cleanup(&processes[i]);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
void log_progress(int total, int passed, int failed, char *name) {
|
||||
LOGF("[%% %3d|+ %3d|- %3d]: %-50s\n", (passed + failed) / total * 100, passed, failed, name);
|
||||
LOGF("[%% %3d|+ %3d|- %3d]: %-50s\n", (passed + failed) / total * 100,
|
||||
passed, failed, name);
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +131,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
#ifdef _WIN32
|
||||
/* On windows disable the "application crashed" popup. */
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
|
||||
SEM_NOOPENFILEERRORBOX);
|
||||
#endif
|
||||
|
||||
/* Disable stdio output buffering. */
|
||||
@ -132,8 +142,9 @@ int main(int argc, char **argv) {
|
||||
if (argc > 1) {
|
||||
/* A specific test process is being started. */
|
||||
for (test = (test_entry_t*)&TESTS; test->main; test++) {
|
||||
if (strcmp(argv[1], test->process_name) == 0)
|
||||
if (strcmp(argv[1], test->process_name) == 0) {
|
||||
return test->main();
|
||||
}
|
||||
}
|
||||
LOGF("Test process %s not found!\n", argv[1]);
|
||||
return 255;
|
||||
@ -143,8 +154,9 @@ int main(int argc, char **argv) {
|
||||
total = 0;
|
||||
test = (test_entry_t*)&TESTS;
|
||||
for (test = (test_entry_t*)&TESTS; test->main; test++) {
|
||||
if (!test->is_helper)
|
||||
if (!test->is_helper) {
|
||||
total++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Run all tests. */
|
||||
@ -152,8 +164,9 @@ int main(int argc, char **argv) {
|
||||
failed = 0;
|
||||
test = (test_entry_t*)&TESTS;
|
||||
for (test = (test_entry_t*)&TESTS; test->main; test++) {
|
||||
if (test->is_helper)
|
||||
if (test->is_helper) {
|
||||
continue;
|
||||
}
|
||||
|
||||
log_progress(total, passed, failed, test->test_name);
|
||||
rewind_cursor();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user