mmx: add x8f8g8b8 fetcher
[profile/ivi/pixman.git] / test / stress-test.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "utils.h"
4 #include <sys/types.h>
5
6 #if 0
7 #define fence_malloc malloc
8 #define fence_free free
9 #define make_random_bytes malloc
10 #endif
11
12 static const pixman_format_code_t image_formats[] =
13 {
14     PIXMAN_a8r8g8b8,
15     PIXMAN_x8r8g8b8,
16     PIXMAN_r5g6b5,
17     PIXMAN_r3g3b2,
18     PIXMAN_a8,
19     PIXMAN_a8b8g8r8,
20     PIXMAN_x8b8g8r8,
21     PIXMAN_b8g8r8a8,
22     PIXMAN_b8g8r8x8,
23     PIXMAN_r8g8b8a8,
24     PIXMAN_r8g8b8x8,
25     PIXMAN_x14r6g6b6,
26     PIXMAN_r8g8b8,
27     PIXMAN_b8g8r8,
28     PIXMAN_r5g6b5,
29     PIXMAN_b5g6r5,
30     PIXMAN_x2r10g10b10,
31     PIXMAN_a2r10g10b10,
32     PIXMAN_x2b10g10r10,
33     PIXMAN_a2b10g10r10,
34     PIXMAN_a1r5g5b5,
35     PIXMAN_x1r5g5b5,
36     PIXMAN_a1b5g5r5,
37     PIXMAN_x1b5g5r5,
38     PIXMAN_a4r4g4b4,
39     PIXMAN_x4r4g4b4,
40     PIXMAN_a4b4g4r4,
41     PIXMAN_x4b4g4r4,
42     PIXMAN_a8,
43     PIXMAN_r3g3b2,
44     PIXMAN_b2g3r3,
45     PIXMAN_a2r2g2b2,
46     PIXMAN_a2b2g2r2,
47     PIXMAN_c8,
48     PIXMAN_g8,
49     PIXMAN_x4c4,
50     PIXMAN_x4g4,
51     PIXMAN_c4,
52     PIXMAN_g4,
53     PIXMAN_g1,
54     PIXMAN_x4a4,
55     PIXMAN_a4,
56     PIXMAN_r1g2b1,
57     PIXMAN_b1g2r1,
58     PIXMAN_a1r1g1b1,
59     PIXMAN_a1b1g1r1,
60     PIXMAN_a1
61 };
62
63 static pixman_filter_t filters[] =
64 {
65     PIXMAN_FILTER_NEAREST,
66     PIXMAN_FILTER_BILINEAR,
67     PIXMAN_FILTER_FAST,
68     PIXMAN_FILTER_GOOD,
69     PIXMAN_FILTER_BEST,
70     PIXMAN_FILTER_CONVOLUTION
71 };
72
73 static int
74 get_size (void)
75 {
76     switch (lcg_rand_n (28))
77     {
78     case 0:
79         return 1;
80
81     case 1:
82         return 2;
83
84     default:
85     case 2:
86         return lcg_rand_n (200);
87
88     case 4:
89         return lcg_rand_n (2000) + 1000;
90
91     case 5:
92         return 65535;
93
94     case 6:
95         return 65536;
96
97     case 7:
98         return lcg_rand_N (64000) + 63000;
99     }
100 }
101
102 static void
103 destroy (pixman_image_t *image, void *data)
104 {
105     if (image->type == BITS && image->bits.free_me != image->bits.bits)
106     {
107         uint32_t *bits;
108
109         if (image->bits.bits != (void *)0x01)
110         {
111             bits = image->bits.bits;
112
113             if (image->bits.rowstride < 0)
114                 bits -= (- image->bits.rowstride * (image->bits.height - 1));
115
116             fence_free (bits);
117         }
118     }
119
120     free (data);
121 }
122
123 static uint32_t
124 real_reader (const void *src, int size)
125 {
126     switch (size)
127     {
128     case 1:
129         return *(uint8_t *)src;
130     case 2:
131         return *(uint16_t *)src;
132     case 4:
133         return *(uint32_t *)src;
134     default:
135         assert (0);
136         return 0; /* silence MSVC */
137     }
138 }
139
140 static void
141 real_writer (void *src, uint32_t value, int size)
142 {
143     switch (size)
144     {
145     case 1:
146         *(uint8_t *)src = value;
147         break;
148
149     case 2:
150         *(uint16_t *)src = value;
151         break;
152
153     case 4:
154         *(uint32_t *)src = value;
155         break;
156
157     default:
158         assert (0);
159         break;
160     }
161 }
162
163 static uint32_t
164 fake_reader (const void *src, int size)
165 {
166     uint32_t r = lcg_rand_u32 ();
167
168     assert (size == 1 || size == 2 || size == 4);
169
170     return r >> (32 - (size * 8));
171 }
172
173 static void
174 fake_writer (void *src, uint32_t value, int size)
175 {
176     assert (size == 1 || size == 2 || size == 4);
177 }
178
179 static int32_t
180 log_rand (void)
181 {
182     uint32_t mask;
183
184     mask = (1 << lcg_rand_n (31)) - 1;
185
186     return (lcg_rand () & mask) - (mask >> 1);
187 }
188
189 static pixman_image_t *
190 create_random_bits_image (void)
191 {
192     pixman_format_code_t format;
193     pixman_indexed_t *indexed;
194     pixman_image_t *image;
195     int width, height, stride;
196     uint32_t *bits;
197     pixman_read_memory_func_t read_func = NULL;
198     pixman_write_memory_func_t write_func = NULL;
199     pixman_filter_t filter;
200     pixman_fixed_t *coefficients = NULL;
201     int n_coefficients = 0;
202
203     /* format */
204     format = image_formats[lcg_rand_n (ARRAY_LENGTH (image_formats))];
205
206     indexed = NULL;
207     if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR)
208     {
209         indexed = malloc (sizeof (pixman_indexed_t));
210
211         initialize_palette (indexed, PIXMAN_FORMAT_BPP (format), TRUE);
212     }
213     else if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_GRAY)
214     {
215         indexed = malloc (sizeof (pixman_indexed_t));
216
217         initialize_palette (indexed, PIXMAN_FORMAT_BPP (format), FALSE);
218     }
219     else
220     {
221         indexed = NULL;
222     }
223
224     /* size */
225     width = get_size ();
226     height = get_size ();
227
228     if ((uint64_t)width * height > 200000)
229     {
230         if (lcg_rand_n(2) == 0)
231             height = 200000 / width;
232         else
233             width = 200000 / height;
234     }
235
236     if (height == 0)
237         height = 1;
238     if (width == 0)
239         width = 1;
240
241     /* bits */
242     switch (lcg_rand_n (7))
243     {
244     default:
245     case 0:
246         stride = width * PIXMAN_FORMAT_BPP (format) + lcg_rand_n (17);
247         stride = (stride + 3) & (~3);
248         bits = (uint32_t *)make_random_bytes (height * stride);
249         break;
250
251     case 1:
252         stride = 0;
253         bits = NULL;
254         break;
255
256     case 2: /* Zero-filled */
257         stride = width * PIXMAN_FORMAT_BPP (format) + lcg_rand_n (17);
258         stride = (stride + 3) & (~3);
259         bits = fence_malloc (height * stride);
260         if (!bits)
261             return NULL;
262         memset (bits, 0, height * stride);
263         break;
264
265     case 3: /* Filled with 0xFF */
266         stride = width * PIXMAN_FORMAT_BPP (format) + lcg_rand_n (17);
267         stride = (stride + 3) & (~3);
268         bits = fence_malloc (height * stride);
269         if (!bits)
270             return NULL;
271         memset (bits, 0xff, height * stride);
272         break;
273
274     case 4: /* bits is a bad pointer, has read/write functions */
275         stride = 232;
276         bits = (void *)0x01;
277         read_func = fake_reader;
278         write_func = fake_writer;
279         break;
280
281     case 5: /* bits is a real pointer, has read/write functions */
282         stride = width * PIXMAN_FORMAT_BPP (format) + lcg_rand_n (17);
283         stride = (stride + 3) & (~3);
284         bits = fence_malloc (height * stride);
285         if (!bits)
286             return NULL;
287         memset (bits, 0xff, height * stride);
288         read_func = real_reader;
289         write_func = real_writer;
290         break;
291
292     case 6: /* bits is a real pointer, stride is negative */
293         stride = (width * PIXMAN_FORMAT_BPP (format) + lcg_rand_n (17));
294         stride = (stride + 3) & (~3);
295         bits = (uint32_t *)make_random_bytes (height * stride);
296         if (!bits)
297             return NULL;
298         bits += ((height - 1) * stride) / 4;
299         stride = - stride;
300         break;
301     }
302
303     /* Filter */
304     filter = filters[lcg_rand_n (ARRAY_LENGTH (filters))];
305     if (filter == PIXMAN_FILTER_CONVOLUTION)
306     {
307         int width = lcg_rand_n (17);
308         int height = lcg_rand_n (19);
309
310         n_coefficients = width * height + 2;
311         coefficients = malloc (n_coefficients * sizeof (pixman_fixed_t));
312
313         if (coefficients)
314         {
315             int i;
316
317             for (i = 0; i < width * height; ++i)
318                 coefficients[i + 2] = lcg_rand_u32();
319
320             coefficients[0] = width << 16;
321             coefficients[1] = height << 16;
322         }
323         else
324         {
325             filter = PIXMAN_FILTER_BEST;
326         }
327     }
328
329     /* Finally create the image */
330     image = pixman_image_create_bits (format, width, height, bits, stride);
331     if (!image)
332         return NULL;
333
334     pixman_image_set_indexed (image, indexed);
335     pixman_image_set_destroy_function (image, destroy, indexed);
336     pixman_image_set_accessors (image, read_func, write_func);
337     pixman_image_set_filter (image, filter, coefficients, n_coefficients);
338
339     return image;
340 }
341
342 static pixman_repeat_t repeats[] =
343 {
344     PIXMAN_REPEAT_NONE,
345     PIXMAN_REPEAT_NORMAL,
346     PIXMAN_REPEAT_REFLECT,
347     PIXMAN_REPEAT_PAD
348 };
349
350 static uint32_t
351 absolute (int32_t i)
352 {
353     return i < 0? -i : i;
354 }
355
356 static void
357 set_general_properties (pixman_image_t *image, pixman_bool_t allow_alpha_map)
358 {
359     pixman_repeat_t repeat;
360
361     /* Set properties that are generic to all images */
362
363     /* Repeat */
364     repeat = repeats[lcg_rand_n (ARRAY_LENGTH (repeats))];
365     pixman_image_set_repeat (image, repeat);
366
367     /* Alpha map */
368     if (allow_alpha_map && lcg_rand_n (3) == 0)
369     {
370         pixman_image_t *alpha_map;
371         int16_t x, y;
372
373         alpha_map = create_random_bits_image ();
374
375         if (alpha_map)
376         {
377             set_general_properties (alpha_map, FALSE);
378
379             x = lcg_rand_N (100000) - 65536;
380             y = lcg_rand_N (100000) - 65536;
381
382             pixman_image_set_alpha_map (image, alpha_map, x, y);
383
384             pixman_image_unref (alpha_map);
385         }
386     }
387
388     /* Component alpha */
389     pixman_image_set_component_alpha (image, lcg_rand_n (3) == 0);
390
391     /* Clip region */
392     if (lcg_rand_n (8) != 0)
393     {
394         pixman_region32_t region;
395         int i, n_rects;
396
397         pixman_region32_init (&region);
398
399         switch (lcg_rand_n (10))
400         {
401         case 0:
402             n_rects = 0;
403             break;
404
405         case 1: case 2: case 3:
406             n_rects = 1;
407             break;
408
409         case 4: case 5:
410             n_rects = 2;
411             break;
412
413         case 6: case 7:
414             n_rects = 3;
415
416         default:
417             n_rects = lcg_rand_n (100);
418             break;
419         }
420
421         for (i = 0; i < n_rects; ++i)
422         {
423             uint32_t width, height;
424             int x, y;
425
426             x = log_rand();
427             y = log_rand();
428             width = absolute (log_rand ()) + 1;
429             height = absolute (log_rand ()) + 1;
430
431             pixman_region32_union_rect (
432                 &region, &region, x, y, width, height);
433         }
434
435         pixman_image_set_clip_region32 (image, &region);
436
437         pixman_region32_fini (&region);
438     }
439
440     /* Whether source clipping is enabled */
441     pixman_image_set_source_clipping (image, !!lcg_rand_n (2));
442
443     /* Client clip */
444     pixman_image_set_has_client_clip (image, !!lcg_rand_n (2));
445
446     /* Transform */
447     if (lcg_rand_n (5) < 2)
448     {
449         pixman_transform_t xform;
450         int i, j, k;
451         uint32_t tx, ty, sx, sy;
452         uint32_t c, s;
453
454         memset (&xform, 0, sizeof xform);
455         xform.matrix[0][0] = pixman_fixed_1;
456         xform.matrix[1][1] = pixman_fixed_1;
457         xform.matrix[2][2] = pixman_fixed_1;
458
459         for (k = 0; k < 3; ++k)
460         {
461             switch (lcg_rand_n (4))
462             {
463             case 0:
464                 /* rotation */
465                 c = lcg_rand_N (2 * 65536) - 65536;
466                 s = lcg_rand_N (2 * 65536) - 65536;
467                 pixman_transform_rotate (&xform, NULL, c, s);
468                 break;
469
470             case 1:
471                 /* translation */
472                 tx = lcg_rand_u32();
473                 ty = lcg_rand_u32();
474                 pixman_transform_translate (&xform, NULL, tx, ty);
475                 break;
476
477             case 2:
478                 /* scale */
479                 sx = lcg_rand_u32();
480                 sy = lcg_rand_u32();
481                 pixman_transform_scale (&xform, NULL, sx, sy);
482                 break;
483
484             case 3:
485                 if (lcg_rand_n (16) == 0)
486                 {
487                     /* random */
488                     for (i = 0; i < 3; ++i)
489                         for (j = 0; j < 3; ++j)
490                             xform.matrix[i][j] = lcg_rand_u32();
491                     break;
492                 }
493                 else if (lcg_rand_n (16) == 0)
494                 {
495                     /* zero */
496                     memset (&xform, 0, sizeof xform);
497                 }
498                 break;
499             }
500         }
501
502         pixman_image_set_transform (image, &xform);
503     }
504 }
505
506 static pixman_color_t
507 random_color (void)
508 {
509     pixman_color_t color =
510     {
511         lcg_rand() & 0xffff,
512         lcg_rand() & 0xffff,
513         lcg_rand() & 0xffff,
514         lcg_rand() & 0xffff,
515     };
516
517     return color;
518 }
519
520
521 static pixman_image_t *
522 create_random_solid_image (void)
523 {
524     pixman_color_t color = random_color();
525     pixman_image_t *image = pixman_image_create_solid_fill (&color);
526
527     return image;
528 }
529
530 static pixman_gradient_stop_t *
531 create_random_stops (int *n_stops)
532 {
533     pixman_fixed_t step;
534     pixman_fixed_t s;
535     int i;
536     pixman_gradient_stop_t *stops;
537
538     *n_stops = lcg_rand_n (50) + 1;
539
540     step = pixman_fixed_1 / *n_stops;
541
542     stops = malloc (*n_stops * sizeof (pixman_gradient_stop_t));
543
544     s = 0;
545     for (i = 0; i < (*n_stops) - 1; ++i)
546     {
547         stops[i].x = s;
548         stops[i].color = random_color();
549
550         s += step;
551     }
552
553     stops[*n_stops - 1].x = pixman_fixed_1;
554     stops[*n_stops - 1].color = random_color();
555
556     return stops;
557 }
558
559 static pixman_point_fixed_t
560 create_random_point (void)
561 {
562     pixman_point_fixed_t p;
563
564     p.x = log_rand ();
565     p.y = log_rand ();
566
567     return p;
568 }
569
570 static pixman_image_t *
571 create_random_linear_image (void)
572 {
573     int n_stops;
574     pixman_gradient_stop_t *stops;
575     pixman_point_fixed_t p1, p2;
576     pixman_image_t *result;
577
578     stops = create_random_stops (&n_stops);
579     if (!stops)
580         return NULL;
581
582     p1 = create_random_point ();
583     p2 = create_random_point ();
584
585     result = pixman_image_create_linear_gradient (&p1, &p2, stops, n_stops);
586
587     free (stops);
588
589     return result;
590 }
591
592 static pixman_image_t *
593 create_random_radial_image (void)
594 {
595     int n_stops;
596     pixman_gradient_stop_t *stops;
597     pixman_point_fixed_t inner_c, outer_c;
598     pixman_fixed_t inner_r, outer_r;
599     pixman_image_t *result;
600
601     inner_c = create_random_point();
602     outer_c = create_random_point();
603     inner_r = lcg_rand();
604     outer_r = lcg_rand();
605
606     stops = create_random_stops (&n_stops);
607
608     if (!stops)
609         return NULL;
610
611     result = pixman_image_create_radial_gradient (
612         &inner_c, &outer_c, inner_r, outer_r, stops, n_stops);
613
614     free (stops);
615
616     return result;
617 }
618
619 static pixman_image_t *
620 create_random_conical_image (void)
621 {
622     pixman_gradient_stop_t *stops;
623     int n_stops;
624     pixman_point_fixed_t c;
625     pixman_fixed_t angle;
626     pixman_image_t *result;
627
628     c = create_random_point();
629     angle = lcg_rand();
630
631     stops = create_random_stops (&n_stops);
632
633     if (!stops)
634         return NULL;
635
636     result = pixman_image_create_conical_gradient (&c, angle, stops, n_stops);
637
638     free (stops);
639
640     return result;
641 }
642
643 static pixman_image_t *
644 create_random_image (void)
645 {
646     pixman_image_t *result;
647
648     switch (lcg_rand_n (5))
649     {
650     default:
651     case 0:
652         result = create_random_bits_image ();
653         break;
654
655     case 1:
656         result = create_random_solid_image ();
657         break;
658
659     case 2:
660         result = create_random_linear_image ();
661         break;
662
663     case 3:
664         result = create_random_radial_image ();
665         break;
666
667     case 4:
668         result = create_random_conical_image ();
669         break;
670     }
671
672     if (result)
673         set_general_properties (result, TRUE);
674
675     return result;
676 }
677
678 static const pixman_op_t op_list[] =
679 {
680     PIXMAN_OP_SRC,
681     PIXMAN_OP_OVER,
682     PIXMAN_OP_ADD,
683     PIXMAN_OP_CLEAR,
684     PIXMAN_OP_SRC,
685     PIXMAN_OP_DST,
686     PIXMAN_OP_OVER,
687     PIXMAN_OP_OVER_REVERSE,
688     PIXMAN_OP_IN,
689     PIXMAN_OP_IN_REVERSE,
690     PIXMAN_OP_OUT,
691     PIXMAN_OP_OUT_REVERSE,
692     PIXMAN_OP_ATOP,
693     PIXMAN_OP_ATOP_REVERSE,
694     PIXMAN_OP_XOR,
695     PIXMAN_OP_ADD,
696     PIXMAN_OP_SATURATE,
697     PIXMAN_OP_DISJOINT_CLEAR,
698     PIXMAN_OP_DISJOINT_SRC,
699     PIXMAN_OP_DISJOINT_DST,
700     PIXMAN_OP_DISJOINT_OVER,
701     PIXMAN_OP_DISJOINT_OVER_REVERSE,
702     PIXMAN_OP_DISJOINT_IN,
703     PIXMAN_OP_DISJOINT_IN_REVERSE,
704     PIXMAN_OP_DISJOINT_OUT,
705     PIXMAN_OP_DISJOINT_OUT_REVERSE,
706     PIXMAN_OP_DISJOINT_ATOP,
707     PIXMAN_OP_DISJOINT_ATOP_REVERSE,
708     PIXMAN_OP_DISJOINT_XOR,
709     PIXMAN_OP_CONJOINT_CLEAR,
710     PIXMAN_OP_CONJOINT_SRC,
711     PIXMAN_OP_CONJOINT_DST,
712     PIXMAN_OP_CONJOINT_OVER,
713     PIXMAN_OP_CONJOINT_OVER_REVERSE,
714     PIXMAN_OP_CONJOINT_IN,
715     PIXMAN_OP_CONJOINT_IN_REVERSE,
716     PIXMAN_OP_CONJOINT_OUT,
717     PIXMAN_OP_CONJOINT_OUT_REVERSE,
718     PIXMAN_OP_CONJOINT_ATOP,
719     PIXMAN_OP_CONJOINT_ATOP_REVERSE,
720     PIXMAN_OP_CONJOINT_XOR,
721     PIXMAN_OP_MULTIPLY,
722     PIXMAN_OP_SCREEN,
723     PIXMAN_OP_OVERLAY,
724     PIXMAN_OP_DARKEN,
725     PIXMAN_OP_LIGHTEN,
726     PIXMAN_OP_COLOR_DODGE,
727     PIXMAN_OP_COLOR_BURN,
728     PIXMAN_OP_HARD_LIGHT,
729     PIXMAN_OP_DIFFERENCE,
730     PIXMAN_OP_EXCLUSION,
731     PIXMAN_OP_SOFT_LIGHT,
732     PIXMAN_OP_HSL_HUE,
733     PIXMAN_OP_HSL_SATURATION,
734     PIXMAN_OP_HSL_COLOR,
735     PIXMAN_OP_HSL_LUMINOSITY,
736 };
737
738 static void
739 run_test (uint32_t seed, pixman_bool_t verbose, uint32_t mod)
740 {
741     pixman_image_t *source, *mask, *dest;
742     pixman_op_t op;
743
744     if (verbose)
745     {
746         if (mod == 0 || (seed % mod) == 0)
747             printf ("Seed 0x%08x\n", seed);
748     }
749             
750     lcg_srand (seed);
751
752     source = create_random_image ();
753     mask   = create_random_image ();
754     dest   = create_random_bits_image ();
755
756     if (source && mask && dest)
757     {
758         set_general_properties (dest, TRUE);
759
760         op = op_list [lcg_rand_n (ARRAY_LENGTH (op_list))];
761
762         pixman_image_composite32 (op,
763                                   source, mask, dest,
764                                   log_rand(), log_rand(),
765                                   log_rand(), log_rand(),
766                                   log_rand(), log_rand(),
767                                   absolute (log_rand()),
768                                   absolute (log_rand()));
769     }
770     if (source)
771         pixman_image_unref (source);
772     if (mask)
773         pixman_image_unref (mask);
774     if (dest)
775         pixman_image_unref (dest);
776 }
777
778 static pixman_bool_t
779 get_int (char *s, uint32_t *i)
780 {
781     char *end;
782     int p;
783
784     p = strtol (s, &end, 0);
785
786     if (end != s && *end == 0)
787     {
788         *i = p;
789         return TRUE;
790     }
791
792     return FALSE;
793 }
794
795 int
796 main (int argc, char **argv)
797 {
798     int verbose = FALSE;
799     uint32_t seed = 1;
800     uint32_t n_tests = 0xffffffff;
801     uint32_t mod = 0;
802     pixman_bool_t use_threads = TRUE;
803     uint32_t i;
804
805     pixman_disable_out_of_bounds_workaround ();
806
807     enable_fp_exceptions();
808
809     if (getenv ("VERBOSE") != NULL)
810         verbose = TRUE;
811
812     for (i = 1; i < argc; ++i)
813     {
814         if (strcmp (argv[i], "-v") == 0)
815         {
816             verbose = TRUE;
817
818             if (i + 1 < argc)
819             {
820                 get_int (argv[i + 1], &mod);
821                 i++;
822             }
823         }
824         else if (strcmp (argv[i], "-s") == 0 && i + 1 < argc)
825         {
826             get_int (argv[i + 1], &seed);
827             use_threads = FALSE;
828             i++;
829         }
830         else if (strcmp (argv[i], "-n") == 0 && i + 1 < argc)
831         {
832             get_int (argv[i + 1], &n_tests);
833             i++;
834         }
835         else
836         {
837             if (strcmp (argv[i], "-h") != 0)
838                 printf ("Unknown option '%s'\n\n", argv[i]);
839
840             printf ("Options:\n\n"
841                     "-n <number>        Number of tests to run\n"
842                     "-s <seed>          Seed of first test (ignored if PIXMAN_RANDOMIZE_TESTS is set)\n"
843                     "-v                 Print out seeds\n"
844                     "-v <n>             Print out every n'th seed\n\n");
845
846             exit (-1);
847         }
848     }
849
850     if (n_tests == 0xffffffff)
851         n_tests = 8000;
852
853     if (getenv ("PIXMAN_RANDOMIZE_TESTS"))
854     {
855         seed = get_random_seed();
856         printf ("First seed: 0x%08x\n", seed);
857     }
858
859     if (use_threads)
860     {
861 #ifdef USE_OPENMP
862 #   pragma omp parallel for default(none) shared(verbose, n_tests, mod, seed)
863 #endif
864         for (i = seed; i < seed + n_tests; ++i)
865             run_test (i, verbose, mod);
866     }
867     else
868     {
869         for (i = seed; i < seed + n_tests; ++i)
870             run_test (i, verbose, mod);
871     }
872
873     return 0;
874 }