LCOV - code coverage report
Current view: top level - src/test/util - logging.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 92.9 % 14 13
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) 2019-2021 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                 :             : #include <test/util/logging.h>
       6                 :             : 
       7                 :             : #include <logging.h>
       8                 :             : #include <noui.h>
       9                 :             : #include <tinyformat.h>
      10                 :             : 
      11                 :             : #include <stdexcept>
      12                 :             : 
      13                 :          55 : DebugLogHelper::DebugLogHelper(std::string message, MatchFn match)
      14                 :          55 :     : m_message{std::move(message)}, m_match(std::move(match))
      15                 :             : {
      16   [ +  -  +  - ]:          55 :     m_print_connection = LogInstance().PushBackCallback(
      17         [ +  - ]:          55 :         [this](const std::string& s) {
      18         [ +  + ]:         554 :             if (m_found) return;
      19   [ +  +  +  + ]:         523 :             m_found = s.find(m_message) != std::string::npos && m_match(&s);
      20                 :             :         });
      21         [ +  - ]:          55 :     noui_test_redirect();
      22                 :          55 : }
      23                 :             : 
      24                 :          55 : void DebugLogHelper::check_found()
      25                 :             : {
      26                 :          55 :     noui_reconnect();
      27                 :          55 :     LogInstance().DeleteCallback(m_print_connection);
      28   [ +  +  -  + ]:          55 :     if (!m_found && m_match(nullptr)) {
      29   [ #  #  #  # ]:           0 :         throw std::runtime_error(strprintf("'%s' not found in debug log\n", m_message));
      30                 :             :     }
      31                 :          55 : }
        

Generated by: LCOV version 2.0-1