aboutsummaryrefslogtreecommitdiff
path: root/pixman
diff options
context:
space:
mode:
Diffstat (limited to 'pixman')
-rw-r--r--pixman/test/composite.c17
-rw-r--r--pixman/test/stress-test.c37
-rw-r--r--pixman/test/utils.c10
-rw-r--r--pixman/test/utils.h3
4 files changed, 51 insertions, 16 deletions
diff --git a/pixman/test/composite.c b/pixman/test/composite.c
index 50a3c0644..5e486708d 100644
--- a/pixman/test/composite.c
+++ b/pixman/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/pixman/test/stress-test.c b/pixman/test/stress-test.c
index a51737ea0..c694bde8c 100644
--- a/pixman/test/stress-test.c
+++ b/pixman/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/pixman/test/utils.c b/pixman/test/utils.c
index ee68d272c..2f1565840 100644
--- a/pixman/test/utils.c
+++ b/pixman/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/pixman/test/utils.h b/pixman/test/utils.h
index 5643c1228..8f0e0c0e5 100644
--- a/pixman/test/utils.h
+++ b/pixman/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,