LCOV - code coverage report
Current view: top level - src/test - main.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 82.4 % 17 14
Test Date: 2024-08-28 04:44:32 Functions: 100.0 % 3 3
Branches: 59.1 % 22 13

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2011-2022 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                 :             : /** Redirect debug log to unit_test.log files */
      18                 :      298233 : const std::function<void(const std::string&)> G_TEST_LOG_FUN = [](const std::string& s) {
      19                 :      298433 :     static const bool should_log{std::any_of(
      20         [ +  - ]:         100 :         &boost::unit_test::framework::master_test_suite().argv[1],
      21   [ +  -  +  -  :         100 :         &boost::unit_test::framework::master_test_suite().argv[boost::unit_test::framework::master_test_suite().argc],
                   +  - ]
      22                 :         100 :         [](const char* arg) {
      23                 :         100 :             return std::string{"DEBUG_LOG_OUT"} == arg;
      24   [ +  +  +  - ]:      298333 :         })};
      25         [ +  - ]:      298233 :     if (!should_log) return;
      26                 :      298233 :     std::cout << s;
      27                 :             : };
      28                 :             : 
      29                 :             : /**
      30                 :             :  * Retrieve the command line arguments from boost.
      31                 :             :  * Allows usage like:
      32                 :             :  * `test_bitcoin --run_test="net_tests/cnode_listen_port" -- -checkaddrman=1 -printtoconsole=1`
      33                 :             :  * which would return `["-checkaddrman=1", "-printtoconsole=1"]`.
      34                 :             :  */
      35                 :         583 : const std::function<std::vector<const char*>()> G_TEST_COMMAND_LINE_ARGUMENTS = []() {
      36                 :         583 :     std::vector<const char*> args;
      37   [ +  -  +  + ]:        1166 :     for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) {
      38   [ +  -  +  - ]:         583 :         args.push_back(boost::unit_test::framework::master_test_suite().argv[i]);
      39                 :             :     }
      40                 :         583 :     return args;
      41                 :           0 : };
      42                 :             : 
      43                 :             : /**
      44                 :             :  * Retrieve the boost unit test name.
      45                 :             :  */
      46                 :           0 : const std::function<std::string()> G_TEST_GET_FULL_NAME = []() {
      47                 :           0 :     return boost::unit_test::framework::current_test_case().full_name();
      48                 :             : };
        

Generated by: LCOV version 2.0-1