[Pixman] [PATCH 3/5] test: blitters-test updated to use new fuzzer_test_main() function
Siarhei Siamashka
siarhei.siamashka at gmail.com
Tue May 25 10:15:06 PDT 2010
From: Siarhei Siamashka <siarhei.siamashka at nokia.com>
---
test/blitters-test-bisect.rb | 43 ---------------------
test/blitters-test.c | 84 ++++-------------------------------------
2 files changed, 9 insertions(+), 118 deletions(-)
delete mode 100644 test/blitters-test-bisect.rb
diff --git a/test/blitters-test-bisect.rb b/test/blitters-test-bisect.rb
deleted file mode 100644
index 62ff782..0000000
--- a/test/blitters-test-bisect.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env ruby
-
-if not ARGV[0] or not ARGV[1] then
- printf("Please provide two 'blitters-test' static binaries in the command line.\n\n")
- printf("The first should be linked with a correct reference pixman library.\n")
- printf("The second binary should be linked with a pixman library which needs to be tested.\n")
- exit(0)
-end
-
-def test_range(min, max)
- if `#{ARGV[0]} #{min} #{max} 2>/dev/null` == `#{ARGV[1]} #{min} #{max} 2>/dev/null` then
- return
- end
- while max != min + 1 do
- avg = ((min + max) / 2).to_i
- res1 = `#{ARGV[0]} #{min} #{avg} 2>/dev/null`
- res2 = `#{ARGV[1]} #{min} #{avg} 2>/dev/null`
- if res1 != res2 then
- max = avg
- else
- min = avg
- end
- end
- return max
-end
-
-base = 1
-while true do
- # run infinitely, processing 100000 test cases per iteration
- printf("running tests %d-%d\n", base, base + 100000 - 1);
- res = test_range(base, base + 100000 - 1)
- if res then
- printf("-- ref --\n")
- printf("%s\n", `#{ARGV[0]} -#{res}`)
- printf("-- new --\n")
- printf("%s\n", `#{ARGV[1]} -#{res}`)
-
- printf("\nFailed test %d, you can reproduce the problematic conditions by running\n", res)
- printf("#{ARGV[1]} -%d\n", res)
- exit(1)
- end
- base += 100000
-end
diff --git a/test/blitters-test.c b/test/blitters-test.c
index 18f871e..673e52f 100644
--- a/test/blitters-test.c
+++ b/test/blitters-test.c
@@ -2,24 +2,8 @@
* Test program, which stresses the use of different color formats and
* compositing operations.
*
- * Just run it without any command line arguments, and it will report either
- * "blitters test passed" - everything is ok
- * "blitters test failed!" - there is some problem
- *
- * In the case of failure, finding the problem involves the following steps:
- * 1. Get the reference 'blitters-test' binary. It makes sense to disable all
- * the cpu specific optimizations in pixman and also configure it with
- * '--disable-shared' option. Those who are paranoid can also tweak the
- * sources to disable all fastpath functions. The resulting binary
- * can be renamed to something like 'blitters-test.ref'.
- * 2. Compile the buggy binary (also with the '--disable-shared' option).
- * 3. Run 'ruby blitters-test-bisect.rb ./blitters-test.ref ./blitters-test'
- * 4. Look at the information about failed case (destination buffer content
- * will be shown) and try to figure out what is wrong. Loading
- * test program in gdb, specifying failed test number in the command
- * line with '-' character prepended and setting breakpoint on
- * 'pixman_image_composite' function can provide detailed information
- * about function arguments
+ * Script 'fuzzer-find-diff.pl' can be used to narrow down the problem in
+ * the case of test failure.
*/
#include <assert.h>
#include <stdlib.h>
@@ -260,7 +244,7 @@ static pixman_format_code_t mask_fmt_list[] = {
* Composite operation with pseudorandom images
*/
uint32_t
-test_composite (uint32_t initcrc, int testnum, int verbose)
+test_composite (int testnum, int verbose)
{
int i;
pixman_image_t *src_img = NULL;
@@ -410,15 +394,15 @@ test_composite (uint32_t initcrc, int testnum, int verbose)
printf ("---\n");
}
- free_random_image (initcrc, src_img, -1);
- crc32 = free_random_image (initcrc, dst_img, dst_fmt);
+ free_random_image (0, src_img, -1);
+ crc32 = free_random_image (0, dst_img, dst_fmt);
if (mask_img)
{
if (srcbuf == maskbuf)
pixman_image_unref(mask_img);
else
- free_random_image (initcrc, mask_img, -1);
+ free_random_image (0, mask_img, -1);
}
@@ -438,60 +422,10 @@ initialize_palette (void)
}
int
-main (int argc, char *argv[])
+main (int argc, const char *argv[])
{
- int i, n1 = 1, n2 = 0;
- uint32_t crc = 0;
- int verbose = getenv ("VERBOSE") != NULL;
-
initialize_palette();
- if (argc >= 3)
- {
- n1 = atoi (argv[1]);
- n2 = atoi (argv[2]);
- }
- else if (argc >= 2)
- {
- n2 = atoi (argv[1]);
- }
- else
- {
- n1 = 1;
- n2 = 2000000;
- }
-
- if (n2 < 0)
- {
- crc = test_composite (0, abs (n2), 1);
- printf ("crc32=%08X\n", crc);
- }
- else
- {
- for (i = n1; i <= n2; i++)
- {
- crc = test_composite (crc, i, 0);
-
- if (verbose)
- printf ("%d: %08X\n", i, crc);
- }
- printf ("crc32=%08X\n", crc);
-
- if (n2 == 2000000)
- {
- /* Predefined value for running with all the fastpath functions
- disabled. It needs to be updated every time when changes are
- introduced to this program or behavior of pixman changes! */
- if (crc == 0x8F9F7DC1)
- {
- printf ("blitters test passed\n");
- }
- else
- {
- printf ("blitters test failed!\n");
- return 1;
- }
- }
- }
- return 0;
+ return fuzzer_test_main("blitters", 2000000, 0x2CFE57ED,
+ test_composite, argc, argv);
}
--
1.6.4.4
More information about the Pixman
mailing list