#endif /* CLOCK_THREAD_CPUTIME_ID */
+/**
+ * Determine the configured iterations to run
+ */
+static hashtable_t *get_iterations()
+{
+ enumerator_t *enumerator;
+ hashtable_t *config = NULL;
+ char *iterations, *iter;
+
+ iterations = getenv("TESTS_ITERATIONS");
+ if (!iterations)
+ {
+ return NULL;
+ }
+
+ config = hashtable_create(hashtable_hash_ptr, hashtable_equals_ptr, 8);
+ enumerator = enumerator_create_token(iterations, ",", " ");
+ while (enumerator->enumerate(enumerator, &iter))
+ {
+ /* add 1 so we can store 0 */
+ config->put(config, (void*)(uintptr_t)atoi(iter)+1, config);
+ }
+ enumerator->destroy(enumerator);
+ if (!config->get_count(config))
+ {
+ config->destroy(config);
+ config = NULL;
+ }
+ return config;
+}
+
/**
* Run a single test case with fixtures
*/
{
enumerator_t *enumerator;
test_function_t *tfun;
+ hashtable_t *iterations;
double *times;
double total_time = 0;
int tests = 0, ti = 0, passed = 0;
fprintf(stderr, " Running case '%s': ", tcase->name);
fflush(stderr);
+ iterations = get_iterations();
+
enumerator = array_create_enumerator(tcase->functions);
while (enumerator->enumerate(enumerator, &tfun))
{
- int i, rounds = 0;
+ int i, rounds = 0, skipped = 0;
for (i = tfun->start; i < tfun->end; i++)
{
+ if (iterations && !iterations->get(iterations, (void*)(uintptr_t)i+1))
+ {
+ skipped++;
+ continue;
+ }
if (pre_test(init, cfg))
{
struct timespec start;
}
}
fflush(stderr);
- if (rounds == tfun->end - tfun->start)
+ if (rounds == tfun->end - tfun->start - skipped)
{
passed++;
}
print_failures(failures, FALSE);
array_destroy(failures);
array_destroy(warnings);
+ DESTROY_IF(iterations);
return passed == array_count(tcase->functions);
}