summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2015-06-27 18:03:15 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2015-06-27 19:05:41 +0100
commit46f277b90b998560eb0cf895f71ca667d2ef8a39 (patch)
tree3c2e90c550666918a17ac1db7390a49ee277b220 /lib
parent66e0bf66da4b06d9495025b053d4d7fe73c86fc7 (diff)
stats: Exercise the reallocation paths
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/tests/igt_stats.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/tests/igt_stats.c b/lib/tests/igt_stats.c
index 6e4b233e..12778e2f 100644
--- a/lib/tests/igt_stats.c
+++ b/lib/tests/igt_stats.c
@@ -204,6 +204,29 @@ static void test_std_deviation(void)
igt_stats_fini(&stats);
}
+static void test_reallocation(void)
+{
+ igt_stats_t stats;
+ unsigned int i;
+
+ igt_stats_init_with_size(&stats, 1);
+
+ for (i = 0; i < 101; i++) {
+ igt_stats_push(&stats, i);
+ /* also triggers ->sorted reallocations */
+ if (i > 10)
+ igt_stats_get_median(&stats);
+ }
+
+ igt_assert_eq(stats.n_values, 101);
+ for (i = 0; i < 101; i++)
+ igt_assert_eq(stats.values[i], i);
+ igt_assert_eq_double(igt_stats_get_mean(&stats), 50.0);
+ igt_assert_eq_double(igt_stats_get_median(&stats), 50.0);
+
+ igt_stats_fini(&stats);
+}
+
igt_simple_main
{
test_init_zero();
@@ -215,4 +238,5 @@ igt_simple_main
test_mean();
test_invalidate_mean();
test_std_deviation();
+ test_reallocation();
}