diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2013-09-11 22:17:33 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2013-09-19 21:37:56 -0400 |
commit | aa5c45254eb60ce4c85a25b5343474fb160ffa7c (patch) | |
tree | 767ba6a62d2353e78de779cf6c0e2164678af0c2 | |
parent | 4312f077365bf9f59423b1694136089c6da6216b (diff) |
test: Test negative strides
Pixman supports negative strides, but up until now they haven't been
tested outside of stress-test. This commit adds testing of negative
strides to blitters-test, scaling-test, affine-test, rotate-test, and
composite-traps-test.
-rw-r--r-- | test/affine-test.c | 22 | ||||
-rw-r--r-- | test/blitters-test.c | 12 | ||||
-rw-r--r-- | test/composite-traps-test.c | 23 | ||||
-rw-r--r-- | test/rotate-test.c | 17 | ||||
-rw-r--r-- | test/scaling-test.c | 31 | ||||
-rw-r--r-- | test/utils.c | 6 |
6 files changed, 98 insertions, 13 deletions
diff --git a/test/affine-test.c b/test/affine-test.c index 03d296f..8e19023 100644 --- a/test/affine-test.c +++ b/test/affine-test.c @@ -80,6 +80,18 @@ test_composite (int testnum, prng_randmemset (srcbuf, src_stride * src_height, 0); prng_randmemset (dstbuf, dst_stride * dst_height, 0); + if (prng_rand_n (2) == 0) + { + srcbuf += (src_stride / 4) * (src_height - 1); + src_stride = - src_stride; + } + + if (prng_rand_n (2) == 0) + { + dstbuf += (dst_stride / 4) * (dst_height - 1); + dst_stride = - dst_stride; + } + src_fmt = src_bpp == 4 ? (prng_rand_n (2) == 0 ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8) : PIXMAN_r5g6b5; @@ -281,6 +293,12 @@ test_composite (int testnum, pixman_image_unref (src_img); pixman_image_unref (dst_img); + if (src_stride < 0) + srcbuf += (src_stride / 4) * (src_height - 1); + + if (dst_stride < 0) + dstbuf += (dst_stride / 4) * (dst_height - 1); + free (srcbuf); free (dstbuf); @@ -289,9 +307,9 @@ test_composite (int testnum, } #if BILINEAR_INTERPOLATION_BITS == 7 -#define CHECKSUM 0xBC00B1DF +#define CHECKSUM 0xBE724CFE #elif BILINEAR_INTERPOLATION_BITS == 4 -#define CHECKSUM 0xA227306B +#define CHECKSUM 0x79BBE501 #else #define CHECKSUM 0x00000000 #endif diff --git a/test/blitters-test.c b/test/blitters-test.c index 2120daf..af94835 100644 --- a/test/blitters-test.c +++ b/test/blitters-test.c @@ -57,6 +57,13 @@ create_random_image (pixman_format_code_t *allowed_formats, prng_randmemset (buf, stride * height, RANDMEMSET_MORE_00_AND_FF); } + /* test negative stride */ + if (prng_rand_n (4) == 0) + { + buf += (stride / 4) * (height - 1); + stride = - stride; + } + img = pixman_image_create_bits (fmt, width, height, buf, stride); if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_COLOR) @@ -89,6 +96,9 @@ free_random_image (uint32_t initcrc, if (fmt != PIXMAN_null) crc32 = compute_crc32_for_image (initcrc, img); + if (img->bits.rowstride < 0) + data += img->bits.rowstride * (img->bits.height - 1); + pixman_image_unref (img); free (data); @@ -385,6 +395,6 @@ main (int argc, const char *argv[]) } return fuzzer_test_main("blitters", 2000000, - 0x0CF3283B, + 0xAC8FDA98, test_composite, argc, argv); } diff --git a/test/composite-traps-test.c b/test/composite-traps-test.c index 44d5012..86a0355 100644 --- a/test/composite-traps-test.c +++ b/test/composite-traps-test.c @@ -97,19 +97,25 @@ test_composite (int testnum, int src_width = prng_rand_n (MAX_SRC_WIDTH) + 1; int src_height = prng_rand_n (MAX_SRC_HEIGHT) + 1; int src_stride = src_width * src_bpp + prng_rand_n (MAX_STRIDE) * src_bpp; - uint32_t *bits; + uint32_t *bits, *orig; src_x = -(src_width / 4) + prng_rand_n (src_width * 3 / 2); src_y = -(src_height / 4) + prng_rand_n (src_height * 3 / 2); src_stride = (src_stride + 3) & ~3; - bits = (uint32_t *)make_random_bytes (src_stride * src_height); + orig = bits = (uint32_t *)make_random_bytes (src_stride * src_height); + if (prng_rand_n (2) == 0) + { + bits += (src_stride / 4) * (src_height - 1); + src_stride = - src_stride; + } + src_img = pixman_image_create_bits ( src_format, src_width, src_height, bits, src_stride); - pixman_image_set_destroy_function (src_img, destroy_bits, bits); + pixman_image_set_destroy_function (src_img, destroy_bits, orig); if (prng_rand_n (8) == 0) { @@ -153,6 +159,12 @@ test_composite (int testnum, dst_bits = (uint32_t *)make_random_bytes (dst_stride * dst_height); + if (prng_rand_n (2) == 0) + { + dst_bits += (dst_stride / 4) * (dst_height - 1); + dst_stride = - dst_stride; + } + dst_x = -(dst_width / 4) + prng_rand_n (dst_width * 3 / 2); dst_y = -(dst_height / 4) + prng_rand_n (dst_height * 3 / 2); @@ -219,6 +231,9 @@ test_composite (int testnum, if (verbose) print_image (dst_img); + if (dst_stride < 0) + dst_bits += (dst_stride / 4) * (dst_height - 1); + fence_free (dst_bits); pixman_image_unref (src_img); @@ -232,6 +247,6 @@ test_composite (int testnum, int main (int argc, const char *argv[]) { - return fuzzer_test_main("composite traps", 40000, 0x749BCC57, + return fuzzer_test_main("composite traps", 40000, 0xAF41D210, test_composite, argc, argv); } diff --git a/test/rotate-test.c b/test/rotate-test.c index 9d2a620..18ca60d 100644 --- a/test/rotate-test.c +++ b/test/rotate-test.c @@ -61,16 +61,25 @@ static pixman_image_t * make_image (void) { pixman_format_code_t format = RANDOM_FORMAT(); - uint32_t *bytes = malloc (WIDTH * HEIGHT * 4); + uint32_t *bytes, *orig; pixman_image_t *image; + int stride; + orig = bytes = malloc (WIDTH * HEIGHT * 4); prng_randmemset (bytes, WIDTH * HEIGHT * 4, 0); + stride = WIDTH * 4; + if (prng_rand_n (2) == 0) + { + bytes += (stride / 4) * (HEIGHT - 1); + stride = - stride; + } + image = pixman_image_create_bits ( - format, WIDTH, HEIGHT, bytes, WIDTH * 4); + format, WIDTH, HEIGHT, bytes, stride); pixman_image_set_transform (image, RANDOM_TRANSFORM()); - pixman_image_set_destroy_function (image, on_destroy, bytes); + pixman_image_set_destroy_function (image, on_destroy, orig); pixman_image_set_repeat (image, PIXMAN_REPEAT_NORMAL); image_endian_swap (image); @@ -106,6 +115,6 @@ int main (int argc, const char *argv[]) { return fuzzer_test_main ("rotate", 15000, - 0xECF5E426, + 0x81E9EC2F, test_transform, argc, argv); } diff --git a/test/scaling-test.c b/test/scaling-test.c index 0778d2d..e2f7fa9 100644 --- a/test/scaling-test.c +++ b/test/scaling-test.c @@ -147,6 +147,24 @@ test_composite (int testnum, src_fmt = get_format (src_bpp); dst_fmt = get_format (dst_bpp); + if (prng_rand_n (2)) + { + srcbuf += (src_stride / 4) * (src_height - 1); + src_stride = - src_stride; + } + + if (prng_rand_n (2)) + { + maskbuf += (mask_stride / 4) * (mask_height - 1); + mask_stride = - mask_stride; + } + + if (prng_rand_n (2)) + { + dstbuf += (dst_stride / 4) * (dst_height - 1); + dst_stride = - dst_stride; + } + src_img = pixman_image_create_bits ( src_fmt, src_width, src_height, srcbuf, src_stride); @@ -349,6 +367,15 @@ test_composite (int testnum, pixman_image_unref (mask_img); pixman_image_unref (dst_img); + if (src_stride < 0) + srcbuf += (src_stride / 4) * (src_height - 1); + + if (mask_stride < 0) + maskbuf += (mask_stride / 4) * (mask_height - 1); + + if (dst_stride < 0) + dstbuf += (dst_stride / 4) * (dst_height - 1); + free (srcbuf); free (maskbuf); free (dstbuf); @@ -358,9 +385,9 @@ test_composite (int testnum, } #if BILINEAR_INTERPOLATION_BITS == 7 -#define CHECKSUM 0xCE8EC6BA +#define CHECKSUM 0x92E0F068 #elif BILINEAR_INTERPOLATION_BITS == 4 -#define CHECKSUM 0xAB1D39BE +#define CHECKSUM 0x8EFFA1E5 #else #define CHECKSUM 0x00000000 #endif diff --git a/test/utils.c b/test/utils.c index a693f30..3400747 100644 --- a/test/utils.c +++ b/test/utils.c @@ -150,6 +150,12 @@ compute_crc32_for_image_internal (uint32_t crc32, uint32_t mask = 0xffffffff; int i; + if (stride < 0) + { + data += (stride / 4) * (height - 1); + stride = - stride; + } + /* mask unused 'x' part */ if (PIXMAN_FORMAT_BPP (fmt) - PIXMAN_FORMAT_DEPTH (fmt) && PIXMAN_FORMAT_DEPTH (fmt) != 0) |