Skip to content

Commit

Permalink
Merge bitcoin#22086: test: remove BasicTestingSetup from unit tests t…
Browse files Browse the repository at this point in the history
…hat don't need it

6c3fcd5 test: remove BasicTestingSetup from util_threadnames unit tests (fanquake)
b53d3c1 test: remove BasicTestingSetup from uint256 unit tests (fanquake)
c0497a4 test: remove BasicTestingSetup from torcontrol unit tests (fanquake)
ef8bb04 test: remove BasicTestingSetup from sync unit tests (fanquake)
1aee834 test: remove BasicTestingSetup from reverse_lock unit tests (fanquake)
57ba949 test: remove BasicTestingSetup from policy_fee unit tests (fanquake)
3974c96 test: remove BasicTestingSetup from merkleblock tests (fanquake)
cd5bc4b test: remove BasicTestingSetup from hash unit tests (fanquake)
39cec22 test: remove BasicTestingSetup from compilerbug unit tests (fanquake)
6d3b78c test: remove BasicTestingSetup from bswap unit tests (fanquake)
a13dc24 test: remove BasicTestingSetup from bech32 unit tests (fanquake)
f4dcbe4 test: remove BasicTestingSetup from base64 unit tests (fanquake)
fd144f6 test: remove BasicTestingSetup from base32 unit tests (fanquake)
4c389ba test: remove BasicTestingSetup from arith_uint256 unit tests (fanquake)
0559065 test: remove BasicTestingSetup from amount unit tests (fanquake)
883a5c7 test: remove BasicTestingSetup from allocator unit tests (fanquake)

Pull request description:

  * Less setup/overhead for tests that don't need it. Some naive bench-marking would suggest that a full `test_bitcoin` run is a few % faster after this change.
  * Tests which don't need the BasicTestingSetup can't accidentally end up depending on it somehow.
  * Already the case in at least the scheduler and block_filter tests.

  This adds missing includes, but more significant is the removal of `setup_common.h` from tests where it isn't needed. This saves recompiling those tests when changes are made in the header.

ACKs for top commit:
  practicalswift:
    cr ACK 6c3fcd5: patch looks correct
  laanwj:
    ACK 6c3fcd5

Tree-SHA512: 69b891e2b4740402d62b86a4fc98c329a432d125971342a6f97334e166b3537ed3d4cdbb2531fa05c1feae32339c9fcb2dceda9afeeaed4edc70e8caa0962161
  • Loading branch information
laanwj authored and PastaPastaPasta committed Mar 4, 2024
1 parent 2793865 commit ec8e45b
Show file tree
Hide file tree
Showing 21 changed files with 44 additions and 40 deletions.
9 changes: 6 additions & 3 deletions src/test/allocator_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <support/lockedpool.h>

#include <test/util/setup_common.h>

#include <limits>
#include <memory>
#include <stdexcept>
#include <utility>
#include <vector>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(allocator_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(allocator_tests)

