mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-22 09:57:41 +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
|
// 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
|
// 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.
|
// Determine some paths.
|
||||||
Path const this_binary(argv[0]);
|
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());
|
string const filename(this_binary.filename());
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << ancestor_path << "/input/" << filename;
|
ss << ancestor_path << "/input/" << filename;
|
||||||
|
@ -2,7 +2,34 @@ if not FUZZ_OPT.enabled()
|
|||||||
subdir_done()
|
subdir_done()
|
||||||
endif
|
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']
|
fuzz_sources = ['fuzz.cc', 'fuzz.h']
|
||||||
cpp_flags = [
|
cpp_flags = [
|
||||||
@ -10,7 +37,7 @@ cpp_flags = [
|
|||||||
f'-DKEA_LFC_SOURCES="@KEA_LFC_BUILT@"',
|
f'-DKEA_LFC_SOURCES="@KEA_LFC_BUILT@"',
|
||||||
]
|
]
|
||||||
if FUZZING_WITH_CLUSTERFUZZLITE
|
if FUZZING_WITH_CLUSTERFUZZLITE
|
||||||
cpp_flags = ['-fsanitize=fuzzer', '-gdwarf-4']
|
cpp_flags += ['-fsanitize=fuzzer', '-gdwarf-4']
|
||||||
else
|
else
|
||||||
fuzz_sources += ['main.cc']
|
fuzz_sources += ['main.cc']
|
||||||
endif
|
endif
|
||||||
@ -34,6 +61,8 @@ executable(
|
|||||||
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
||||||
include_directories: includes,
|
include_directories: includes,
|
||||||
link_with: [dhcp4_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
link_with: [dhcp4_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
||||||
|
install: true,
|
||||||
|
install_dir: SBINDIR,
|
||||||
)
|
)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
@ -44,6 +73,8 @@ executable(
|
|||||||
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
||||||
include_directories: includes,
|
include_directories: includes,
|
||||||
link_with: [dhcp6_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
link_with: [dhcp6_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
||||||
|
install: true,
|
||||||
|
install_dir: SBINDIR,
|
||||||
)
|
)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
@ -54,6 +85,8 @@ executable(
|
|||||||
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
||||||
include_directories: includes,
|
include_directories: includes,
|
||||||
link_with: [dhcp4_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
link_with: [dhcp4_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
||||||
|
install: true,
|
||||||
|
install_dir: SBINDIR,
|
||||||
)
|
)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
@ -64,6 +97,8 @@ executable(
|
|||||||
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
||||||
include_directories: includes,
|
include_directories: includes,
|
||||||
link_with: [dhcp6_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
link_with: [dhcp6_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
||||||
|
install: true,
|
||||||
|
install_dir: SBINDIR,
|
||||||
)
|
)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
@ -74,6 +109,8 @@ executable(
|
|||||||
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
||||||
include_directories: includes,
|
include_directories: includes,
|
||||||
link_with: [dhcp4_lib, kea_dhcpsrv_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
link_with: [dhcp4_lib, kea_dhcpsrv_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
||||||
|
install: true,
|
||||||
|
install_dir: SBINDIR,
|
||||||
)
|
)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
@ -84,6 +121,8 @@ executable(
|
|||||||
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
||||||
include_directories: includes,
|
include_directories: includes,
|
||||||
link_with: [dhcp6_lib, kea_dhcpsrv_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
link_with: [dhcp6_lib, kea_dhcpsrv_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
||||||
|
install: true,
|
||||||
|
install_dir: SBINDIR,
|
||||||
)
|
)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
@ -94,6 +133,8 @@ executable(
|
|||||||
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
||||||
include_directories: includes,
|
include_directories: includes,
|
||||||
link_with: [dhcp4_lib, kea_testutils_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
link_with: [dhcp4_lib, kea_testutils_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
||||||
|
install: true,
|
||||||
|
install_dir: SBINDIR,
|
||||||
)
|
)
|
||||||
|
|
||||||
executable(
|
executable(
|
||||||
@ -104,4 +145,8 @@ executable(
|
|||||||
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
dependencies: [CRYPTO_DEP, GTEST_DEP],
|
||||||
include_directories: includes,
|
include_directories: includes,
|
||||||
link_with: [dhcp6_lib, kea_testutils_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
|
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 : [
|
current_source_dir = meson.current_source_dir()
|
||||||
'test_fuzz_http_endpoint_kea_dhcp4.sh',
|
fuzz_test_scripts = run_command(
|
||||||
'test_fuzz_packets_kea_dhcp6.sh',
|
GRABBER,
|
||||||
'test_fuzz_config_kea_dhcp4.sh',
|
current_source_dir,
|
||||||
'test_fuzz_packets_kea_dhcp4.sh',
|
'test_fuzz_*.sh',
|
||||||
'test_fuzz_unix_socket_kea_dhcp6.sh',
|
check: true,
|
||||||
'test_fuzz_config_kea_dhcp6.sh',
|
)
|
||||||
'test_fuzz_unix_socket_kea_dhcp4.sh',
|
fuzz_test_scripts = fuzz_test_scripts.stdout().strip().split('\n')
|
||||||
'test_fuzz_http_endpoint_kea_dhcp6.sh',
|
|
||||||
]
|
foreach st : fuzz_test_scripts
|
||||||
t = configure_file(input: i, output: i, copy: true)
|
bt = configure_file(input: st, output: st, copy: true)
|
||||||
test(i, t)
|
test(st, bt)
|
||||||
endforeach
|
endforeach
|
||||||
|
Loading…
x
Reference in New Issue
Block a user