diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-11-18 22:43:22 +0000 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-11-18 22:43:22 +0000 |
| commit | e01637fd3a0a59ffea320a7df9770e73f486c91e (patch) | |
| tree | fa76152764a7a53a0f6dab21585064e14406a07a | |
| parent | e0cc7f6a03008f623d3286678f6dc22f8cebef51 (diff) | |
| download | gentoo-utils-e01637fd3a0a59ffea320a7df9770e73f486c91e.tar.gz | |
setup meson to allow building multiple fuzzers easily
| -rw-r--r-- | Cargo.toml | 8 | ||||
| -rw-r--r-- | fuzz/atom/meson.build | 1 | ||||
| -rw-r--r-- | fuzz/atom/parser/fuzz.rs (renamed from fuzz/fuzz.rs) | 0 | ||||
| -rw-r--r-- | fuzz/atom/parser/gencorpus.rs (renamed from fuzz/gencorpus.rs) | 0 | ||||
| -rw-r--r-- | fuzz/atom/parser/meson.build | 6 | ||||
| -rw-r--r-- | fuzz/meson.build | 95 |
6 files changed, 68 insertions, 42 deletions
@@ -13,9 +13,9 @@ thiserror = "2.0.17" debug = true [[bin]] -path = "fuzz/gencorpus.rs" -name = "gencorpus" +path = "fuzz/atom/parser/gencorpus.rs" +name = "atom_parser_gencorpus" [[test]] -path = "fuzz/fuzz.rs" -name = "fuzz"
\ No newline at end of file +path = "fuzz/atom/parser/fuzz.rs" +name = "atom_parser_fuzz"
\ No newline at end of file diff --git a/fuzz/atom/meson.build b/fuzz/atom/meson.build new file mode 100644 index 0000000..57b0131 --- /dev/null +++ b/fuzz/atom/meson.build @@ -0,0 +1 @@ +subdir('parser') diff --git a/fuzz/fuzz.rs b/fuzz/atom/parser/fuzz.rs index 610e08b..610e08b 100644 --- a/fuzz/fuzz.rs +++ b/fuzz/atom/parser/fuzz.rs diff --git a/fuzz/gencorpus.rs b/fuzz/atom/parser/gencorpus.rs index 67ba1e3..67ba1e3 100644 --- a/fuzz/gencorpus.rs +++ b/fuzz/atom/parser/gencorpus.rs diff --git a/fuzz/atom/parser/meson.build b/fuzz/atom/parser/meson.build new file mode 100644 index 0000000..efc84c6 --- /dev/null +++ b/fuzz/atom/parser/meson.build @@ -0,0 +1,6 @@ +fuzzers += { + 'atom_parser': [ + meson.current_source_dir() / 'gencorpus.rs', + meson.current_source_dir() / 'fuzz.rs', + ], +} diff --git a/fuzz/meson.build b/fuzz/meson.build index c7652aa..1b61551 100644 --- a/fuzz/meson.build +++ b/fuzz/meson.build @@ -1,40 +1,59 @@ cbindgen = find_program('cbindgen') -gencorpus = executable( - 'gencorpus', - 'gencorpus.rs', - dependencies: [mon], - link_with: [gentoo_utils], -) - -corpus_directory = meson.current_build_dir() / 'corpus' - -corpus = custom_target( - 'corpus', - output: 'corpus', - command: [gencorpus, corpus_directory], -) - -fuzz_h = custom_target( - 'fuzz_h', - input: 'fuzz.rs', - output: 'fuzz.h', - command: [cbindgen, '@INPUT@', '-o', '@OUTPUT'], -) - -fuzz_rs = static_library( - '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]) - -test('fuzz', fuzz, args: [corpus_directory], depends: [corpus], timeout: 0) +fuzzers = {} + +subdir('atom') + +foreach fuzzer, sources : fuzzers + gencorpus_rs = sources[0] + fuzz_rs = sources[1] + + gencorpus = executable( + fuzzer + '_' + 'gencorpus', + gencorpus_rs, + dependencies: [mon], + link_with: [gentoo_utils], + ) + + corpus_directory = fuzzer + '_' + 'corpus' + + corpus = custom_target( + fuzzer + '_' + 'corpus', + output: fuzzer + '_' + 'corpus', + command: [gencorpus, corpus_directory], + ) + + 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 |
