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,8 +22,10 @@ $(BINS_fuzz): $(TARGETS_libqpdf) $(OBJ_DEFAULT_FUZZ)
22 # Files from the test suite that are good for seeding the fuzzer. 22 # Files from the test suite that are good for seeding the fuzzer.
23 # Update $n_test_files in qtest/fuzz.test if you change this list. 23 # Update $n_test_files in qtest/fuzz.test if you change this list.
24 SEED_CORPUS_FILES = \ 24 SEED_CORPUS_FILES = \
  25 + stream-data.pdf \
  26 + lin5.pdf \
25 field-types.pdf \ 27 field-types.pdf \
26 - image-streams.pdf \ 28 + image-streams-small.pdf \
27 need-appearances.pdf \ 29 need-appearances.pdf \
28 outlines-with-actions.pdf \ 30 outlines-with-actions.pdf \
29 outlines-with-old-root-dests.pdf \ 31 outlines-with-old-root-dests.pdf \
@@ -53,7 +55,7 @@ SEED_CORPUS_FILES = \ @@ -53,7 +55,7 @@ SEED_CORPUS_FILES = \
53 # ----- 55 # -----
54 56
55 CORPUS_FROM_TEST := $(foreach F,$(SEED_CORPUS_FILES),qpdf/qtest/qpdf/$F) 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 .PHONY: fuzz_corpus 60 .PHONY: fuzz_corpus
59 fuzz_corpus:: fuzz/$(OUTPUT_DIR)/fuzz_corpus.stamp 61 fuzz_corpus:: fuzz/$(OUTPUT_DIR)/fuzz_corpus.stamp
@@ -68,7 +70,7 @@ $(foreach F,$(CORPUS_FROM_TEST),$(eval \ @@ -68,7 +70,7 @@ $(foreach F,$(CORPUS_FROM_TEST),$(eval \
68 70
69 fuzz/$(OUTPUT_DIR)/fuzz_corpus.stamp: fuzz/original-corpus.tar.gz $(CORPUS_FROM_TEST) 71 fuzz/$(OUTPUT_DIR)/fuzz_corpus.stamp: fuzz/original-corpus.tar.gz $(CORPUS_FROM_TEST)
70 mkdir -p $(CORPUS_DIR) 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 touch $@ 74 touch $@
73 75
74 $(foreach B,$(FUZZERS),$(eval \ 76 $(foreach B,$(FUZZERS),$(eval \
@@ -122,9 +124,11 @@ install_fuzz: $(STATIC_BINS_fuzz) @@ -122,9 +124,11 @@ install_fuzz: $(STATIC_BINS_fuzz)
122 mkdir -p $(OUT) 124 mkdir -p $(OUT)
123 cp fuzz/pdf.dict $(STATIC_BINS_fuzz) $(OUT)/ 125 cp fuzz/pdf.dict $(STATIC_BINS_fuzz) $(OUT)/
124 for B in $(FUZZERS); do \ 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 fi; \ 132 fi; \
129 done 133 done
130 134
fuzz/options renamed to fuzz/qpdf_fuzzer.options
fuzz/qtest/fuzz.test
@@ -9,8 +9,8 @@ require TestDriver; @@ -9,8 +9,8 @@ require TestDriver;
9 9
10 my $td = new TestDriver('fuzz'); 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 my $n_orig_files = 2559; 14 my $n_orig_files = 2559;
15 my $n_files = $n_test_files + $n_orig_files; 15 my $n_files = $n_test_files + $n_orig_files;
16 16