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 : : #define BOOST_TEST_MODULE Bitcoin Core Test Suite
9 : :
10 : : #include <boost/test/included/unit_test.hpp>
11 : :
12 : : #include <test/util/setup_common.h>
13 : :
14 : : #include <functional>
15 : : #include <iostream>
16 : :
17 : : /**
18 : : * Retrieve the command line arguments from boost.
19 : : * Allows usage like:
20 : : * `test_bitcoin --run_test="net_tests/cnode_listen_port" -- -checkaddrman=1 -printtoconsole=1`
21 : : * which would return `["-checkaddrman=1", "-printtoconsole=1"]`.
22 : : */
23 : 654 : const std::function<std::vector<const char*>()> G_TEST_COMMAND_LINE_ARGUMENTS = []() {
24 : 654 : std::vector<const char*> args;
25 [ + - + + ]: 1308 : for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) {
26 [ + - + - ]: 654 : args.push_back(boost::unit_test::framework::master_test_suite().argv[i]);
27 : : }
28 : 654 : return args;
29 : 0 : };
30 : :
31 : : /**
32 : : * Retrieve the boost unit test name.
33 : : */
34 : 654 : const std::function<std::string()> G_TEST_GET_FULL_NAME = []() {
35 : 654 : return boost::unit_test::framework::current_test_case().full_name();
36 : : };
|