static void stats_print(Stats *stats)
{
- Log << "\tTotal Collections\t\t\t\t" << stats->collection_total;
- Log << "\tFailed Collections\t\t\t\t" << stats->collection_failed;
- Log << "\tSkipped Collections\t\t\t\t" << stats->collection_skipped;
- Log << "\tSucceeded Collections\t\t\t\t" << stats->collection_success;
- Logn();
- Log << "Total\t\t\t\t" << stats->total;
- Log << "\tFailed\t\t\t" << stats->failed;
- Log << "\tSkipped\t\t\t" << stats->skipped;
- Log << "\tSucceeded\t\t" << stats->success;
+ Out << "\tTotal Collections\t\t\t\t" << stats->collection_total;
+ Out << "\tFailed Collections\t\t\t\t" << stats->collection_failed;
+ Out << "\tSkipped Collections\t\t\t\t" << stats->collection_skipped;
+ Out << "\tSucceeded Collections\t\t\t\t" << stats->collection_success;
+ Outn();
+ Out << "Total\t\t\t\t" << stats->total;
+ Out << "\tFailed\t\t\t" << stats->failed;
+ Out << "\tSkipped\t\t\t" << stats->skipped;
+ Out << "\tSucceeded\t\t" << stats->success;
}
static long int timedif(struct timeval a, struct timeval b)
return EXIT_FAILURE;
}
- setup_signals();
+ libtest::SignalThread signal;
+ if (not signal.setup())
+ {
+ return EXIT_FAILURE;
+ }
Stats stats;
if (collection_to_run)
{
- Log << "Only testing " << collection_to_run;
+ Out << "Only testing " << collection_to_run;
}
char *wildcard= NULL;
wildcard= argv[2];
}
- for (collection_st *next= world->collections; next->name and (not is_shutdown()); next++)
+ for (collection_st *next= world->collections; next->name and (not signal.is_shutdown()); next++)
{
test_return_t collection_rc= TEST_SUCCESS;
bool failed= false;
case TEST_FATAL:
case TEST_FAILURE:
- Error << next->name << " [ failed ]";
+ Out << next->name << " [ failed ]";
failed= true;
- set_shutdown(SHUTDOWN_GRACEFUL);
+ signal.set_shutdown(SHUTDOWN_GRACEFUL);
goto cleanup;
case TEST_SKIPPED:
- Log << next->name << " [ skipping ]";
+ Out << next->name << " [ skipping ]";
skipped= true;
goto cleanup;
test_assert(0, "Allocation failure, or unknown return");
}
- Log << "Collection: " << next->name;
+ Out << "Collection: " << next->name;
for (test_st *run= next->tests; run->name; run++)
{
else if (return_code == TEST_FAILURE)
{
Error << " item.flush(failure)";
- set_shutdown(SHUTDOWN_GRACEFUL);
+ signal.set_shutdown(SHUTDOWN_GRACEFUL);
}
}
else if (return_code == TEST_SKIPPED)
else if (return_code == TEST_FAILURE)
{
Error << " item.startup(failure)";
- set_shutdown(SHUTDOWN_GRACEFUL);
+ signal.set_shutdown(SHUTDOWN_GRACEFUL);
}
stats.total++;
switch (return_code)
{
case TEST_SUCCESS:
- Log << "\tTesting " << run->name << "\t\t\t\t\t" << load_time / 1000 << "." << load_time % 1000 << "[ " << test_strerror(return_code) << " ]";
+ Out << "\tTesting " << run->name << "\t\t\t\t\t" << load_time / 1000 << "." << load_time % 1000 << "[ " << test_strerror(return_code) << " ]";
stats.success++;
break;
case TEST_FAILURE:
stats.failed++;
failed= true;
- Log << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]";
+ Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]";
break;
case TEST_SKIPPED:
stats.skipped++;
skipped= true;
- Log << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]";
+ Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]";
break;
case TEST_MEMORY_ALLOCATION_FAILURE:
if (test_failed(world->on_error(return_code, creators_ptr)))
{
Error << "Failed while running on_error()";
- set_shutdown(SHUTDOWN_GRACEFUL);
+ signal.set_shutdown(SHUTDOWN_GRACEFUL);
break;
}
}
}
world->shutdown(creators_ptr);
- Logn();
+ Outn();
}
- if (not is_shutdown())
+ if (not signal.is_shutdown())
{
- set_shutdown(SHUTDOWN_GRACEFUL);
+ signal.set_shutdown(SHUTDOWN_GRACEFUL);
}
int exit_code= EXIT_SUCCESS;
- shutdown_t status= get_shutdown();
+ shutdown_t status= signal.get_shutdown();
if (status == SHUTDOWN_FORCED)
{
- Log << "Tests were aborted.";
+ Out << "Tests were aborted.";
exit_code= EXIT_FAILURE;
}
else if (stats.collection_failed)
{
- Log << "Some test failed.";
+ Out << "Some test failed.";
exit_code= EXIT_FAILURE;
}
else if (stats.collection_skipped)
{
- Log << "Some tests were skipped.";
+ Out << "Some tests were skipped.";
}
else
{
- Log << "All tests completed successfully.";
+ Out << "All tests completed successfully.";
}
stats_print(&stats);
delete world;
- Logn(); // Generate a blank to break up the messages if make check/test has been run
+ Outn(); // Generate a blank to break up the messages if make check/test has been run
return exit_code;
}