Skip to content

Commit b983e7e

Browse files
author
MarcoFalke
committed
Merge bitcoin#17542: build: Create test utility library from src/test/util/
a2e581d build: Create test utility library from src/test/util/ (Harris) Pull request description: This PR creates a static **test utility library** that replaces repetitive compilations of sources from *src/test/util* in **unit**, **gui** and **bench** **tests**. The original issue is here: bitcoin#17401 The changes are: * a new *Makefile.test_util.include* * a new entry in *Makefile.am* that includes *Makefile.test_util.include* when testing is enabled * removal of all *src/test/util* headers & sources from unit, gui and bench Makefiles * addition of *libtest_util.a* at LDADD's of every test ACKs for top commit: MarcoFalke: ACK a2e581d 🍞 Tree-SHA512: d172127a26ee70d16625e17d7d94337a65472c57bb97f910c357c52d3dc082ea478ee586ee9074d9ebfeb05b75027e5e15f5bcd2aa35962dadfd9ac6bfd55ab9
2 parents a739d20 + a2e581d commit b983e7e

5 files changed

+40
-30
lines changed

src/Makefile.am

+2
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,8 @@ if EMBEDDED_LEVELDB
717717
include Makefile.leveldb.include
718718
endif
719719

720+
include Makefile.test_util.include
721+
720722
if ENABLE_TESTS
721723
include Makefile.test.include
722724
endif

src/Makefile.bench.include

+1-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ bench_bench_bitcoin_SOURCES = \
4040
bench/lockedpool.cpp \
4141
bench/poly1305.cpp \
4242
bench/prevector.cpp \
43-
test/util/transaction_utils.h \
44-
test/util/transaction_utils.cpp \
45-
test/util/setup_common.h \
46-
test/util/setup_common.cpp \
4743
test/util.h \
4844
test/util.cpp
4945

@@ -59,6 +55,7 @@ bench_bench_bitcoin_LDADD = \
5955
$(LIBBITCOIN_UTIL) \
6056
$(LIBBITCOIN_CONSENSUS) \
6157
$(LIBBITCOIN_CRYPTO) \
58+
$(LIBTEST_UTIL) \
6259
$(LIBLEVELDB) \
6360
$(LIBLEVELDB_SSE42) \
6461
$(LIBMEMENV) \

src/Makefile.qttest.include

+2-10
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ TEST_QT_H = \
2626
qt/test/util.h \
2727
qt/test/wallettests.h
2828

29-
TEST_BITCOIN_CPP = \
30-
test/util/setup_common.cpp
31-
32-
TEST_BITCOIN_H = \
33-
test/util/setup_common.h
34-
3529
qt_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \
3630
$(QT_INCLUDES) $(QT_TEST_INCLUDES)
3731

@@ -42,9 +36,7 @@ qt_test_test_bitcoin_qt_SOURCES = \
4236
qt/test/test_main.cpp \
4337
qt/test/uritests.cpp \
4438
qt/test/util.cpp \
45-
$(TEST_QT_H) \
46-
$(TEST_BITCOIN_CPP) \
47-
$(TEST_BITCOIN_H)
39+
$(TEST_QT_H)
4840
if ENABLE_WALLET
4941
qt_test_test_bitcoin_qt_SOURCES += \
5042
qt/test/addressbooktests.cpp \
@@ -54,7 +46,7 @@ endif # ENABLE_WALLET
5446

5547
nodist_qt_test_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP)
5648

57-
qt_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER)
49+
qt_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER) $(LIBTEST_UTIL)
5850
if ENABLE_WALLET
5951
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_UTIL) $(LIBBITCOIN_WALLET)
6052
endif

src/Makefile.test.include

+4-16
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,19 @@ RAW_TEST_FILES =
5858
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)
5959

6060
BITCOIN_TEST_SUITE = \
61-
test/util/blockfilter.cpp \
62-
test/util/blockfilter.h \
63-
test/util/logging.cpp \
64-
test/util/logging.h \
65-
test/util/transaction_utils.cpp \
66-
test/util/transaction_utils.h \
6761
test/main.cpp \
68-
test/util/setup_common.h \
69-
test/util/setup_common.cpp \
70-
test/util/str.h \
71-
test/util/str.cpp
62+
$(TEST_UTIL_H)
7263

7364
FUZZ_SUITE = \
7465
test/fuzz/fuzz.cpp \
7566
test/fuzz/fuzz.h \
76-
test/fuzz/FuzzedDataProvider.h \
77-
test/util/setup_common.cpp \
78-
test/util/setup_common.h \
79-
test/util/str.cpp \
80-
test/util/str.h
67+
test/fuzz/FuzzedDataProvider.h
8168

8269
FUZZ_SUITE_LD_COMMON = \
8370
$(LIBBITCOIN_SERVER) \
8471
$(LIBBITCOIN_COMMON) \
8572
$(LIBBITCOIN_UTIL) \
73+
$(LIBTEST_UTIL) \
8674
$(LIBBITCOIN_CONSENSUS) \
8775
$(LIBBITCOIN_CRYPTO) \
8876
$(LIBUNIVALUE) \
@@ -198,7 +186,7 @@ endif
198186

199187
test_test_bitcoin_SOURCES = $(BITCOIN_TEST_SUITE) $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
200188
test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(TESTDEFS) $(EVENT_CFLAGS)
201-
test_test_bitcoin_LDADD =
189+
test_test_bitcoin_LDADD = $(LIBTEST_UTIL)
202190
if ENABLE_WALLET
203191
test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
204192
endif

src/Makefile.test_util.include

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) 2013-2019 The Bitcoin Core developers
2+
# Distributed under the MIT software license, see the accompanying
3+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
LIBTEST_UTIL=libtest_util.a
6+
7+
EXTRA_LIBRARIES += \
8+
$(LIBTEST_UTIL)
9+
10+
TEST_UTIL_H = \
11+
test/util/blockfilter.h \
12+
test/util/logging.h \
13+
test/util/setup_common.h \
14+
test/util/str.h \
15+
test/util/transaction_utils.h
16+
17+
libtest_util_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS)
18+
libtest_util_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
19+
libtest_util_a_SOURCES = \
20+
test/util/blockfilter.cpp \
21+
test/util/logging.cpp \
22+
test/util/setup_common.cpp \
23+
test/util/str.cpp \
24+
test/util/transaction_utils.cpp \
25+
$(TEST_UTIL_H)
26+
27+
LIBTEST_UTIL += $(LIBBITCOIN_SERVER)
28+
LIBTEST_UTIL += $(LIBBITCOIN_COMMON)
29+
LIBTEST_UTIL += $(LIBBITCOIN_UTIL)
30+
LIBTEST_UTIL += $(LIBBITCOIN_CRYPTO_BASE)
31+

0 commit comments

Comments
 (0)