Skip to content

Commit e51f6c4

Browse files
author
MarcoFalke
committed
Merge #20936: build: build fuzz tests by default
32cbb06 build: build fuzz tests by default. (Dan Benjamin) Pull request description: This fixes issue #19388. The changes are as follows: - Add a new flag to configure, --enable-fuzz-binary, which allows building test/fuzz/fuzz regardless of whether we are building to do actual fuzzing - Set -DPROVIDE_MAIN_FUNCTION whenever --enable-fuzz is no - Add the following libraries to FUZZ_SUITE_LD_COMMON: - LIBBITCOIN_WALLET - SQLLITE_LIBS - BDB_LIBS - if necessary, some or all of: - NATPMP_LIBS - MINIUPNPC_LIBS - LIBBITCOIN_ZMQ / ZMQ_LIBS Fixes #19388 ACKs for top commit: MarcoFalke: review ACK 32cbb06 📭 Tree-SHA512: c91d713ffe54a3d055daaec02c4317d7e13eed6688821ddc10d894224950b18e276fbdd4acc758c7103b50f34a132b1882b68bc8b60409f97438e0759ced77e1
2 parents 8636288 + 32cbb06 commit e51f6c4

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

ci/test/00_setup_env_native_qt5.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ export RUN_UNIT_TESTS_SEQUENTIAL="true"
1616
export RUN_UNIT_TESTS="false"
1717
export GOAL="install"
1818
export PREVIOUS_RELEASES_TO_DOWNLOAD="v0.15.2 v0.16.3 v0.17.2 v0.18.1 v0.19.1"
19-
export BITCOIN_CONFIG="--enable-zmq --with-libs=no --with-gui=qt5 --enable-glibc-back-compat --enable-reduce-exports --enable-debug CFLAGS=\"-g0 -O2 -funsigned-char\" CXXFLAGS=\"-g0 -O2 -funsigned-char\" --with-boost-process"
19+
export BITCOIN_CONFIG="--enable-zmq --with-libs=no --with-gui=qt5 --enable-glibc-back-compat --enable-reduce-exports
20+
--enable-debug --disable-fuzz-binary CFLAGS=\"-g0 -O2 -funsigned-char\" CXXFLAGS=\"-g0 -O2 -funsigned-char\" --with-boost-process"

ci/test/00_setup_env_win64.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export PACKAGES="python3 nsis g++-mingw-w64-x86-64 wine-binfmt wine64 file"
1313
export RUN_FUNCTIONAL_TESTS=false
1414
export RUN_SECURITY_TESTS="true"
1515
export GOAL="deploy"
16-
export BITCOIN_CONFIG="--enable-reduce-exports --disable-gui-tests --without-boost-process"
16+
export BITCOIN_CONFIG="--enable-reduce-exports --disable-fuzz-binary --disable-gui-tests --without-boost-process"
1717

1818
# Compiler for MinGW-w64 causes false -Wreturn-type warning.
1919
# See https://sourceforge.net/p/mingw-w64/bugs/306/

configure.ac

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,16 @@ AC_ARG_ENABLE([extended-functional-tests],
184184

185185
AC_ARG_ENABLE([fuzz],
186186
AS_HELP_STRING([--enable-fuzz],
187-
[enable building of fuzz targets (default no). enabling this will disable all other targets]),
187+
[build for fuzzing (default no). enabling this will disable all other targets and override --{enable,disable}-fuzz-binary]),
188188
[enable_fuzz=$enableval],
189189
[enable_fuzz=no])
190190

