1+ #
2+ # Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
13# Copyright (c) 2024 Matt Borland
2- # Copyright (c) 2025 Alexander Grund
34#
4- # Distributed under the Boost Software License, Version 1.0.
5- # https ://www.boost.org/LICENSE_1_0.txt.
6-
5+ # Distributed under the Boost Software License, Version 1.0. (See accompanying
6+ # file LICENSE_1_0.txt or copy at http ://www.boost.org/LICENSE_1_0.txt)
7+ #
78
89import common ;
9- import path ;
10- import python ;
1110import regex ;
12- import toolset ;
13-
14- path-constant HERE : . ;
1511
1612local all_fuzzers = [ regex.replace-list
1713 [ glob "fuzz_*.cpp" ] : ".cpp" : ""
1814] ;
1915
20- if ! [ python.configured ]
21- {
22- using python ;
23- }
24-
25- .make-corpus-script = $(HERE)/make-corpus.py ;
26-
27- rule make-corpus ( target : sources + : properties * )
28- {
29- RUNNER on $(target) = [ path.native $(.make-corpus-script) ] ;
30- }
31- actions make-corpus
32- {
33- "$(PYTHON:E=python)" "$(RUNNER)" $(<) $(>)
34- }
35- toolset.flags $(__name__).make-corpus PYTHON <python.interpreter> ;
36-
3716for local fuzzer in $(all_fuzzers)
3817{
18+ # These two fuzzers are the most complex ones. The rest are really
19+ # simple, so less time is enough
3920 local fuzz_time = 30 ;
40- local corpus = /tmp/corpus/$(fuzzer) ;
41- local min_corpus = /tmp/mincorpus/$(fuzzer) ;
42- local seed_corpus = $(HERE)/seedcorpus/$(fuzzer) ;
43- local seed_files = [ glob "$(seed_corpus)/*" ] ;
4421
4522 # Create the output corpus directories
46- make $(corpus ) : $(seed_files) : make-corpus ;
47- make $(min_corpus ) : : common.MkDir ;
23+ make /tmp/corpus/$(fuzzer ) : : common.MkDir ;
24+ make /tmp/mincorpus/$(fuzzer ) : : common.MkDir ;
4825
4926 # Build the fuzzer
5027 exe $(fuzzer)
@@ -59,21 +36,31 @@ for local fuzzer in $(all_fuzzers)
5936 <linkflags>-fsanitize=fuzzer
6037 ;
6138
39+ # Make sure that any old crashes are run without problems
40+ local old_crashes = [ glob-tree-ex old_crashes/$(fuzzer) : * ] ;
41+ if $(old_crashes)
42+ {
43+ run $(fuzzer)
44+ : target-name $(fuzzer)-old-crashes
45+ : input-files [ SORT $(old_crashes) ]
46+ ;
47+ }
48+
6249 # Run the fuzzer for a short while
6350 run $(fuzzer)
64- : <testing.arg>"$(corpus ) -max_total_time=$(fuzz_time)"
51+ : <testing.arg>"seedcorpus/$(fuzzer ) -max_total_time=$(fuzz_time)"
6552 : target-name $(fuzzer)-fuzzing
6653 : requirements
67- <dependency>$(corpus )
54+ <dependency>/tmp/corpus/$(fuzzer )
6855 ;
6956
7057 # Minimize the corpus
7158 run $(fuzzer)
72- : <testing.arg>"$(min_corpus) $(corpus ) -merge=1"
59+ : <testing.arg>"/tmp/mincorpus/$(fuzzer) /tmp/corpus/$(fuzzer ) -merge=1"
7360 : target-name $(fuzzer)-minimize-corpus
7461 : requirements
7562 <dependency>$(fuzzer)-fuzzing
76- <dependency>$(corpus )
77- <dependency>$(min_corpus )
63+ <dependency>/tmp/corpus/$(fuzzer )
64+ <dependency>/tmp/mincorpus/$(fuzzer )
7865 ;
7966}
0 commit comments