build: Add option --enable-danger-fuzz-link-all

This commit is contained in:
MarcoFalke 2020-12-14 15:52:39 +01:00
parent 44444ba759
commit fa13e1b0c5
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
4 changed files with 42 additions and 1 deletions

View file

@ -7,7 +7,7 @@ setup:
- sudo apt-get update
- sudo apt-get install -y autoconf bsdmainutils clang git libboost-all-dev libboost-program-options-dev libc++1 libc++abi1 libc++abi-dev libc++-dev libclang1 libclang-dev libdb5.3++ libevent-dev libllvm-ocaml-dev libomp5 libomp-dev libprotobuf-dev libqt5core5a libqt5dbus5 libqt5gui5 libssl-dev libtool llvm llvm-dev llvm-runtime pkg-config protobuf-compiler qttools5-dev qttools5-dev-tools software-properties-common
- ./autogen.sh
- CC=clang CXX=clang++ ./configure --enable-fuzz --with-sanitizers=address,fuzzer,undefined
- CC=clang CXX=clang++ ./configure --enable-fuzz --with-sanitizers=address,fuzzer,undefined --enable-danger-fuzz-link-all
- make
- git clone https://github.com/bitcoin-core/qa-assets
auto_targets:

View file

@ -167,6 +167,12 @@ AC_ARG_ENABLE([fuzz],
[enable_fuzz=$enableval],
[enable_fuzz=no])
AC_ARG_ENABLE([danger_fuzz_link_all],
AS_HELP_STRING([--enable-danger-fuzz-link-all],
[Danger! Modifies source code. Needs git and gnu sed installed. Link each fuzz target (default no).]),
[enable_danger_fuzz_link_all=$enableval],
[enable_danger_fuzz_link_all=no])
AC_ARG_WITH([qrencode],
[AS_HELP_STRING([--with-qrencode],
[enable QR code support (default is yes if qt is enabled and libqrencode is found)])],
@ -1612,6 +1618,7 @@ AM_CONDITIONAL([USE_SQLITE], [test "x$use_sqlite" = "xyes"])
AM_CONDITIONAL([USE_BDB], [test "x$use_bdb" = "xyes"])
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
AM_CONDITIONAL([ENABLE_FUZZ],[test x$enable_fuzz = xyes])
AM_CONDITIONAL([ENABLE_FUZZ_LINK_ALL],[test x$enable_danger_fuzz_link_all = xyes])
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
AM_CONDITIONAL([ENABLE_BENCH],[test x$use_bench = xyes])

View file

@ -10,6 +10,7 @@ endif
TEST_SRCDIR = test
TEST_BINARY=test/test_bitcoin$(EXEEXT)
FUZZ_BINARY=test/fuzz/fuzz$(EXEEXT)
JSON_TEST_FILES = \
test/data/script_tests.json \
@ -320,6 +321,11 @@ if EMBEDDED_UNIVALUE
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
endif
if ENABLE_FUZZ_LINK_ALL
all-local: $(FUZZ_BINARY)
bash ./test/fuzz/danger_link_all.sh
endif
%.cpp.test: %.cpp
@echo Running tests: `cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1` from $<
$(AM_V_at)$(TEST_BINARY) --catch_system_errors=no -l test_suite -t "`cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1`" -- DEBUG_LOG_OUT > $<.log 2>&1 || (cat $<.log && false)

View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Copyright (c) 2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL=C.UTF-8
set -e
ROOT_DIR="$(git rev-parse --show-toplevel)"
# Run only once (break make recursion)
if [ -d "${ROOT_DIR}/lock_fuzz_link_all" ]; then
exit
fi
mkdir "${ROOT_DIR}/lock_fuzz_link_all"
echo "Linking each fuzz target separately."
for FUZZING_HARNESS in $(PRINT_ALL_FUZZ_TARGETS_AND_ABORT=1 "${ROOT_DIR}/src/test/fuzz/fuzz" | sort -u); do
echo "Building src/test/fuzz/${FUZZING_HARNESS} ..."
git checkout -- "${ROOT_DIR}/src/test/fuzz/fuzz.cpp"
sed -i "s/std::getenv(\"FUZZ\")/\"${FUZZING_HARNESS}\"/g" "${ROOT_DIR}/src/test/fuzz/fuzz.cpp"
make
mv "${ROOT_DIR}/src/test/fuzz/fuzz" "${ROOT_DIR}/src/test/fuzz/${FUZZING_HARNESS}"
done
git checkout -- "${ROOT_DIR}/src/test/fuzz/fuzz.cpp"
rmdir "${ROOT_DIR}/lock_fuzz_link_all"
echo "Successfully built all fuzz targets."