tests/etnaviv_2d_test: check whether the rendering is correct

Instead of always dumping the rendered picture, check whether it matches
the expectations. This makes more sense for automated testing.

Retain the ability to dump the picture instead of checking it when a
file name is given as an argument. This also removes use of a hardcoded
file name in a world writable directory, which is an unsafe thing to
do anyway.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
main
Lubomir Rintel 2020-12-01 21:38:29 +01:00 committed by Christian Gmeiner
parent 9638207005
commit 9a7afcf198
1 changed files with 27 additions and 2 deletions

View File

@ -147,6 +147,27 @@ static void gen_cmd_stream(struct etna_cmd_stream *stream, struct etna_bo *bmp,
etna_set_state(stream, VIVS_GL_FLUSH_CACHE, VIVS_GL_FLUSH_CACHE_PE2D);
}
int etna_check_image(uint32_t *p, int width, int height)
{
int i;
uint32_t expected;
for (i = 0; i < width * height; i++) {
if (i%8 < 4 && i%(width*8) < width*4 && i%width < 8*16 && i < width*8*16)
expected = 0xff40ff40;
else
expected = 0x00000000;
if (p[i] != expected) {
fprintf(stderr, "Offset %d: expected: 0x%08x, got: 0x%08x\n",
i, expected, p[i]);
return -1;
}
}
return 0;
}
int main(int argc, char *argv[])
{
const int width = 256;
@ -165,7 +186,7 @@ int main(int argc, char *argv[])
int core = 0;
if (argc < 2) {
fprintf(stderr, "Usage: %s /dev/dri/<device>\n", argv[0]);
fprintf(stderr, "Usage: %s /dev/dri/<device> [<etna.bmp>]\n", argv[0]);
return 1;
}
@ -242,7 +263,11 @@ int main(int argc, char *argv[])
etna_cmd_stream_finish(stream);
bmp_dump32(etna_bo_map(bmp), width, height, false, "/tmp/etna.bmp");
if (argc > 2)
bmp_dump32(etna_bo_map(bmp), width, height, false, argv[2]);
if (etna_check_image(etna_bo_map(bmp), width, height))
ret = 7;
etna_cmd_stream_del(stream);