From 2a9f88430e7088eccfbbbd6c6b4f4e534126b1e1 Mon Sep 17 00:00:00 2001 From: Siarhei Siamashka Date: Sun, 22 May 2011 22:16:38 +0300 Subject: [PATCH] test: better coverage for BILINEAR->NEAREST filter optimization The upcoming optimization which is going to be able to replace BILINEAR filter with NEAREST where appropriate needs to analyze the transformation matrix and not to make any mistakes. The changes to affine-test include: 1. Higher chance of using the same scale factor for x and y axes. This can help to stress some special cases (for example the case when both x and y scale factors are integer). The same applies to x/y translation. 2. Introduced a small chance for "corrupting" transformation matrix by flipping random bits. This supposedly can help to identify the cases when some of the fast paths or other code logic is wrongly activated due to insufficient checks. --- test/affine-test.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/test/affine-test.c b/test/affine-test.c index ed8000c..a4ceed3 100644 --- a/test/affine-test.c +++ b/test/affine-test.c @@ -99,14 +99,23 @@ test_composite (int testnum, image_endian_swap (dst_img); pixman_transform_init_identity (&transform); - - if (lcg_rand_n (8) > 0) + + if (lcg_rand_n (3) > 0) { - scale_x = -32768 * 3 + lcg_rand_N (65536 * 5); - scale_y = -32768 * 3 + lcg_rand_N (65536 * 5); - translate_x = lcg_rand_N (65536); - translate_y = lcg_rand_N (65536); + scale_x = -65536 * 3 + lcg_rand_N (65536 * 6); + if (lcg_rand_n (2)) + scale_y = -65536 * 3 + lcg_rand_N (65536 * 6); + else + scale_y = scale_x; pixman_transform_init_scale (&transform, scale_x, scale_y); + } + if (lcg_rand_n (3) > 0) + { + translate_x = -65536 * 3 + lcg_rand_N (6 * 65536); + if (lcg_rand_n (2)) + translate_y = -65536 * 3 + lcg_rand_N (6 * 65536); + else + translate_y = translate_x; pixman_transform_translate (&transform, NULL, translate_x, translate_y); } @@ -144,8 +153,23 @@ test_composite (int testnum, pixman_transform_translate (&transform, NULL, tx, ty); } + if (lcg_rand_n (8) == 0) + { + /* Flip random bits */ + int maxflipcount = 8; + while (maxflipcount--) + { + int i = lcg_rand_n (2); + int j = lcg_rand_n (3); + int bitnum = lcg_rand_n (32); + transform.matrix[i][j] ^= 1 << bitnum; + if (lcg_rand_n (2)) + break; + } + } + pixman_image_set_transform (src_img, &transform); - + switch (lcg_rand_n (4)) { case 0: @@ -282,6 +306,6 @@ main (int argc, const char *argv[]) { pixman_disable_out_of_bounds_workaround (); - return fuzzer_test_main ("affine", 8000000, 0x4B5D1852, + return fuzzer_test_main ("affine", 8000000, 0x1EF2175A, test_composite, argc, argv); } -- 2.7.4