From e588f6dfa6f022120d5a55ef96994dbbc33d0dc9 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Fri, 27 Feb 2015 20:37:29 +0100 Subject: lib/debugfs: Add igt_assert_crc_equal Because of hash collisions tests should only ever compare crc checksums for equality. Checking for inequality can result in random failures. To ensure this only expose and igt_assert function and use that. Follow-up patches will rework the code for tests which don't follow this requirement and try to compare for CRC inequality. v2: Rebase on top of Matt's kms_plane changes. Signed-off-by: Daniel Vetter --- lib/igt_debugfs.c | 21 ++++++++++++++++++++- lib/igt_debugfs.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index a2cec45a..dddd6c35 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -63,7 +63,7 @@ * another either for equality or difference. Otherwise CRCs must be treated as * completely opaque values. Note that not even CRCs from different pipes or tap * points on the same platform can be compared. Hence only use igt_crc_is_null() - * and igt_crc_equal() to inspect CRC values captured by the same + * and igt_assert_crc_equal() to inspect CRC values captured by the same * #igt_pipe_crc_t object. * * # Other debugfs interface wrappers @@ -234,6 +234,25 @@ bool igt_crc_equal(igt_crc_t *a, igt_crc_t *b) return true; } +/** + * igt_assert_crc_equal: + * @a: first pipe CRC value + * @b: second pipe CRC value + * + * Compares two CRC values and fails the testcase if they don't match with + * igt_fail(). Note that due to CRC collisions CRC based testcase can only + * assert that CRCs match, never that they are different. Otherwise there might + * be random testcase failures when different screen contents end up with the + * same CRC by chance. + */ +void igt_assert_crc_equal(igt_crc_t *a, igt_crc_t *b) +{ + int i; + + for (i = 0; i < a->n_words; i++) + igt_assert_eq_u32(a->crc[i], b->crc[i]); +} + /** * igt_crc_to_string: * @crc: pipe CRC value to print diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h index 82850295..f158c338 100644 --- a/lib/igt_debugfs.h +++ b/lib/igt_debugfs.h @@ -87,6 +87,7 @@ enum intel_pipe_crc_source { bool igt_crc_is_null(igt_crc_t *crc); bool igt_crc_equal(igt_crc_t *a, igt_crc_t *b); +void igt_assert_crc_equal(igt_crc_t *a, igt_crc_t *b); char *igt_crc_to_string(igt_crc_t *crc); void igt_require_pipe_crc(void); -- cgit v1.2.3