mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-22 01:49:48 +00:00
[#3731] Fix fuzzing stalling because it cannot find inputs
Also install fuzzers which will be required for CI
This commit is contained in:
parent
2fff27e274
commit
857e917dad
@ -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;
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user