aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/xorg-lib/pixman-0.21.6/0026-test-Randomize-some-tests-if-PIXMAN_RANDOMIZE_TESTS-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/xorg-lib/pixman-0.21.6/0026-test-Randomize-some-tests-if-PIXMAN_RANDOMIZE_TESTS-.patch')
-rw-r--r--recipes/xorg-lib/pixman-0.21.6/0026-test-Randomize-some-tests-if-PIXMAN_RANDOMIZE_TESTS-.patch187
1 files changed, 187 insertions, 0 deletions
diff --git a/recipes/xorg-lib/pixman-0.21.6/0026-test-Randomize-some-tests-if-PIXMAN_RANDOMIZE_TESTS-.patch b/recipes/xorg-lib/pixman-0.21.6/0026-test-Randomize-some-tests-if-PIXMAN_RANDOMIZE_TESTS-.patch
new file mode 100644
index 0000000000..8fc5b7706f
--- /dev/null
+++ b/recipes/xorg-lib/pixman-0.21.6/0026-test-Randomize-some-tests-if-PIXMAN_RANDOMIZE_TESTS-.patch
@@ -0,0 +1,187 @@
+From 7eb0abb5e819046537b9f809c7ec332c6679c557 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <ssp@redhat.com>
+Date: Mon, 14 Mar 2011 14:56:22 -0400
+Subject: [PATCH 26/40] test: Randomize some tests if PIXMAN_RANDOMIZE_TESTS is set
+
+This patch makes so that composite and stress-test will start from a
+random seed if the PIXMAN_RANDOMIZE_TESTS environment variable is
+set. Running the test suite in this mode is useful to get more test
+coverage.
+
+Also, in stress-test.c make it so that setting the initial seed causes
+threads to be turned off. This makes it much easier to see when
+something fails.
+---
+ test/composite.c | 17 ++++++++++++-----
+ test/stress-test.c | 37 ++++++++++++++++++++++++++-----------
+ test/utils.c | 10 ++++++++++
+ test/utils.h | 3 +++
+ 4 files changed, 51 insertions(+), 16 deletions(-)
+
+diff --git a/test/composite.c b/test/composite.c
+index a86e5ed..e6d52b9 100644
+--- a/test/composite.c
++++ b/test/composite.c
+@@ -868,7 +868,7 @@ main (int argc, char **argv)
+ {
+ #define N_TESTS (8 * 1024 * 1024)
+ int result = 0;
+- int i;
++ uint32_t i;
+
+ if (argc > 1)
+ {
+@@ -890,15 +890,22 @@ main (int argc, char **argv)
+ }
+ }
+
++ uint32_t seed;
++
++ if (getenv ("PIXMAN_RANDOMIZE_TESTS"))
++ seed = get_random_seed();
++ else
++ seed = 1;
++
+ #ifdef USE_OPENMP
+-# pragma omp parallel for default(none) shared(result) shared(argv)
++# pragma omp parallel for default(none) shared(result, argv, seed)
+ #endif
+- for (i = 1; i <= N_TESTS; ++i)
++ for (i = seed; i <= N_TESTS; ++i)
+ {
+ if (!result && !run_test (i))
+ {
+- printf ("Test %d failed.\n", i);
+-
++ printf ("Test 0x%08X failed.\n", i);
++
+ result = i;
+ }
+ }
+diff --git a/test/stress-test.c b/test/stress-test.c
+index 166dc6d..d496f93 100644
+--- a/test/stress-test.c
++++ b/test/stress-test.c
+@@ -1,4 +1,6 @@
++#include <stdio.h>
+ #include "utils.h"
++#include <sys/types.h>
+
+ #if 0
+ #define fence_malloc malloc
+@@ -730,11 +732,17 @@ static const pixman_op_t op_list[] =
+ };
+
+ static void
+-run_test (uint32_t seed)
++run_test (uint32_t seed, pixman_bool_t verbose, uint32_t mod)
+ {
+ pixman_image_t *source, *mask, *dest;
+ pixman_op_t op;
+
++ if (verbose)
++ {
++ if (mod == 0 || (seed % mod) == 0)
++ printf ("Seed 0x%08x\n", seed);
++ }
++
+ lcg_srand (seed);
+
+ source = create_random_image ();
+@@ -787,6 +795,7 @@ main (int argc, char **argv)
+ uint32_t seed = 1;
+ uint32_t n_tests = 0xffffffff;
+ uint32_t mod = 0;
++ pixman_bool_t use_threads = TRUE;
+ uint32_t i;
+
+ pixman_disable_out_of_bounds_workaround ();
+@@ -811,6 +820,7 @@ main (int argc, char **argv)
+ else if (strcmp (argv[i], "-s") == 0 && i + 1 < argc)
+ {
+ get_int (argv[i + 1], &seed);
++ use_threads = FALSE;
+ i++;
+ }
+ else if (strcmp (argv[i], "-n") == 0 && i + 1 < argc)
+@@ -825,7 +835,7 @@ main (int argc, char **argv)
+
+ printf ("Options:\n\n"
+ "-n <number> Number of tests to run\n"
+- "-s <seed> Seed of first test\n"
++ "-s <seed> Seed of first test (ignored if PIXMAN_RANDOMIZE_TESTS is set)\n"
+ "-v Print out seeds\n"
+ "-v <n> Print out every n'th seed\n\n");
+
+@@ -836,19 +846,24 @@ main (int argc, char **argv)
+ if (n_tests == 0xffffffff)
+ n_tests = 8000;
+
+- /* FIXME: seed 2005763 fails in set_lum() with divide by zero */
++ if (getenv ("PIXMAN_RANDOMIZE_TESTS"))
++ {
++ seed = get_random_seed();
++ printf ("First seed: 0x%08x\n", seed);
++ }
++
++ if (use_threads)
++ {
+ #ifdef USE_OPENMP
+ # pragma omp parallel for default(none) shared(verbose, n_tests, mod, seed)
+ #endif
+- for (i = seed; i < seed + n_tests; ++i)
++ for (i = seed; i < seed + n_tests; ++i)
++ run_test (i, verbose, mod);
++ }
++ else
+ {
+- if (verbose)
+- {
+- if (mod == 0 || (i % mod) == 0)
+- printf ("Seed %d\n", i);
+- }
+-
+- run_test (i);
++ for (i = seed; i < seed + n_tests; ++i)
++ run_test (i, verbose, mod);
+ }
+
+ return 0;
+diff --git a/test/utils.c b/test/utils.c
+index 4bf02e1..56701c4 100644
+--- a/test/utils.c
++++ b/test/utils.c
+@@ -455,6 +455,16 @@ gettime (void)
+ #endif
+ }
+
++uint32_t
++get_random_seed (void)
++{
++ double d = gettime();
++
++ lcg_srand (*(uint32_t *)&d);
++
++ return lcg_rand_u32 ();
++}
++
+ static const char *global_msg;
+
+ static void
+diff --git a/test/utils.h b/test/utils.h
+index a5183f7..615ad78 100644
+--- a/test/utils.h
++++ b/test/utils.h
+@@ -79,6 +79,9 @@ make_random_bytes (int n_bytes);
+ double
+ gettime (void);
+
++uint32_t
++get_random_seed (void);
++
+ /* main body of the fuzzer test */
+ int
+ fuzzer_test_main (const char *test_name,
+--
+1.6.6.1
+