Branch data Line data Source code
1 : : // Copyright (c) 2011-present 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 : : /**
6 : : * See https://www.boost.org/doc/libs/1_78_0/libs/test/doc/html/boost_test/adv_scenarios/single_header_customizations/multiple_translation_units.html
7 : : */
8 : : // Boost.Test's SIGSTKSZ alternate stack can be smaller than Linux requires on musl.
9 : : #define BOOST_TEST_DISABLE_ALT_STACK
10 : : #define BOOST_TEST_MODULE Bitcoin Core Test Suite
11 : :
12 : : #include <boost/test/included/unit_test.hpp>
13 : :
14 : : #include <test/util/setup_common.h>
15 : :
16 : : #include <functional>
17 : : #include <iostream>
18 : :
19 : : /**
20 : : * Retrieve the command line arguments from boost.
21 : : * Allows usage like:
22 : : * `test_bitcoin --run_test="net_tests/cnode_listen_port" -- -checkaddrman=1 -printtoconsole=1`
23 : : * which would return `["-checkaddrman=1", "-printtoconsole=1"]`.
24 : : */
25 : 728 : const std::function<std::vector<const char*>()> G_TEST_COMMAND_LINE_ARGUMENTS = []() {
26 : 728 : std::vector<const char*> args;
27 [ + - + + ]: 1456 : for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) {
28 [ + - + - ]: 728 : args.push_back(boost::unit_test::framework::master_test_suite().argv[i]);
29 : : }
30 : 728 : return args;
31 : 0 : };
32 : :
33 : : /**
34 : : * Retrieve the boost unit test name.
35 : : */
36 : 728 : const std::function<std::string()> G_TEST_GET_FULL_NAME = []() {
37 : 728 : return boost::unit_test::framework::current_test_case().full_name();
38 : : };
|