Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/run_fuzzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ jobs:
id: cache-corpus
with:
path: head/fuzzing/corpus.tar
key: corpus-${{ github.run_id }}
restore-keys: corpus-
key: corpus
- name: Install packages
shell: bash
run: |
Expand Down Expand Up @@ -55,6 +54,9 @@ jobs:
ls -al /usr/lib/llvm-18/lib/clang/18/lib/linux/"$(basename ${f%.*})"-x86_64.a
done
fi
- name: Check fuzzing dir
run: |
ls -al head/fuzzing/
- uses: ./head/.github/actions/build
with:
buildtype: 'boost'
Expand All @@ -63,9 +65,11 @@ jobs:
cxxstd: 17
targets: libs/json/fuzzing//run
- name: Pack the corpus
working-directory: boost-root/libs/json/fuzzing/
working-directory: boost-root/libs/json/fuzzing/cmin
run: |
tar cf - cmin > corpus.tar.tmp && mv corpus.tar.tmp "${GITHUB_WORKSPACE}"/head/fuzzing
tar cf - * > "$GITHUB_WORKSPACE"/head/fuzzing/corpus.tar
ls -al .
tar -tf "$GITHUB_WORKSPACE"/head/fuzzing/corpus.tar
- name: Save the corpus as a github artifact
uses: actions/upload-artifact@v4
if: success()
Expand Down
58 changes: 29 additions & 29 deletions fuzzing/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,31 @@ import testing ;
] ;

local corpus.tar = [ glob-ex . : corpus.tar ] ;
local test-corpus ;
if $(corpus.tar)
{
# if an old corpus exists, use it
# get it with curl -O --location -J https://bintray.com/pauldreik/boost.json/download_file?file_path=corpus%2Fcorpus.tar
make old-corpus
: $(corpus.tar)
: @untar-corpus
: <location>oldcorpus
;
explicit old-corpus ;
}
else
{
alias old-corpus ;
test-corpus = [ glob-tree-ex ../test : *.json ] ;
}
explicit old-corpus ;


local initial-corpus = [ glob-tree-ex ../test : *.json ] ;

local old-runs = [ SORT [ glob-tree-ex old_crashes : * ] ] ;
make old_crashes : : common.MkDir : <location>. ;
explicit old_crashes ;

local variants = basic_parser parse parser direct_parse ;
for local variant in basic_parser parse parser direct_parse
{
local $(variant)-runs ;
local fuzzer = fuzzer_$(variant) ;
lib $(fuzzer) : fuzz_$(variant).cpp /boost/json//boost_json ;
exe $(fuzzer)
: fuzz_$(variant).cpp /boost/json//json_sources
: requirements
Expand All @@ -73,44 +72,44 @@ for local variant in basic_parser parse parser direct_parse
;

# make sure the old crashes pass without problems
local old-runs = [ glob-tree-ex old_crashes/$(variant) : * ] ;
if $(old-runs)
{
run $(fuzzer)
: target-name $(variant)-run-crashes
: input-files [ SORT $(old-runs) ]
: input-files $(old-runs)
;
explicit $(variant)-run-crashes ;
$(variant)-runs += $(variant)-run-crashes ;
}

make oldcorpus/$(variant)
: old-corpus
: common.MkDir
: <location>.
;
explicit oldcorpus/$(variant) ;

# make an initial corpus from the test data already in the repo
local seed-corpus ;
for file in $(initial-corpus)
local old-corpus-deps ;
if $(corpus.tar)
{
local copied = $(variant)/$(file:D=) ;
make $(copied) : $(file) : common.copy : <location>seedcorpus ;
explicit $(copied) ;
seed-corpus += $(copied) ;
old-corpus-deps = old-corpus ;
}
make seedcorpus/$(variant)
: $(seed-corpus)
else
{
# make an initial corpus from the test data already in the repo
for file in $(test-corpus)
{
local copied = $(variant)/$(file:D=) ;
make $(copied) : $(file) : common.copy : <location>oldcorpus ;
explicit $(copied) ;
old-corpus-deps += $(copied) ;
}
}
make oldcorpus/$(variant)
: $(old-corpus-deps)
: common.MkDir
: <location>.
;
explicit seedcorpus/$(variant) ;
explicit oldcorpus/$(variant) ;

# run the fuzzer for a short while
make out/$(variant)
: $(fuzzer)
oldcorpus/$(variant)
seedcorpus/$(variant)
old_crashes
: @run-fuzzer
: <location>.
<flags>$(.MAXTIME)
Expand All @@ -122,8 +121,9 @@ for local variant in basic_parser parse parser direct_parse
# minimize the corpus
make cmin/$(variant)
: $(fuzzer)
oldcorpus/$(variant)
out/$(variant)
oldcorpus/$(variant)
old_crashes
: @run-fuzzer
: <location>.
<flags>-merge=1
Expand Down Expand Up @@ -178,7 +178,7 @@ rule run-fuzzer ( target : sources * : props * )
actions run-fuzzer
{
$(.UBSAN_OPTIONS)
$(>[1]) $(<) $(>[2]) $(>[3]) $(FLAGS)
$(>[1]) $(<) $(>[2-]) $(FLAGS)
}

.TOUCH_FILE = [ common.file-touch-command ] ;
Expand Down
File renamed without changes.
Loading