diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-08-04 17:55:14 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-08-15 21:57:18 -0400 |
commit | 9fe7d32c4b704a10e780444530eaea28b4351110 (patch) | |
tree | 95b1d05be7e776039606f18fb95ff9b6658d3ce9 /test/alpha-loop.c | |
parent | 8a5d1be1dab799ed23239f3471b4a351d8356368 (diff) |
Add alpha-loop test program
This tests what happens if you attempt to make an image with an alpha
map that has the image as its alpha map. This results in an infinite
loop in _pixman_image_validate(), so the test sets up a SIGALRM to
exit if it runs for more than five seconds.
Diffstat (limited to 'test/alpha-loop.c')
-rw-r--r-- | test/alpha-loop.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/alpha-loop.c b/test/alpha-loop.c new file mode 100644 index 0000000..e4d90a9 --- /dev/null +++ b/test/alpha-loop.c @@ -0,0 +1,29 @@ +#include <stdio.h> +#include <stdlib.h> +#include "utils.h" + +#define WIDTH 400 +#define HEIGHT 200 + +int +main (int argc, char **argv) +{ + uint8_t *alpha = make_random_bytes (WIDTH * HEIGHT); + uint32_t *src = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * 4); + uint32_t *dest = (uint32_t *)make_random_bytes (WIDTH * HEIGHT * 4); + + pixman_image_t *a = pixman_image_create_bits (PIXMAN_a8, WIDTH, HEIGHT, (uint32_t *)alpha, WIDTH); + pixman_image_t *d = pixman_image_create_bits (PIXMAN_a8r8g8b8, WIDTH, HEIGHT, dest, WIDTH * 4); + pixman_image_t *s = pixman_image_create_bits (PIXMAN_a2r10g10b10, WIDTH, HEIGHT, src, WIDTH * 4); + + fail_after (5, "Infinite loop detected: 5 seconds without progress\n"); + + pixman_image_set_alpha_map (s, a, 0, 0); + pixman_image_set_alpha_map (a, s, 0, 0); + + pixman_image_composite (PIXMAN_OP_SRC, s, NULL, d, 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT); + + pixman_image_unref (s); + + return 0; +} |