+ 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;
+
+ stats.collection_total++;
+
+ collection_rc= world.collection.startup(world_ptr);
+
+ if (collection_rc != TEST_SUCCESS)
+ goto skip_pre;
+
+ if (next->pre)
+ {
+ collection_rc= world.runner->pre(next->pre, world_ptr);
+ }
+
+skip_pre:
+ 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.collection_failed++;
+ goto cleanup;
+ case TEST_SKIPPED:
+ fprintf(stderr, "\n%s [ skipping ]\n\n", next->name);
+ stats.collection_skipped++;
+ goto cleanup;
+ case TEST_MEMORY_ALLOCATION_FAILURE:
+ case TEST_MAXIMUM_RETURN:
+ default:
+ assert(0);
+ break;
+ }
+
+
+ for (x= 0; run->name; run++)
+ {
+ struct timeval start_time, end_time;
+ long int load_time= 0;
+
+ if (wildcard && fnmatch(wildcard, run->name, 0))
+ continue;
+
+ fprintf(stderr, "Testing %s", run->name);
+
+ if (world.test.startup)
+ {
+ world.test.startup(world_ptr);
+ }
+
+ if (run->requires_flush && world.test.flush)
+ {
+ world.test.flush(world_ptr);
+ }
+
+ if (world.test.pre_run)
+ {
+ world.test.pre_run(world_ptr);
+ }
+
+
+ // Runner code
+ {
+#if 0
+ if (next->pre && world.runner->pre)
+ {
+ return_code= world.runner->pre(next->pre, world_ptr);
+
+ if (return_code != TEST_SUCCESS)
+ {
+ goto error;
+ }
+ }
+#endif
+
+ gettimeofday(&start_time, NULL);
+ return_code= world.runner->run(run->test_fn, world_ptr);
+ gettimeofday(&end_time, NULL);
+ load_time= timedif(end_time, start_time);
+
+#if 0
+ if (next->post && world.runner->post)
+ {
+ (void) world.runner->post(next->post, world_ptr);
+ }
+#endif
+ }
+
+ if (world.test.post_run)
+ {
+ world.test.post_run(world_ptr);
+ }
+
+ stats.total++;
+
+ fprintf(stderr, "\t\t\t\t\t");
+
+ switch (return_code)
+ {
+ case TEST_SUCCESS:
+ fprintf(stderr, "%ld.%03ld ", load_time / 1000, load_time % 1000);
+ stats.success++;
+ 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;
+ }
+
+ fprintf(stderr, "[ %s ]\n", test_strerror(return_code));
+
+ if (world.test.on_error)
+ {
+ test_return_t rc;
+ rc= world.test.on_error(return_code, world_ptr);
+
+ if (rc != TEST_SUCCESS)
+ break;
+ }
+ }
+
+ if (next->post && world.runner->post)
+ {
+ (void) world.runner->post(next->post, world_ptr);
+ }
+
+ if (! failed && ! skipped)
+ {
+ stats.collection_success++;
+ }
+cleanup:
+
+ world.collection.shutdown(world_ptr);