Commit 2320714339b572a4d5bceadfcfc94356aa782ada

Authored by Jay Berkenbilt
1 parent ed7f2a6c

Clean up fuzzer installation and add test files

* Create the seed corpus in the build directory
* Don't assume all fuzzers share an options file
fuzz/build.mk
... ... @@ -22,8 +22,10 @@ $(BINS_fuzz): $(TARGETS_libqpdf) $(OBJ_DEFAULT_FUZZ)
22 22 # Files from the test suite that are good for seeding the fuzzer.
23 23 # Update $n_test_files in qtest/fuzz.test if you change this list.
24 24 SEED_CORPUS_FILES = \
  25 + stream-data.pdf \
  26 + lin5.pdf \
25 27 field-types.pdf \
26   - image-streams.pdf \
  28 + image-streams-small.pdf \
27 29 need-appearances.pdf \
28 30 outlines-with-actions.pdf \
29 31 outlines-with-old-root-dests.pdf \
... ... @@ -53,7 +55,7 @@ SEED_CORPUS_FILES = \
53 55 # -----
54 56  
55 57 CORPUS_FROM_TEST := $(foreach F,$(SEED_CORPUS_FILES),qpdf/qtest/qpdf/$F)
56   -CORPUS_DIR := fuzz/qpdf_fuzzer_seed_corpus
  58 +CORPUS_DIR := fuzz/$(OUTPUT_DIR)/qpdf_fuzzer_seed_corpus
57 59  
58 60 .PHONY: fuzz_corpus
59 61 fuzz_corpus:: fuzz/$(OUTPUT_DIR)/fuzz_corpus.stamp
... ... @@ -68,7 +70,7 @@ $(foreach F,$(CORPUS_FROM_TEST),$(eval \
68 70  
69 71 fuzz/$(OUTPUT_DIR)/fuzz_corpus.stamp: fuzz/original-corpus.tar.gz $(CORPUS_FROM_TEST)
70 72 mkdir -p $(CORPUS_DIR)
71   - (cd $(CORPUS_DIR); tar xzf ../original-corpus.tar.gz)
  73 + (cd $(CORPUS_DIR); tar xzf ../../original-corpus.tar.gz)
72 74 touch $@
73 75  
74 76 $(foreach B,$(FUZZERS),$(eval \
... ... @@ -122,9 +124,11 @@ install_fuzz: $(STATIC_BINS_fuzz)
122 124 mkdir -p $(OUT)
123 125 cp fuzz/pdf.dict $(STATIC_BINS_fuzz) $(OUT)/
124 126 for B in $(FUZZERS); do \
125   - cp fuzz/options $(OUT)/$${B}.options; \
126   - if test -d fuzz/$${B}_seed_corpus; then \
127   - (cd fuzz/$${B}_seed_corpus; zip -q -r $(OUT)/$${B}_seed_corpus.zip .); \
  127 + if test -f fuzz/$${B}.options; then \
  128 + cp fuzz/$${B}.options $(OUT)/$${B}.options; \
  129 + fi; \
  130 + if test -d fuzz/$(OUTPUT_DIR)/$${B}_seed_corpus; then \
  131 + (cd fuzz/$(OUTPUT_DIR)/$${B}_seed_corpus; zip -q -r $(OUT)/$${B}_seed_corpus.zip .); \
128 132 fi; \
129 133 done
130 134  
... ...
fuzz/options renamed to fuzz/qpdf_fuzzer.options
fuzz/qtest/fuzz.test
... ... @@ -9,8 +9,8 @@ require TestDriver;
9 9  
10 10 my $td = new TestDriver('fuzz');
11 11  
12   -my @files = glob("../qpdf_fuzzer_seed_corpus/*");
13   -my $n_test_files = 27;
  12 +my @files = glob("../build/qpdf_fuzzer_seed_corpus/*");
  13 +my $n_test_files = 29;
14 14 my $n_orig_files = 2559;
15 15 my $n_files = $n_test_files + $n_orig_files;
16 16  
... ...