66
77
88import common ;
9+ import path ;
10+ import python ;
911import regex ;
12+ import toolset ;
13+
14+ path-constant HERE : . ;
1015
1116local all_fuzzers = [ regex.replace-list
1217 [ glob "fuzz_*.cpp" ] : ".cpp" : ""
1318] ;
1419
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+
1537for local fuzzer in $(all_fuzzers)
1638{
1739 local fuzz_time = 60 ;
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)/*" ] ;
1844
1945 # Create the output corpus directories
20- make /tmp/corpus/$(fuzzer ) : : common.MkDir ;
21- make /tmp/mincorpus/$(fuzzer ) : : common.MkDir ;
46+ make $(corpus ) : $(seed_files) : make-corpus ;
47+ make $(min_corpus ) : : common.MkDir ;
2248
2349 # Build the fuzzer
2450 exe $(fuzzer)
@@ -36,19 +62,20 @@ for local fuzzer in $(all_fuzzers)
3662
3763 # Run the fuzzer for a short while
3864 run $(fuzzer)
39- : <testing.arg>"seedcorpus/$(fuzzer ) -max_total_time=$(fuzz_time)"
65+ : <testing.arg>"$(corpus ) -max_total_time=$(fuzz_time)"
4066 : target-name $(fuzzer)-fuzzing
4167 : requirements
42- <dependency>/tmp/corpus/$(fuzzer )
68+ <dependency>$(corpus )
4369 ;
4470
4571 # Minimize the corpus
4672 run $(fuzzer)
47- : <testing.arg>"/tmp/mincorpus/$(fuzzer) /tmp/corpus/$(fuzzer ) -merge=1"
73+ : <testing.arg>"$(min_corpus) $(corpus ) -merge=1"
4874 : target-name $(fuzzer)-minimize-corpus
4975 : requirements
5076 <dependency>$(fuzzer)-fuzzing
51- <dependency>/tmp/corpus/$(fuzzer )
52- <dependency>/tmp/mincorpus/$(fuzzer )
77+ <dependency>$(corpus )
78+ <dependency>$(min_corpus )
5379 ;
54- }
80+ }
81+
0 commit comments