BOOST_AUTO_TEST_CASE(arena_tests)
{
Expand Down
5 changes: 3 additions & 2 deletions src/test/amount_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

#include <amount.h>
#include <policy/feerate.h>
#include <test/util/setup_common.h>

#include <limits>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(amount_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(amount_tests)

BOOST_AUTO_TEST_CASE(MoneyRangeTest)
{
Expand Down
6 changes: 3 additions & 3 deletions src/test/arith_uint256_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <arith_uint256.h>
#include <test/util/setup_common.h>
#include <uint256.h>

#include <boost/test/unit_test.hpp>

#include <cmath>
#include <cstdint>
#include <iomanip>
#include <limits>
#include <sstream>
#include <stdint.h>
#include <string>
#include <vector>

BOOST_FIXTURE_TEST_SUITE(arith_uint256_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(arith_uint256_tests)

/// Convert vector to arith_uint256, via uint256 blob
static inline arith_uint256 arith_uint256V(const std::vector<unsigned char>& vch)
Expand Down
3 changes: 1 addition & 2 deletions src/test/base32_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <test/util/setup_common.h>
#include <util/strencodings.h>

#include <boost/test/unit_test.hpp>
#include <string>

using namespace std::literals;

BOOST_FIXTURE_TEST_SUITE(base32_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(base32_tests)

BOOST_AUTO_TEST_CASE(base32_testvectors)
{
Expand Down
4 changes: 2 additions & 2 deletions src/test/base58_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <test/data/base58_encode_decode.json.h>

#include <base58.h>
#include <test/util/setup_common.h>
#include <test/util/setup_common.h> // for InsecureRand*
#include <util/strencodings.h>
#include <util/vector.h>

Expand All @@ -18,7 +18,7 @@ using namespace std::literals;

extern UniValue read_json(const std::string& jsondata);

BOOST_FIXTURE_TEST_SUITE(base58_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(base58_tests)

// Goal: test low-level base58 encoding functionality
BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
Expand Down
3 changes: 1 addition & 2 deletions src/test/base64_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <test/util/setup_common.h>
#include <util/strencodings.h>

#include <boost/test/unit_test.hpp>
#include <string>

using namespace std::literals;

BOOST_FIXTURE_TEST_SUITE(base64_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(base64_tests)

BOOST_AUTO_TEST_CASE(base64_testvectors)
{
Expand Down
5 changes: 3 additions & 2 deletions src/test/bech32_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <bech32.h>
#include <test/util/setup_common.h>
#include <test/util/str.h>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(bech32_tests, BasicTestingSetup)
#include <string>

BOOST_AUTO_TEST_SUITE(bech32_tests)

BOOST_AUTO_TEST_CASE(bip173_testvectors_valid)
{
Expand Down
3 changes: 1 addition & 2 deletions src/test/bls_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
#include <clientversion.h>
#include <random.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <util/irange.h>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(bls_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(bls_tests)

void FuncSign(const bool legacy_scheme)
{
Expand Down
3 changes: 1 addition & 2 deletions src/test/bswap_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <compat/byteswap.h>
#include <test/util/setup_common.h>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(bswap_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(bswap_tests)

BOOST_AUTO_TEST_CASE(bswap_tests)
{
Expand Down
4 changes: 2 additions & 2 deletions src/test/cachemap_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include <cachemap.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <version.h>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(cachemap_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(cachemap_tests)

static bool Compare(const CacheMap<int,int>& cmap1, const CacheMap<int,int>& cmap2)
{
Expand Down
4 changes: 2 additions & 2 deletions src/test/cachemultimap_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

#include <cachemultimap.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <version.h>

#include <algorithm>
#include <iostream>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(cachemultimap_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(cachemultimap_tests)

static bool Compare(const CacheMultiMap<int,int>& cmmap1, const CacheMultiMap<int,int>& cmmap2)
{
Expand Down
3 changes: 1 addition & 2 deletions src/test/compilerbug_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <boost/test/unit_test.hpp>
#include <test/util/setup_common.h>

BOOST_FIXTURE_TEST_SUITE(compilerbug_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(compilerbug_tests)

#if defined(__GNUC__)
// This block will also be built under clang, which is fine (as it supports noinline)
Expand Down
4 changes: 1 addition & 3 deletions src/test/dip0020opcodes_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
#include <policy/policy.h>
#include <script/interpreter.h>

#include <test/util/setup_common.h>

#include <boost/test/unit_test.hpp>

#include <array>

using valtype = std::vector<uint8_t>;
using stacktype = std::vector<valtype>;

BOOST_FIXTURE_TEST_SUITE(dip0020opcodes_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(dip0020opcodes_tests)

std::array<uint32_t, 2> flagset{{0, STANDARD_SCRIPT_VERIFY_FLAGS}};

Expand Down
2 changes: 1 addition & 1 deletion src/test/hash_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(hash_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(hash_tests)

BOOST_AUTO_TEST_CASE(murmurhash3)
{
Expand Down
4 changes: 3 additions & 1 deletion src/test/merkleblock_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

#include <boost/test/unit_test.hpp>

#include <set>
#include <vector>

BOOST_FIXTURE_TEST_SUITE(merkleblock_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(merkleblock_tests)

/**
* Create a CMerkleBlock using a list of txids which will be found in the
Expand Down
5 changes: 3 additions & 2 deletions src/test/ratecheck_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

#include <governance/governance.h>

#include <test/util/setup_common.h>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(ratecheck_tests, BasicTestingSetup)
#include <cmath>

BOOST_AUTO_TEST_SUITE(ratecheck_tests)

BOOST_AUTO_TEST_CASE(ratecheck_test)
{
Expand Down
4 changes: 3 additions & 1 deletion src/test/reverselock_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(reverselock_tests, BasicTestingSetup)
#include <stdexcept>

BOOST_AUTO_TEST_SUITE(reverselock_tests)

BOOST_AUTO_TEST_CASE(reverselock_basics)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/sync_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <boost/test/unit_test.hpp>

#include <mutex>
#include <stdexcept>

namespace {
template <typename MutexType>
Expand Down Expand Up @@ -76,7 +77,7 @@ void TestDoubleLock(bool should_throw)
#endif /* DEBUG_LOCKORDER */
} // namespace

BOOST_FIXTURE_TEST_SUITE(sync_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(sync_tests)

BOOST_AUTO_TEST_CASE(potential_deadlock_detected)
{
Expand Down
3 changes: 1 addition & 2 deletions src/test/torcontrol_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//
#include <test/util/setup_common.h>

#include <boost/test/unit_test.hpp>

Expand All @@ -15,7 +14,7 @@ std::pair<std::string, std::string> SplitTorReplyLine(const std::string& s);
std::map<std::string, std::string> ParseTorReplyMapping(const std::string& s);


BOOST_FIXTURE_TEST_SUITE(torcontrol_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(torcontrol_tests)

static void CheckSplitTorReplyLine(std::string input, std::string command, std::string args)
{
Expand Down
3 changes: 2 additions & 1 deletion src/test/uint256_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>

BOOST_FIXTURE_TEST_SUITE(uint256_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(uint256_tests)

const unsigned char R1Array[] =
"\x9c\x52\x4a\xdb\xcf\x56\x11\x12\x2b\x29\x12\x5e\x5d\x35\xd2\xd2"
Expand Down
4 changes: 2 additions & 2 deletions src/test/util_threadnames_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <test/util/setup_common.h>
#include <util/string.h>
#include <util/threadnames.h>

#include <mutex>
#include <set>
#include <string>
#include <thread>
#include <vector>

Expand All @@ -17,7 +17,7 @@

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(util_threadnames_tests, BasicTestingSetup)
BOOST_AUTO_TEST_SUITE(util_threadnames_tests)

const std::string TEST_THREAD_NAME_BASE = "test_thread.";

Expand Down

0 comments on commit ec8e45b

Please sign in to comment.