diff options
author | marha <marha@users.sourceforge.net> | 2010-08-06 11:48:36 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-08-06 11:48:36 +0000 |
commit | 20ff8ddf2d9bb41050d10bbc75d61b9161880c7c (patch) | |
tree | 22566fcd9663b2baa565cd0c64eaa662d6ba03ee /pixman/test/fuzzer-find-diff.pl | |
parent | c29011f2831315d3da9c4727c1e626d80520b97a (diff) | |
parent | 6849d83857b4e470a44ad8b6aa5cfb283fd64c89 (diff) | |
download | vcxsrv-20ff8ddf2d9bb41050d10bbc75d61b9161880c7c.tar.gz vcxsrv-20ff8ddf2d9bb41050d10bbc75d61b9161880c7c.tar.bz2 vcxsrv-20ff8ddf2d9bb41050d10bbc75d61b9161880c7c.zip |
svn merge ^/branches/released .
Diffstat (limited to 'pixman/test/fuzzer-find-diff.pl')
-rw-r--r-- | pixman/test/fuzzer-find-diff.pl | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/pixman/test/fuzzer-find-diff.pl b/pixman/test/fuzzer-find-diff.pl new file mode 100644 index 000000000..a43f6fb83 --- /dev/null +++ b/pixman/test/fuzzer-find-diff.pl @@ -0,0 +1,68 @@ +#!/usr/bin/env perl
+
+$usage = "Usage:
+ fuzzer-find-diff.pl reference_binary new_binary [number_of_tests_to_run]
+
+The first two input arguments are the commands to run the test programs
+based on fuzzer_test_main() function from 'util.c' (preferably they should
+be statically compiled, this can be achieved via '--disable-shared' pixman
+configure option). The third optional argument is the number of test rounds
+to run (if not specified, then testing runs infinitely or until some problem
+is detected).
+
+Usage examples:
+ fuzzer-find-diff.pl ./blitters-test-with-sse-disabled ./blitters-test 9000000
+ fuzzer-find-diff.pl ./blitters-test \"ssh ppc64_host /path/to/blitters-test\"
+";
+
+$#ARGV >= 1 or die $usage;
+
+$batch_size = 10000;
+
+if ($#ARGV >= 2) {
+ $number_of_tests = int($ARGV[2]);
+} else {
+ $number_of_tests = -1
+}
+
+sub test_range {
+ my $min = shift;
+ my $max = shift;
+
+ if (`$ARGV[0] $min $max 2>/dev/null` eq `$ARGV[1] $min $max 2>/dev/null`) {
+ return;
+ }
+
+ while ($max != $min + 1) {
+ my $avg = int(($min + $max) / 2);
+ my $res1 = `$ARGV[0] $min $avg 2>/dev/null`;
+ my $res2 = `$ARGV[1] $min $avg 2>/dev/null`;
+ if ($res1 ne $res2) {
+ $max = $avg;
+ } else {
+ $min = $avg;
+ }
+ }
+ return $max;
+}
+
+$base = 1;
+while ($number_of_tests <= 0 || $base <= $number_of_tests) {
+ printf("testing %-12d\r", $base + $batch_size - 1);
+ my $res = test_range($base, $base + $batch_size - 1);
+ if ($res) {
+ printf("Failure: results are different for test %d:\n", $res);
+
+ printf("\n-- ref --\n");
+ print `$ARGV[0] $res`;
+ printf("-- new --\n");
+ print `$ARGV[1] $res`;
+
+ printf("The problematic conditions can be reproduced by running:\n");
+ printf("$ARGV[1] %d\n", $res);
+
+ exit(1);
+ }
+ $base += $batch_size;
+}
+printf("Success: %d tests finished\n", $base - 1);
|