mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 09:26:10 +00:00
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 <daniel.vetter@intel.com>
This commit is contained in:
parent
4fec18e5e0
commit
e588f6dfa6
@ -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
|
||||
|
@ -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);
|
||||
|
@ -134,7 +134,7 @@ static void do_single_test(data_t *data, int x, int y)
|
||||
igt_wait_for_vblank(data->drm_fd, data->pipe);
|
||||
igt_pipe_crc_collect_crc(pipe_crc, &ref_crc);
|
||||
/* Clear screen afterwards */
|
||||
igt_assert(igt_crc_equal(&crc, &ref_crc));
|
||||
igt_assert_crc_equal(&crc, &ref_crc);
|
||||
|
||||
igt_paint_color(cr, 0, 0, data->screenw, data->screenh,
|
||||
0.0, 0.0, 0.0);
|
||||
@ -453,7 +453,7 @@ static void test_cursor_size(data_t *data)
|
||||
/* Clear screen afterwards */
|
||||
igt_paint_color(cr, 0, 0, data->screenw, data->screenh,
|
||||
0.0, 0.0, 0.0);
|
||||
igt_assert(igt_crc_equal(&crc[i], &ref_crc));
|
||||
igt_assert_crc_equal(&crc[i], &ref_crc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ static void test_crc(data_t *data, enum test_mode mode)
|
||||
igt_pipe_crc_stop(pipe_crc);
|
||||
igt_assert(!igt_crc_equal(&crcs[0], &data->ref_crc[0]));
|
||||
if (mode == TEST_PAGE_FLIP)
|
||||
igt_assert(igt_crc_equal(&crcs[0], &data->ref_crc[1]));
|
||||
igt_assert_crc_equal(&crcs[0], &data->ref_crc[1]);
|
||||
else
|
||||
igt_assert(!igt_crc_equal(&crcs[0], &data->ref_crc[1]));
|
||||
free(crcs);
|
||||
@ -287,7 +287,7 @@ static void test_crc(data_t *data, enum test_mode mode)
|
||||
igt_pipe_crc_stop(pipe_crc);
|
||||
igt_assert(!igt_crc_equal(&crcs[0], &data->ref_crc[0]));
|
||||
if (mode == TEST_PAGE_FLIP)
|
||||
igt_assert(igt_crc_equal(&crcs[0], &data->ref_crc[1]));
|
||||
igt_assert_crc_equal(&crcs[0], &data->ref_crc[1]);
|
||||
else
|
||||
igt_assert(!igt_crc_equal(&crcs[0], &data->ref_crc[1]));
|
||||
free(crcs);
|
||||
|
@ -113,7 +113,7 @@ test_flip_changes_tiling(data_t *data, igt_output_t *output, uint64_t tiling)
|
||||
|
||||
/* get a crc and compare with the reference */
|
||||
igt_pipe_crc_collect_crc(pipe_crc, &crc);
|
||||
igt_assert(igt_crc_equal(&reference_crc, &crc));
|
||||
igt_assert_crc_equal(&reference_crc, &crc);
|
||||
|
||||
/* clean up */
|
||||
igt_plane_set_fb(primary, NULL);
|
||||
|
@ -319,7 +319,7 @@ test_plane(data_t *data, igt_output_t *output, enum pipe pipe, enum igt_plane pl
|
||||
igt_output_set_pipe(output, PIPE_ANY);
|
||||
igt_display_commit(&data->display);
|
||||
|
||||
igt_assert(igt_crc_equal(&ref_crc, &crc));
|
||||
igt_assert_crc_equal(&ref_crc, &crc);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -468,7 +468,7 @@ test_crtc(data_t *data, igt_output_t *output, enum pipe pipe)
|
||||
igt_output_set_pipe(output, PIPE_ANY);
|
||||
igt_display_commit(&data->display);
|
||||
|
||||
igt_assert(igt_crc_equal(&ref_crc, &crc));
|
||||
igt_assert_crc_equal(&ref_crc, &crc);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ test_read_crc_for_output(data_t *data, int pipe, igt_output_t *output,
|
||||
|
||||
/* and ensure that they'are all equal, we haven't changed the fb */
|
||||
for (j = 0; j < (N_CRCS - 1); j++)
|
||||
igt_assert(igt_crc_equal(&crcs[j], &crcs[j + 1]));
|
||||
igt_assert_crc_equal(&crcs[j], &crcs[j + 1]);
|
||||
|
||||
if (flags & TEST_SEQUENCE)
|
||||
for (j = 0; j < (N_CRCS - 1); j++)
|
||||
|
@ -207,11 +207,11 @@ test_plane_position_with_output(data_t *data,
|
||||
igt_pipe_crc_collect_crc(data->pipe_crc, &crc2);
|
||||
|
||||
if (flags & TEST_POSITION_FULLY_COVERED)
|
||||
igt_assert(igt_crc_equal(&test.reference_crc, &crc));
|
||||
igt_assert_crc_equal(&test.reference_crc, &crc);
|
||||
else
|
||||
igt_assert(!igt_crc_equal(&test.reference_crc, &crc));
|
||||
|
||||
igt_assert(igt_crc_equal(&crc, &crc2));
|
||||
igt_assert_crc_equal(&crc, &crc2);
|
||||
|
||||
igt_plane_set_fb(primary, NULL);
|
||||
igt_plane_set_fb(sprite, NULL);
|
||||
@ -333,9 +333,9 @@ test_plane_panning_with_output(data_t *data,
|
||||
igt_debug_wait_for_keypress("crc");
|
||||
|
||||
if (flags & TEST_PANNING_TOP_LEFT)
|
||||
igt_assert(igt_crc_equal(&test.red_crc, &crc));
|
||||
igt_assert_crc_equal(&test.red_crc, &crc);
|
||||
else
|
||||
igt_assert(igt_crc_equal(&test.blue_crc, &crc));
|
||||
igt_assert_crc_equal(&test.blue_crc, &crc);
|
||||
|
||||
igt_plane_set_fb(primary, NULL);
|
||||
|
||||
|
@ -100,7 +100,7 @@ static void test(data_t *data)
|
||||
|
||||
/* check that the crc is as expected, which requires that caches got flushed */
|
||||
igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
|
||||
igt_assert(igt_crc_equal(&crc, &data->ref_crc));
|
||||
igt_assert_crc_equal(&crc, &data->ref_crc);
|
||||
}
|
||||
|
||||
static bool prepare_crtc(data_t *data)
|
||||
|
@ -204,7 +204,7 @@ static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
|
||||
igt_display_commit2(display, commit);
|
||||
|
||||
igt_pipe_crc_collect_crc(data->pipe_crc, &crc_output);
|
||||
igt_assert(igt_crc_equal(&data->ref_crc, &crc_output));
|
||||
igt_assert_crc_equal(&data->ref_crc, &crc_output);
|
||||
|
||||
/* check the rotation state has been reset when the VT
|
||||
* mode is restored */
|
||||
@ -212,7 +212,7 @@ static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
|
||||
kmstest_set_vt_graphics_mode();
|
||||
prepare_crtc(data, output, pipe, plane);
|
||||
igt_pipe_crc_collect_crc(data->pipe_crc, &crc_output);
|
||||
igt_assert(igt_crc_equal(&crc_unrotated, &crc_output));
|
||||
igt_assert_crc_equal(&crc_unrotated, &crc_output);
|
||||
|
||||
|
||||
valid_tests++;
|
||||
|
@ -261,37 +261,37 @@ functional_test_pipe(data_t *data, enum pipe pipe, igt_output_t *output)
|
||||
igt_display_commit2(display, COMMIT_LEGACY);
|
||||
|
||||
/* Blue bg + red sprite should be same under both types of API's */
|
||||
igt_assert(igt_crc_equal(&test.crc_2, &test.crc_4));
|
||||
igt_assert_crc_equal(&test.crc_2, &test.crc_4);
|
||||
|
||||
/* Disabling primary plane should be same as black primary */
|
||||
igt_assert(igt_crc_equal(&test.crc_1, &test.crc_5));
|
||||
igt_assert_crc_equal(&test.crc_1, &test.crc_5);
|
||||
|
||||
/* Re-enabling primary should return to blue properly */
|
||||
igt_assert(igt_crc_equal(&test.crc_2, &test.crc_6));
|
||||
igt_assert_crc_equal(&test.crc_2, &test.crc_6);
|
||||
|
||||
/*
|
||||
* We should be able to setup plane FB's while CRTC is disabled and
|
||||
* then have them pop up correctly when the CRTC is re-enabled.
|
||||
*/
|
||||
igt_assert(igt_crc_equal(&test.crc_2, &test.crc_7));
|
||||
igt_assert_crc_equal(&test.crc_2, &test.crc_7);
|
||||
|
||||
/*
|
||||
* We should be able to modeset with the primary plane off
|
||||
* successfully
|
||||
*/
|
||||
igt_assert(igt_crc_equal(&test.crc_3, &test.crc_8));
|
||||
igt_assert_crc_equal(&test.crc_3, &test.crc_8);
|
||||
|
||||
/*
|
||||
* We should be able to move the primary plane completely offscreen
|
||||
* and have it disable successfully.
|
||||
*/
|
||||
igt_assert(igt_crc_equal(&test.crc_5, &test.crc_9));
|
||||
igt_assert_crc_equal(&test.crc_5, &test.crc_9);
|
||||
|
||||
/*
|
||||
* We should be able to explicitly disable an already
|
||||
* implicitly-disabled primary plane
|
||||
*/
|
||||
igt_assert(igt_crc_equal(&test.crc_5, &test.crc_10));
|
||||
igt_assert_crc_equal(&test.crc_5, &test.crc_10);
|
||||
|
||||
igt_plane_set_fb(primary, NULL);
|
||||
igt_plane_set_fb(sprite, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user