Skip to content

Commit

Permalink
Update jamfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Jan 15, 2025
1 parent e3a1ee1 commit a8475b9
Showing 1 changed file with 37 additions and 22 deletions.
59 changes: 37 additions & 22 deletions fuzzing/Jamfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,52 @@
#
# Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
# Copyright (c) 2024 Matt Borland
# Copyright (c) 2025 Alexander Grund
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt.
#

import common ;
import path ;
import python ;
import regex ;
import toolset ;

path-constant HERE : . ;

local all_fuzzers = [ regex.replace-list
[ glob "fuzz_*.cpp" ] : ".cpp" : ""
] ;

if ! [ python.configured ]
{
using python ;
}

.make-corpus-script = $(HERE)/make-corpus.py ;

rule make-corpus ( target : sources + : properties * )
{
RUNNER on $(target) = [ path.native $(.make-corpus-script) ] ;
}
actions make-corpus
{
"$(PYTHON:E=python)" "$(RUNNER)" $(<) $(>)
}
toolset.flags $(__name__).make-corpus PYTHON <python.interpreter> ;

for local fuzzer in $(all_fuzzers)
{
# These two fuzzers are the most complex ones. The rest are really
# simple, so less time is enough
local fuzz_time = 30 ;
local fuzz_time = 60 ;
local corpus = /tmp/corpus/$(fuzzer) ;
local min_corpus = /tmp/mincorpus/$(fuzzer) ;
local seed_corpus = $(HERE)/seedcorpus/$(fuzzer) ;
local seed_files = [ glob "$(seed_corpus)/*" ] ;

# Create the output corpus directories
make /tmp/corpus/$(fuzzer) : : common.MkDir ;
make /tmp/mincorpus/$(fuzzer) : : common.MkDir ;
make $(corpus) : $(seed_files) : make-corpus ;
make $(min_corpus) : : common.MkDir ;

# Build the fuzzer
exe $(fuzzer)
Expand All @@ -37,31 +62,21 @@ for local fuzzer in $(all_fuzzers)
<library>/boost/charconv//boost_charconv
;

# Make sure that any old crashes are run without problems
local old_crashes = [ glob-tree-ex old_crashes/$(fuzzer) : * ] ;
if $(old_crashes)
{
run $(fuzzer)
: target-name $(fuzzer)-old-crashes
: input-files [ SORT $(old_crashes) ]
;
}

# Run the fuzzer for a short while
run $(fuzzer)
: <testing.arg>"seedcorpus/$(fuzzer) -max_total_time=$(fuzz_time)"
: <testing.arg>"$(corpus) -max_total_time=$(fuzz_time)"
: target-name $(fuzzer)-fuzzing
: requirements
<dependency>/tmp/corpus/$(fuzzer)
<dependency>$(corpus)
;

# Minimize the corpus
run $(fuzzer)
: <testing.arg>"/tmp/mincorpus/$(fuzzer) /tmp/corpus/$(fuzzer) -merge=1"
: <testing.arg>"$(min_corpus) $(corpus) -merge=1"
: target-name $(fuzzer)-minimize-corpus
: requirements
<dependency>$(fuzzer)-fuzzing
<dependency>/tmp/corpus/$(fuzzer)
<dependency>/tmp/mincorpus/$(fuzzer)
<dependency>$(corpus)
<dependency>$(min_corpus)
;
}

0 comments on commit a8475b9

Please sign in to comment.