diff --git a/fuzz/main.cc b/fuzz/main.cc index b9445d6f90..fdb7d68057 100644 --- a/fuzz/main.cc +++ b/fuzz/main.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -36,7 +36,12 @@ main(int, char* argv[]) { // Determine some paths. Path const this_binary(argv[0]); - string const ancestor_path(Path(this_binary.parentPath()).parentPath()); + string ancestor_path(this_binary.parentPath()); + // TODO: remove kludgy if-condition when autotools gets removed. + if (Path(ancestor_path).filename() == ".libs") { + ancestor_path = Path(ancestor_path).parentPath(); + } + cout << ancestor_path << endl; string const filename(this_binary.filename()); stringstream ss; ss << ancestor_path << "/input/" << filename; diff --git a/fuzz/meson.build b/fuzz/meson.build index 3886616ccd..1eb3025eaf 100644 --- a/fuzz/meson.build +++ b/fuzz/meson.build @@ -2,7 +2,34 @@ if not FUZZ_OPT.enabled() subdir_done() endif -subdir('tests') +current_source_dir = meson.current_source_dir() +list = [] +foreach i : [ + 'fuzz_config_kea_dhcp4', + 'fuzz_config_kea_dhcp6', + 'fuzz_http_endpoint_kea_dhcp4', + 'fuzz_http_endpoint_kea_dhcp6', + 'fuzz_packets_kea_dhcp4', + 'fuzz_packets_kea_dhcp6', + 'fuzz_unix_socket_kea_dhcp4', + 'fuzz_unix_socket_kea_dhcp6', + 'fuzz_config_kea_dhcp4/doc-examples', + 'fuzz_config_kea_dhcp6/doc-examples', + +] + command = run_command( + GRABBER, + f'input/@i@', + '*', + check: true, + ) + foreach j : command.stdout().strip().split('\n') + # configure_file doesn't work with path segments in the output, so let + # us simulate it with commands. + run_command([f'mkdir', '-p', f'@TOP_BUILD_DIR@/fuzz/input/@i@'], check: true) + run_command([f'cp', f'input/@i@/@j@', f'@TOP_BUILD_DIR@/fuzz/input/@i@/@j@'], check: true) + endforeach +endforeach fuzz_sources = ['fuzz.cc', 'fuzz.h'] cpp_flags = [ @@ -10,7 +37,7 @@ cpp_flags = [ f'-DKEA_LFC_SOURCES="@KEA_LFC_BUILT@"', ] if FUZZING_WITH_CLUSTERFUZZLITE - cpp_flags = ['-fsanitize=fuzzer', '-gdwarf-4'] + cpp_flags += ['-fsanitize=fuzzer', '-gdwarf-4'] else fuzz_sources += ['main.cc'] endif @@ -34,6 +61,8 @@ executable( dependencies: [CRYPTO_DEP, GTEST_DEP], include_directories: includes, link_with: [dhcp4_lib, fuzz_lib] + LIBS_BUILT_SO_FAR, + install: true, + install_dir: SBINDIR, ) executable( @@ -44,6 +73,8 @@ executable( dependencies: [CRYPTO_DEP, GTEST_DEP], include_directories: includes, link_with: [dhcp6_lib, fuzz_lib] + LIBS_BUILT_SO_FAR, + install: true, + install_dir: SBINDIR, ) executable( @@ -54,6 +85,8 @@ executable( dependencies: [CRYPTO_DEP, GTEST_DEP], include_directories: includes, link_with: [dhcp4_lib, fuzz_lib] + LIBS_BUILT_SO_FAR, + install: true, + install_dir: SBINDIR, ) executable( @@ -64,6 +97,8 @@ executable( dependencies: [CRYPTO_DEP, GTEST_DEP], include_directories: includes, link_with: [dhcp6_lib, fuzz_lib] + LIBS_BUILT_SO_FAR, + install: true, + install_dir: SBINDIR, ) executable( @@ -74,6 +109,8 @@ executable( dependencies: [CRYPTO_DEP, GTEST_DEP], include_directories: includes, link_with: [dhcp4_lib, kea_dhcpsrv_lib, fuzz_lib] + LIBS_BUILT_SO_FAR, + install: true, + install_dir: SBINDIR, ) executable( @@ -84,6 +121,8 @@ executable( dependencies: [CRYPTO_DEP, GTEST_DEP], include_directories: includes, link_with: [dhcp6_lib, kea_dhcpsrv_lib, fuzz_lib] + LIBS_BUILT_SO_FAR, + install: true, + install_dir: SBINDIR, ) executable( @@ -94,6 +133,8 @@ executable( dependencies: [CRYPTO_DEP, GTEST_DEP], include_directories: includes, link_with: [dhcp4_lib, kea_testutils_lib, fuzz_lib] + LIBS_BUILT_SO_FAR, + install: true, + install_dir: SBINDIR, ) executable( @@ -104,4 +145,8 @@ executable( dependencies: [CRYPTO_DEP, GTEST_DEP], include_directories: includes, link_with: [dhcp6_lib, kea_testutils_lib, fuzz_lib] + LIBS_BUILT_SO_FAR, + install: true, + install_dir: SBINDIR, ) + +subdir('tests') diff --git a/fuzz/tests/meson.build b/fuzz/tests/meson.build index b9084099df..7f5c561334 100644 --- a/fuzz/tests/meson.build +++ b/fuzz/tests/meson.build @@ -1,13 +1,13 @@ -foreach i : [ - 'test_fuzz_http_endpoint_kea_dhcp4.sh', - 'test_fuzz_packets_kea_dhcp6.sh', - 'test_fuzz_config_kea_dhcp4.sh', - 'test_fuzz_packets_kea_dhcp4.sh', - 'test_fuzz_unix_socket_kea_dhcp6.sh', - 'test_fuzz_config_kea_dhcp6.sh', - 'test_fuzz_unix_socket_kea_dhcp4.sh', - 'test_fuzz_http_endpoint_kea_dhcp6.sh', -] - t = configure_file(input: i, output: i, copy: true) - test(i, t) +current_source_dir = meson.current_source_dir() +fuzz_test_scripts = run_command( + GRABBER, + current_source_dir, + 'test_fuzz_*.sh', + check: true, +) +fuzz_test_scripts = fuzz_test_scripts.stdout().strip().split('\n') + +foreach st : fuzz_test_scripts + bt = configure_file(input: st, output: st, copy: true) + test(st, bt) endforeach