191+
AC_ARG_ENABLE([fuzz-binary],
192+
AS_HELP_STRING([--enable-fuzz-binary],
193+
[enable building of fuzz binary (default yes).]),
194+
[enable_fuzz_binary=$enableval],
195+
[enable_fuzz_binary=yes])
196+
191197
AC_ARG_ENABLE([danger_fuzz_link_all],
192198
AS_HELP_STRING([--enable-danger-fuzz-link-all],
193199
[Danger! Modifies source code. Needs git and gnu sed installed. Link each fuzz target (default no).]),
@@ -1227,7 +1233,7 @@ AC_DEFUN([SUPPRESS_WARNINGS],
12271233

12281234
dnl enable-fuzz should disable all other targets
12291235
if test "x$enable_fuzz" = "xyes"; then
1230-
AC_MSG_WARN(enable-fuzz will disable all other targets)
1236+
AC_MSG_WARN(enable-fuzz will disable all other targets and force --enable-fuzz-binary=yes)
12311237
build_bitcoin_utils=no
12321238
build_bitcoin_cli=no
12331239
build_bitcoin_tx=no
@@ -1243,10 +1249,11 @@ if test "x$enable_fuzz" = "xyes"; then
12431249
use_upnp=no
12441250
use_natpmp=no
12451251
use_zmq=no
1252+
enable_fuzz_binary=yes
12461253

12471254
AX_CHECK_PREPROC_FLAG([-DABORT_ON_FAILED_ASSUME],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DABORT_ON_FAILED_ASSUME"]],,[[$CXXFLAG_WERROR]])
12481255

1249-
AC_MSG_CHECKING([whether main function is needed])
1256+
AC_MSG_CHECKING([whether main function is needed for fuzz binary])
12501257
AX_CHECK_LINK_FLAG(
12511258
[[-fsanitize=$use_sanitizers]],
12521259
[AC_MSG_RESULT([no])],
@@ -1274,6 +1281,8 @@ else
12741281
QT_DBUS_INCLUDES=SUPPRESS_WARNINGS($QT_DBUS_INCLUDES)
12751282
QT_TEST_INCLUDES=SUPPRESS_WARNINGS($QT_TEST_INCLUDES)
12761283
fi
1284+
1285+
CPPFLAGS="$CPPFLAGS -DPROVIDE_MAIN_FUNCTION"
12771286
fi
12781287

12791288
if test x$enable_wallet != xno; then
@@ -1719,6 +1728,7 @@ AM_CONDITIONAL([USE_BDB], [test "x$use_bdb" = "xyes"])
17191728
AM_CONDITIONAL([ENABLE_TRACING],[test x$have_sdt = xyes])
17201729
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
17211730
AM_CONDITIONAL([ENABLE_FUZZ],[test x$enable_fuzz = xyes])
1731+
AM_CONDITIONAL([ENABLE_FUZZ_BINARY],[test x$enable_fuzz_binary = xyes])
17221732
AM_CONDITIONAL([ENABLE_FUZZ_LINK_ALL],[test x$enable_danger_fuzz_link_all = xyes])
17231733
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
17241734
AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
@@ -1735,6 +1745,8 @@ AM_CONDITIONAL([ENABLE_SHANI],[test x$enable_shani = xyes])
17351745
AM_CONDITIONAL([ENABLE_ARM_CRC],[test x$enable_arm_crc = xyes])
17361746
AM_CONDITIONAL([USE_ASM],[test x$use_asm = xyes])
17371747
AM_CONDITIONAL([WORDS_BIGENDIAN],[test x$ac_cv_c_bigendian = xyes])
1748+
AM_CONDITIONAL([USE_NATPMP],[test x$use_natpmp = xyes])
1749+
AM_CONDITIONAL([USE_UPNP],[test x$use_upnp = xyes])
17381750

17391751
AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
17401752
AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])

src/Makefile.test.include

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
# Distributed under the MIT software license, see the accompanying
33
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
if ENABLE_FUZZ
5+
if ENABLE_FUZZ_BINARY
66
noinst_PROGRAMS += test/fuzz/fuzz
7-
else
7+
endif
8+
9+
if !ENABLE_FUZZ
810
bin_PROGRAMS += test/test_bitcoin
911
endif
1012

@@ -50,6 +52,14 @@ FUZZ_SUITE_LD_COMMON = \
5052
$(EVENT_LIBS) \
5153
$(EVENT_PTHREADS_LIBS)
5254

55+
if USE_UPNP
56+
FUZZ_SUITE_LD_COMMON += $(MINIUPNPC_LIBS)
57+
endif
58+
59+
if USE_NATPMP
60+
FUZZ_SUITE_LD_COMMON += $(NATPMP_LIBS)
61+
endif
62+
5363
# test_bitcoin binary #
5464
BITCOIN_TESTS =\
5565
test/arith_uint256_tests.cpp \
@@ -145,10 +155,16 @@ BITCOIN_TESTS += \
145155
wallet/test/ismine_tests.cpp \
146156
wallet/test/scriptpubkeyman_tests.cpp
147157

158+
FUZZ_SUITE_LD_COMMON +=\
159+
$(LIBBITCOIN_WALLET) \
160+
$(SQLITE_LIBS) \
161+
$(BDB_LIBS)
162+
148163
if USE_BDB
149164
BITCOIN_TESTS += wallet/test/db_tests.cpp
150165
endif
151166

167+
152168
BITCOIN_TEST_SUITE += \
153169
wallet/test/wallet_test_fixture.cpp \
154170
wallet/test/wallet_test_fixture.h \
@@ -172,12 +188,12 @@ test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(
172188

173189
if ENABLE_ZMQ
174190
test_test_bitcoin_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
191+
FUZZ_SUITE_LD_COMMON += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
175192
endif
176193

177-
if ENABLE_FUZZ
178-
179194
FUZZ_SUITE_LDFLAGS_COMMON = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS)
180195

196+
if ENABLE_FUZZ_BINARY
181197
test_fuzz_fuzz_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
182198
test_fuzz_fuzz_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
183199
test_fuzz_fuzz_LDADD = $(FUZZ_SUITE_LD_COMMON)
@@ -278,8 +294,7 @@ test_fuzz_fuzz_SOURCES = \
278294
test/fuzz/tx_in.cpp \
279295
test/fuzz/tx_out.cpp \
280296
test/fuzz/txrequest.cpp
281-
282-
endif # ENABLE_FUZZ
297+
endif # ENABLE_FUZZ_BINARY
283298

284299
nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES)
285300

0 commit comments

Comments
 (0)