From 424bd9d0720e3752c6ff252c6eb0a3425109b765 Mon Sep 17 00:00:00 2001 From: John Turner Date: Sun, 16 Nov 2025 20:31:19 +0000 Subject: [PATCH] move fuzz stuff into its own directory --- Cargo.toml | 6 +++++- {tests => fuzz}/fuzz.rs | 0 fuzz/meson.build | 27 +++++++++++++++++++++++++++ meson.build | 4 +++- tests/meson.build | 28 +--------------------------- 5 files changed, 36 insertions(+), 29 deletions(-) rename {tests => fuzz}/fuzz.rs (100%) create mode 100644 fuzz/meson.build diff --git a/Cargo.toml b/Cargo.toml index 345c08d..bcb32da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,4 +10,8 @@ itertools = "0.14.0" thiserror = "2.0.17" [profile.dev] -debug = true \ No newline at end of file +debug = true + +[[test]] +path = "fuzz/fuzz.rs" +name = "fuzz" \ No newline at end of file diff --git a/tests/fuzz.rs b/fuzz/fuzz.rs similarity index 100% rename from tests/fuzz.rs rename to fuzz/fuzz.rs diff --git a/fuzz/meson.build b/fuzz/meson.build new file mode 100644 index 0000000..c4b5e8d --- /dev/null +++ b/fuzz/meson.build @@ -0,0 +1,27 @@ +cbindgen = find_program('cbindgen') + +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_cpp = executable( + 'fuzz', + link_args: ['-fsanitize=fuzzer'], + link_with: [fuzz_rs], +) diff --git a/meson.build b/meson.build index ac6d6af..401adf6 100644 --- a/meson.build +++ b/meson.build @@ -19,4 +19,6 @@ gentoo_utils = static_library( link_with: [thiserror], ) -subdir('tests') +if get_option('fuzz').enabled() + subdir('fuzz') +endif diff --git a/tests/meson.build b/tests/meson.build index c4b5e8d..69052cd 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,27 +1 @@ -cbindgen = find_program('cbindgen') - -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_cpp = executable( - 'fuzz', - link_args: ['-fsanitize=fuzzer'], - link_with: [fuzz_rs], -) +subdir('fuzz')