mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-02 22:50:20 +00:00
As a test suite, run stand-alone fuzzer on seed corpus
Temporarily skip fuzz tests on Windows. There are Windows-specific failures to address later.
This commit is contained in:
parent
e2c77bab89
commit
bcfa407912
@ -1,5 +1,9 @@
|
|||||||
2019-06-15 Jay Berkenbilt <ejb@ql.org>
|
2019-06-15 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* Do "ideal integration" with oss-fuzz. This includes adding a
|
||||||
|
better fuzzer with a seed corpus and adding automated tests of the
|
||||||
|
fuzzer with the test data.
|
||||||
|
|
||||||
* When parsing files, while reading an object, if there are too
|
* When parsing files, while reading an object, if there are too
|
||||||
many consecutive errors without enough intervening successes, give
|
many consecutive errors without enough intervening successes, give
|
||||||
up on the specific object. This reduces cases in which very badly
|
up on the specific object. This reduces cases in which very badly
|
||||||
|
52
fuzz/qtest/fuzz.test
Normal file
52
fuzz/qtest/fuzz.test
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
require 5.008;
|
||||||
|
use warnings;
|
||||||
|
use strict;
|
||||||
|
use Digest::SHA;
|
||||||
|
use File::Basename;
|
||||||
|
|
||||||
|
require TestDriver;
|
||||||
|
|
||||||
|
my $td = new TestDriver('fuzz');
|
||||||
|
|
||||||
|
if (($^O eq 'MSWin32') || ($^O eq 'msys'))
|
||||||
|
{
|
||||||
|
$td->emphasize("temporarily skipping fuzz tests in Windows");
|
||||||
|
$td->report(0);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
my @files = glob("../qpdf_fuzzer_seed_corpus/*");
|
||||||
|
my $n_test_files = 27;
|
||||||
|
my $n_orig_files = 2559;
|
||||||
|
my $n_files = $n_test_files + $n_orig_files;
|
||||||
|
|
||||||
|
if (scalar(@files) != $n_files)
|
||||||
|
{
|
||||||
|
die "wrong number of files seen in fuzz.test";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $f (@files)
|
||||||
|
{
|
||||||
|
my $sum = basename($f);
|
||||||
|
$td->runtest("checksum $sum",
|
||||||
|
{$td->STRING => get_sha1_checksum($f)},
|
||||||
|
{$td->STRING => $sum});
|
||||||
|
$td->runtest("fuzz check $sum",
|
||||||
|
{$td->COMMAND => "qpdf_fuzzer $f"},
|
||||||
|
{$td->REGEXP => ".*$f successful\n",
|
||||||
|
$td->EXIT_STATUS => 0},
|
||||||
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
}
|
||||||
|
|
||||||
|
$td->report(2 * $n_files);
|
||||||
|
|
||||||
|
sub get_sha1_checksum
|
||||||
|
{
|
||||||
|
my $file = shift;
|
||||||
|
open(F, "<$file") or fatal("can't open $file: $!");
|
||||||
|
binmode F;
|
||||||
|
my $digest = Digest::SHA->new('sha1')->addfile(*F)->hexdigest;
|
||||||
|
close(F);
|
||||||
|
$digest;
|
||||||
|
}
|
@ -642,6 +642,8 @@ my @bug_tests = (
|
|||||||
["263", "empty xref stream", 2],
|
["263", "empty xref stream", 2],
|
||||||
["335a", "ozz-fuzz-12152", 2],
|
["335a", "ozz-fuzz-12152", 2],
|
||||||
["335b", "ozz-fuzz-14845", 2],
|
["335b", "ozz-fuzz-14845", 2],
|
||||||
|
# When adding to this list, consider adding to SEED_CORPUS_FILES
|
||||||
|
# in fuzz/build.mk and updating the count in fuzz/qtest/fuzz.test.
|
||||||
);
|
);
|
||||||
$n_tests += scalar(@bug_tests);
|
$n_tests += scalar(@bug_tests);
|
||||||
foreach my $d (@bug_tests)
|
foreach my $d (@bug_tests)
|
||||||
|
Loading…
Reference in New Issue
Block a user