Skip to content

Commit 857e917

Browse files
committed
[#3731] Fix fuzzing stalling because it cannot find inputs
Also install fuzzers which will be required for CI
1 parent 2fff27e commit 857e917

File tree

3 files changed

+66
-16
lines changed

3 files changed

+66
-16
lines changed

fuzz/main.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
1+
// Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC")
22
//
33
// This Source Code Form is subject to the terms of the Mozilla Public
44
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -36,7 +36,12 @@ main(int, char* argv[]) {
3636

3737
// Determine some paths.
3838
Path const this_binary(argv[0]);
39-
string const ancestor_path(Path(this_binary.parentPath()).parentPath());
39+
string ancestor_path(this_binary.parentPath());
40+
// TODO: remove kludgy if-condition when autotools gets removed.
41+
if (Path(ancestor_path).filename() == ".libs") {
42+
ancestor_path = Path(ancestor_path).parentPath();
43+
}
44+
cout << ancestor_path << endl;
4045
string const filename(this_binary.filename());
4146
stringstream ss;
4247
ss << ancestor_path << "/input/" << filename;

fuzz/meson.build

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,42 @@ if not FUZZ_OPT.enabled()
22
subdir_done()
33
endif
44

5-
subdir('tests')
5+
current_source_dir = meson.current_source_dir()
6+
list = []
7+
foreach i : [
8+
'fuzz_config_kea_dhcp4',
9+
'fuzz_config_kea_dhcp6',
10+
'fuzz_http_endpoint_kea_dhcp4',
11+
'fuzz_http_endpoint_kea_dhcp6',
12+
'fuzz_packets_kea_dhcp4',
13+
'fuzz_packets_kea_dhcp6',
14+
'fuzz_unix_socket_kea_dhcp4',
15+
'fuzz_unix_socket_kea_dhcp6',
16+
'fuzz_config_kea_dhcp4/doc-examples',
17+
'fuzz_config_kea_dhcp6/doc-examples',
18+
19+
]
20+
command = run_command(
21+
GRABBER,
22+
f'input/@i@',
23+
'*',
24+
check: true,
25+
)
26+
foreach j : command.stdout().strip().split('\n')
27+
# configure_file doesn't work with path segments in the output, so let
28+
# us simulate it with commands.
29+
run_command([f'mkdir', '-p', f'@TOP_BUILD_DIR@/fuzz/input/@i@'], check: true)
30+
run_command([f'cp', f'input/@i@/@j@', f'@TOP_BUILD_DIR@/fuzz/input/@i@/@j@'], check: true)
31+
endforeach
32+
endforeach
633

734
fuzz_sources = ['fuzz.cc', 'fuzz.h']
835
cpp_flags = [
936
f'-DKEA_LFC_INSTALLATION="@KEA_LFC_INSTALLED@"',
1037
f'-DKEA_LFC_SOURCES="@KEA_LFC_BUILT@"',
1138
]
1239
if FUZZING_WITH_CLUSTERFUZZLITE
13-
cpp_flags = ['-fsanitize=fuzzer', '-gdwarf-4']
40+
cpp_flags += ['-fsanitize=fuzzer', '-gdwarf-4']
1441
else
1542
fuzz_sources += ['main.cc']
1643
endif
@@ -34,6 +61,8 @@ executable(
3461
dependencies: [CRYPTO_DEP, GTEST_DEP],
3562
include_directories: includes,
3663
link_with: [dhcp4_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
64+
install: true,
65+
install_dir: SBINDIR,
3766
)
3867

3968
executable(
@@ -44,6 +73,8 @@ executable(
4473
dependencies: [CRYPTO_DEP, GTEST_DEP],
4574
include_directories: includes,
4675
link_with: [dhcp6_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
76+
install: true,
77+
install_dir: SBINDIR,
4778
)
4879

4980
executable(
@@ -54,6 +85,8 @@ executable(
5485
dependencies: [CRYPTO_DEP, GTEST_DEP],
5586
include_directories: includes,
5687
link_with: [dhcp4_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
88+
install: true,
89+
install_dir: SBINDIR,
5790
)
5891

5992
executable(
@@ -64,6 +97,8 @@ executable(
6497
dependencies: [CRYPTO_DEP, GTEST_DEP],
6598
include_directories: includes,
6699
link_with: [dhcp6_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
100+
install: true,
101+
install_dir: SBINDIR,
67102
)
68103

69104
executable(
@@ -74,6 +109,8 @@ executable(
74109
dependencies: [CRYPTO_DEP, GTEST_DEP],
75110
include_directories: includes,
76111
link_with: [dhcp4_lib, kea_dhcpsrv_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
112+
install: true,
113+
install_dir: SBINDIR,
77114
)
78115

79116
executable(
@@ -84,6 +121,8 @@ executable(
84121
dependencies: [CRYPTO_DEP, GTEST_DEP],
85122
include_directories: includes,
86123
link_with: [dhcp6_lib, kea_dhcpsrv_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
124+
install: true,
125+
install_dir: SBINDIR,
87126
)
88127

89128
executable(
@@ -94,6 +133,8 @@ executable(
94133
dependencies: [CRYPTO_DEP, GTEST_DEP],
95134
include_directories: includes,
96135
link_with: [dhcp4_lib, kea_testutils_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
136+
install: true,
137+
install_dir: SBINDIR,
97138
)
98139

99140
executable(
@@ -104,4 +145,8 @@ executable(
104145
dependencies: [CRYPTO_DEP, GTEST_DEP],
105146
include_directories: includes,
106147
link_with: [dhcp6_lib, kea_testutils_lib, fuzz_lib] + LIBS_BUILT_SO_FAR,
148+
install: true,
149+
install_dir: SBINDIR,
107150
)
151+
152+
subdir('tests')

fuzz/tests/meson.build

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
foreach i : [
2-
'test_fuzz_http_endpoint_kea_dhcp4.sh',
3-
'test_fuzz_packets_kea_dhcp6.sh',
4-
'test_fuzz_config_kea_dhcp4.sh',
5-
'test_fuzz_packets_kea_dhcp4.sh',
6-
'test_fuzz_unix_socket_kea_dhcp6.sh',
7-
'test_fuzz_config_kea_dhcp6.sh',
8-
'test_fuzz_unix_socket_kea_dhcp4.sh',
9-
'test_fuzz_http_endpoint_kea_dhcp6.sh',
10-
]
11-
t = configure_file(input: i, output: i, copy: true)
12-
test(i, t)
1+
current_source_dir = meson.current_source_dir()
2+
fuzz_test_scripts = run_command(
3+
GRABBER,
4+
current_source_dir,
5+
'test_fuzz_*.sh',
6+
check: true,
7+
)
8+
fuzz_test_scripts = fuzz_test_scripts.stdout().strip().split('\n')
9+
10+
foreach st : fuzz_test_scripts
11+
bt = configure_file(input: st, output: st, copy: true)
12+
test(st, bt)
1313
endforeach

0 commit comments

Comments
 (0)