forked from gentoo-utils/gentoo-utils
setup meson to allow building multiple fuzzers easily
This commit is contained in:
@@ -13,9 +13,9 @@ thiserror = "2.0.17"
|
|||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
path = "fuzz/gencorpus.rs"
|
path = "fuzz/atom/parser/gencorpus.rs"
|
||||||
name = "gencorpus"
|
name = "atom_parser_gencorpus"
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
path = "fuzz/fuzz.rs"
|
path = "fuzz/atom/parser/fuzz.rs"
|
||||||
name = "fuzz"
|
name = "atom_parser_fuzz"
|
||||||
1
fuzz/atom/meson.build
Normal file
1
fuzz/atom/meson.build
Normal file
@@ -0,0 +1 @@
|
|||||||
|
subdir('parser')
|
||||||
6
fuzz/atom/parser/meson.build
Normal file
6
fuzz/atom/parser/meson.build
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
fuzzers += {
|
||||||
|
'atom_parser': [
|
||||||
|
meson.current_source_dir() / 'gencorpus.rs',
|
||||||
|
meson.current_source_dir() / 'fuzz.rs',
|
||||||
|
],
|
||||||
|
}
|
||||||
@@ -1,40 +1,59 @@
|
|||||||
cbindgen = find_program('cbindgen')
|
cbindgen = find_program('cbindgen')
|
||||||
|
|
||||||
gencorpus = executable(
|
fuzzers = {}
|
||||||
'gencorpus',
|
|
||||||
'gencorpus.rs',
|
|
||||||
dependencies: [mon],
|
|
||||||
link_with: [gentoo_utils],
|
|
||||||
)
|
|
||||||
|
|
||||||
corpus_directory = meson.current_build_dir() / 'corpus'
|
subdir('atom')
|
||||||
|
|
||||||
corpus = custom_target(
|
foreach fuzzer, sources : fuzzers
|
||||||
'corpus',
|
gencorpus_rs = sources[0]
|
||||||
output: 'corpus',
|
fuzz_rs = sources[1]
|
||||||
command: [gencorpus, corpus_directory],
|
|
||||||
)
|
|
||||||
|
|
||||||
fuzz_h = custom_target(
|
gencorpus = executable(
|
||||||
'fuzz_h',
|
fuzzer + '_' + 'gencorpus',
|
||||||
input: 'fuzz.rs',
|
gencorpus_rs,
|
||||||
output: 'fuzz.h',
|
dependencies: [mon],
|
||||||
command: [cbindgen, '@INPUT@', '-o', '@OUTPUT'],
|
link_with: [gentoo_utils],
|
||||||
)
|
)
|
||||||
|
|
||||||
fuzz_rs = static_library(
|
corpus_directory = fuzzer + '_' + 'corpus'
|
||||||
'fuzz_rs',
|
|
||||||
'fuzz.rs',
|
|
||||||
rust_abi: 'c',
|
|
||||||
rust_args: [
|
|
||||||
'-Cpasses=sancov-module',
|
|
||||||
'-Cllvm-args=-sanitizer-coverage-level=3',
|
|
||||||
'-Cllvm-args=-sanitizer-coverage-inline-8bit-counters',
|
|
||||||
],
|
|
||||||
dependencies: [mon],
|
|
||||||
link_with: [gentoo_utils],
|
|
||||||
)
|
|
||||||
|
|
||||||
fuzz = executable('fuzz', link_args: ['-fsanitize=fuzzer'], link_with: [fuzz_rs])
|
corpus = custom_target(
|
||||||
|
fuzzer + '_' + 'corpus',
|
||||||
|
output: fuzzer + '_' + 'corpus',
|
||||||
|
command: [gencorpus, corpus_directory],
|
||||||
|
)
|
||||||
|
|
||||||
test('fuzz', fuzz, args: [corpus_directory], depends: [corpus], timeout: 0)
|
fuzz_h = custom_target(
|
||||||
|
fuzzer + '_' + 'fuzz_h',
|
||||||
|
input: fuzz_rs,
|
||||||
|
output: fuzzer + '_' + 'fuzz.h',
|
||||||
|
command: [cbindgen, '@INPUT@', '-o', '@OUTPUT'],
|
||||||
|
)
|
||||||
|
|
||||||
|
fuzz_rs = static_library(
|
||||||
|
fuzzer + '.rs',
|
||||||
|
fuzz_rs,
|
||||||
|
rust_abi: 'c',
|
||||||
|
rust_args: [
|
||||||
|
'-Cpasses=sancov-module',
|
||||||
|
'-Cllvm-args=-sanitizer-coverage-level=3',
|
||||||
|
'-Cllvm-args=-sanitizer-coverage-inline-8bit-counters',
|
||||||
|
],
|
||||||
|
dependencies: [mon],
|
||||||
|
link_with: [gentoo_utils],
|
||||||
|
)
|
||||||
|
|
||||||
|
fuzz = executable(
|
||||||
|
fuzzer + '_' + 'fuzzer',
|
||||||
|
link_args: ['-fsanitize=fuzzer'],
|
||||||
|
link_with: [fuzz_rs],
|
||||||
|
)
|
||||||
|
|
||||||
|
test(
|
||||||
|
fuzzer + '_' + 'fuzz',
|
||||||
|
fuzz,
|
||||||
|
args: [corpus_directory],
|
||||||
|
depends: [corpus],
|
||||||
|
timeout: 0,
|
||||||
|
)
|
||||||
|
endforeach
|
||||||
|
|||||||
Reference in New Issue
Block a user