Skip to content

Commit e2e48e0

Browse files
committed
refactor fuzzing jobs
1 parent a6fbf10 commit e2e48e0

18 files changed

+37
-33
lines changed

.github/workflows/run_fuzzer.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ jobs:
2323
id: cache-corpus
2424
with:
2525
path: head/fuzzing/corpus.tar
26-
key: corpus-${{ github.run_id }}
27-
restore-keys: corpus-
26+
key: corpus
2827
- name: Install packages
2928
shell: bash
3029
run: |
@@ -55,6 +54,9 @@ jobs:
5554
ls -al /usr/lib/llvm-18/lib/clang/18/lib/linux/"$(basename ${f%.*})"-x86_64.a
5655
done
5756
fi
57+
- name: Check fuzzing dir
58+
run: |
59+
ls -al fuzzing/
5860
- uses: ./head/.github/actions/build
5961
with:
6062
buildtype: 'boost'
@@ -63,9 +65,11 @@ jobs:
6365
cxxstd: 17
6466
targets: libs/json/fuzzing//run
6567
- name: Pack the corpus
66-
working-directory: boost-root/libs/json/fuzzing/
68+
working-directory: boost-root/libs/json/fuzzing/cmin
6769
run: |
68-
tar cf - cmin > corpus.tar.tmp && mv corpus.tar.tmp "${GITHUB_WORKSPACE}"/head/fuzzing
70+
tar cf - * > "$GITHUB_WORKSPACE"/head/fuzzing/corpus.tar
71+
ls -al .
72+
tar -tf "$GITHUB_WORKSPACE"/head/fuzzing/corpus.tar
6973
- name: Save the corpus as a github artifact
7074
uses: actions/upload-artifact@v4
7175
if: success()

fuzzing/Jamfile

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,31 @@ import testing ;
3939
] ;
4040

4141
local corpus.tar = [ glob-ex . : corpus.tar ] ;
42+
local test-corpus ;
4243
if $(corpus.tar)
4344
{
4445
# if an old corpus exists, use it
45-
# get it with curl -O --location -J https://bintray.com/pauldreik/boost.json/download_file?file_path=corpus%2Fcorpus.tar
4646
make old-corpus
4747
: $(corpus.tar)
4848
: @untar-corpus
4949
: <location>oldcorpus
5050
;
51+
explicit old-corpus ;
5152
}
5253
else
5354
{
54-
alias old-corpus ;
55+
test-corpus = [ glob-tree-ex ../test : *.json ] ;
5556
}
56-
explicit old-corpus ;
57-
58-
59-
local initial-corpus = [ glob-tree-ex ../test : *.json ] ;
6057

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

6262
local variants = basic_parser parse parser direct_parse ;
6363
for local variant in basic_parser parse parser direct_parse
6464
{
6565
local $(variant)-runs ;
6666
local fuzzer = fuzzer_$(variant) ;
67-
lib $(fuzzer) : fuzz_$(variant).cpp /boost/json//boost_json ;
6867
exe $(fuzzer)
6968
: fuzz_$(variant).cpp /boost/json//json_sources
7069
: requirements
@@ -73,44 +72,44 @@ for local variant in basic_parser parse parser direct_parse
7372
;
7473

7574
# make sure the old crashes pass without problems
76-
local old-runs = [ glob-tree-ex old_crashes/$(variant) : * ] ;
7775
if $(old-runs)
7876
{
7977
run $(fuzzer)
8078
: target-name $(variant)-run-crashes
81-
: input-files [ SORT $(old-runs) ]
79+
: input-files $(old-runs)
8280
;
81+
explicit $(variant)-run-crashes ;
8382
$(variant)-runs += $(variant)-run-crashes ;
8483
}
8584

86-
make oldcorpus/$(variant)
87-
: old-corpus
88-
: common.MkDir
89-
: <location>.
90-
;
91-
explicit oldcorpus/$(variant) ;
92-
93-
# make an initial corpus from the test data already in the repo
94-
local seed-corpus ;
95-
for file in $(initial-corpus)
85+
local old-corpus-deps ;
86+
if $(corpus.tar)
9687
{
97-
local copied = $(variant)/$(file:D=) ;
98-
make $(copied) : $(file) : common.copy : <location>seedcorpus ;
99-
explicit $(copied) ;
100-
seed-corpus += $(copied) ;
88+
old-corpus-deps = old-corpus ;
10189
}
102-
make seedcorpus/$(variant)
103-
: $(seed-corpus)
90+
else
91+
{
92+
# make an initial corpus from the test data already in the repo
93+
for file in $(test-corpus)
94+
{
95+
local copied = $(variant)/$(file:D=) ;
96+
make $(copied) : $(file) : common.copy : <location>oldcorpus ;
97+
explicit $(copied) ;
98+
old-corpus-deps += $(copied) ;
99+
}
100+
}
101+
make oldcorpus/$(variant)
102+
: $(old-corpus-deps)
104103
: common.MkDir
105104
: <location>.
106105
;
107-
explicit seedcorpus/$(variant) ;
106+
explicit oldcorpus/$(variant) ;
108107

109108
# run the fuzzer for a short while
110109
make out/$(variant)
111110
: $(fuzzer)
112111
oldcorpus/$(variant)
113-
seedcorpus/$(variant)
112+
old_crashes
114113
: @run-fuzzer
115114
: <location>.
116115
<flags>$(.MAXTIME)
@@ -122,8 +121,9 @@ for local variant in basic_parser parse parser direct_parse
122121
# minimize the corpus
123122
make cmin/$(variant)
124123
: $(fuzzer)
125-
oldcorpus/$(variant)
126124
out/$(variant)
125+
oldcorpus/$(variant)
126+
old_crashes
127127
: @run-fuzzer
128128
: <location>.
129129
<flags>-merge=1
@@ -178,7 +178,7 @@ rule run-fuzzer ( target : sources * : props * )
178178
actions run-fuzzer
179179
{
180180
$(.UBSAN_OPTIONS)
181-
$(>[1]) $(<) $(>[2]) $(>[3]) $(FLAGS)
181+
$(>[1]) $(<) $(>[2-]) $(FLAGS)
182182
}
183183

184184
.TOUCH_FILE = [ common.file-touch-command ] ;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)