[PATCH i-g-t 3/3] stats: Exercise the reallocation paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Damien Lespiau <damien.lespiau@xxxxxxxxx>
---
 lib/tests/igt_stats.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lib/tests/igt_stats.c b/lib/tests/igt_stats.c
index 6e4b233..12778e2 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();
 }
-- 
2.1.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux