#include <unistd.h>
#include <time.h>
#include <fnmatch.h>
+#include <stdint.h>
#include "test.h"
static void world_stats_print(world_stats_st *stats)
{
+ fputc('\n', stderr);
+ fprintf(stderr, "Total Collections\t\t\t\t%u\n", stats->collection_total);
+ fprintf(stderr, "\tFailed Collections\t\t\t%u\n", stats->collection_failed);
+ fprintf(stderr, "\tSkipped Collections\t\t\t%u\n", stats->collection_skipped);
+ fprintf(stderr, "\tSucceeded Collections\t\t%u\n", stats->collection_success);
+ fputc('\n', stderr);
fprintf(stderr, "Total\t\t\t\t%u\n", stats->total);
fprintf(stderr, "\tFailed\t\t\t%u\n", stats->failed);
fprintf(stderr, "\tSkipped\t\t\t%u\n", stats->skipped);
for (next= collection; next->name; next++)
{
+ test_return_t collection_rc= TEST_SUCCESS;
test_st *run;
+ bool failed= false;
+ bool skipped= false;
run= next->tests;
if (collection_to_run && fnmatch(collection_to_run, next->name, 0))
continue;
- fprintf(stderr, "\n%s\n\n", next->name);
+ stats.collection_total++;
+
+ if (world.collection_startup)
+ {
+ collection_rc= world.test_startup(world_ptr);
+ }
+
+ switch (collection_rc)
+ {
+ case TEST_SUCCESS:
+ fprintf(stderr, "\n%s\n\n", next->name);
+ break;
+ case TEST_FAILURE:
+ fprintf(stderr, "\n%s [ failed ]\n\n", next->name);
+ stats.failed++;
+ continue;
+ case TEST_SKIPPED:
+ fprintf(stderr, "\n%s [ skipping ]\n\n", next->name);
+ stats.skipped++;
+ continue;
+ case TEST_MEMORY_ALLOCATION_FAILURE:
+ case TEST_MAXIMUM_RETURN:
+ default:
+ assert(0);
+ break;
+ }
for (x= 0; run->name; run++)
{
break;
case TEST_FAILURE:
stats.failed++;
+ failed= true;
break;
case TEST_SKIPPED:
stats.skipped++;
+ skipped= true;
break;
case TEST_MEMORY_ALLOCATION_FAILURE:
+ fprintf(stderr, "Exhausted memory, quitting\n");
+ abort();
case TEST_MAXIMUM_RETURN:
default:
+ assert(0); // Coding error.
break;
}
break;
}
}
+
+ if (failed)
+ {
+ stats.collection_failed++;
+ }
+
+ if (skipped)
+ {
+ stats.collection_skipped++;
+ }
+
+ if (! failed && ! skipped)
+ {
+ stats.collection_success++;
+ }
+
+ if (world.collection_shutdown)
+ {
+ world.collection_shutdown(world_ptr);
+ }
}
- fprintf(stderr, "All tests completed successfully\n\n");
+ if (stats.collection_failed || stats.collection_skipped)
+ {
+ fprintf(stderr, "Some test failures and/or skipped test occurred.\n\n");
+ }
+ else
+ {
+ fprintf(stderr, "All tests completed successfully\n\n");
+ }
if (world.destroy)
{
test_callback_create_fn create;
test_callback_fn destroy;
- /* This is called a the beginning of any collection run. */
+ /* This is called a the beginning of any test run. */
test_callback_fn test_startup;
+ /* This is called a the beginning of any collection run. */
+ test_callback_fn collection_startup;
+
+ /* This is called a the beginning of any collection run. */
+ test_callback_fn collection_shutdown;
+
/* This called on a test if the test requires a flush call (the bool is from test_st) */
test_callback_fn flush;
@note world_stats_st is a simple structure for tracking test successes.
*/
typedef struct {
+ uint32_t collection_success;
+ uint32_t collection_skipped;
+ uint32_t collection_failed;
+ uint32_t collection_total;
uint32_t success;
uint32_t skipped;
uint32_t failed;