diff options
author | marha <marha@users.sourceforge.net> | 2010-08-18 09:35:37 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-08-18 09:35:37 +0000 |
commit | 2aa7bcf37f00b7884ae166d62db81493ea37934a (patch) | |
tree | e7ad3e04c09c56538993c8a42a53adce5743d9a7 /pixman/test | |
parent | 2744e12e38280c4877311f129d5a5db509b75026 (diff) | |
download | vcxsrv-2aa7bcf37f00b7884ae166d62db81493ea37934a.tar.gz vcxsrv-2aa7bcf37f00b7884ae166d62db81493ea37934a.tar.bz2 vcxsrv-2aa7bcf37f00b7884ae166d62db81493ea37934a.zip |
libxext libx11 libxcb libXinerama libXau pixman xserver git update 18/10/2010
Diffstat (limited to 'pixman/test')
-rw-r--r-- | pixman/test/Makefile.am | 4 | ||||
-rw-r--r-- | pixman/test/alpha-loop.c | 29 | ||||
-rw-r--r-- | pixman/test/utils.c | 33 | ||||
-rw-r--r-- | pixman/test/utils.h | 3 |
4 files changed, 69 insertions, 0 deletions
diff --git a/pixman/test/Makefile.am b/pixman/test/Makefile.am index efd9cd91a..d3e9d3fa0 100644 --- a/pixman/test/Makefile.am +++ b/pixman/test/Makefile.am @@ -13,6 +13,7 @@ TESTPROGRAMS = \ gradient-crash-test \
trap-crasher \
alphamap \
+ alpha-loop \
scaling-crash-test \
blitters-test \
scaling-test \
@@ -39,6 +40,9 @@ scaling_test_SOURCES = scaling-test.c utils.c utils.h alphamap_LDADD = $(TEST_LDADD)
alphamap_SOURCES = alphamap.c utils.c utils.h
+alpha_loop_LDADD = $(TEST_LDADD)
+alpha_loop_SOURCES = alpha-loop.c utils.c utils.h
+
# GTK using test programs
if HAVE_GTK
diff --git a/pixman/test/alpha-loop.c b/pixman/test/alpha-loop.c new file mode 100644 index 000000000..38fc21f5d --- /dev/null +++ b/pixman/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;
+}
diff --git a/pixman/test/utils.c b/pixman/test/utils.c index 4b68debff..f5199268b 100644 --- a/pixman/test/utils.c +++ b/pixman/test/utils.c @@ -1,4 +1,9 @@ #include "utils.h"
+#include <signal.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
/* Random number seed
*/
@@ -319,3 +324,31 @@ fuzzer_test_main (const char *test_name, return 0;
}
+
+static const char *global_msg;
+
+static void
+on_alarm (int signo)
+{
+ printf ("%s\n", global_msg);
+ exit (1);
+}
+
+void
+fail_after (int seconds, const char *msg)
+{
+#ifdef HAVE_SIGACTION
+#ifdef HAVE_ALARM
+ struct sigaction action;
+
+ global_msg = msg;
+
+ memset (&action, 0, sizeof (action));
+ action.sa_handler = on_alarm;
+
+ alarm (seconds);
+
+ sigaction (SIGALRM, &action, NULL);
+#endif
+#endif
+}
diff --git a/pixman/test/utils.h b/pixman/test/utils.h index 39b49b2c1..a5b3c91c4 100644 --- a/pixman/test/utils.h +++ b/pixman/test/utils.h @@ -62,3 +62,6 @@ fuzzer_test_main (const char *test_name, uint32_t (*test_function)(int testnum, int verbose),
int argc,
const char *argv[]);
+
+void
+fail_after (int seconds, const char *msg);
|