LCOV - code coverage report
Current view: top level - src/test/util - logging.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 15 16 93.8 %
Date: 2020-09-26 01:30:44 Functions: 4 4 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2019 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             : #include <util/memory.h>
      11             : 
      12             : #include <stdexcept>
      13             : 
      14          16 : DebugLogHelper::DebugLogHelper(std::string message, MatchFn match)
      15           8 :     : m_message{std::move(message)}, m_match(std::move(match))
      16           8 : {
      17          24 :     m_print_connection = LogInstance().PushBackCallback(
      18         336 :         [this](const std::string& s) {
      19         328 :             if (m_found) return;
      20         321 :             m_found = s.find(m_message) != std::string::npos && m_match(&s);
      21         328 :         });
      22           8 :     noui_test_redirect();
      23          16 : }
      24             : 
      25           8 : void DebugLogHelper::check_found()
      26             : {
      27           8 :     noui_reconnect();
      28           8 :     LogInstance().DeleteCallback(m_print_connection);
      29           8 :     if (!m_found && m_match(nullptr)) {
      30           0 :         throw std::runtime_error(strprintf("'%s' not found in debug log\n", m_message));
      31             :     }
      32           8 : }

Generated by: LCOV version 1.15