LCOV - code coverage report
Current view: top level - src/test/fuzz/util - threadinterrupt.h (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 2 2
Test Date: 2025-10-10 04:04:55 Functions: 100.0 % 1 1
Branches: 50.0 % 2 1

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2024-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                 :             : #ifndef BITCOIN_TEST_FUZZ_UTIL_THREADINTERRUPT_H
       6                 :             : #define BITCOIN_TEST_FUZZ_UTIL_THREADINTERRUPT_H
       7                 :             : 
       8                 :             : #include <test/fuzz/FuzzedDataProvider.h>
       9                 :             : #include <util/threadinterrupt.h>
      10                 :             : 
      11                 :             : #include <memory>
      12                 :             : 
      13                 :             : /**
      14                 :             :  * Mocked CThreadInterrupt that returns "randomly" whether it is interrupted and never sleeps.
      15                 :             :  */
      16                 :             : class FuzzedThreadInterrupt : public CThreadInterrupt
      17                 :             : {
      18                 :             : public:
      19                 :             :     explicit FuzzedThreadInterrupt(FuzzedDataProvider& fuzzed_data_provider);
      20                 :             : 
      21                 :             :     virtual bool interrupted() const override;
      22                 :             :     virtual bool sleep_for(Clock::duration) override;
      23                 :             : 
      24                 :             : private:
      25                 :             :     FuzzedDataProvider& m_fuzzed_data_provider;
      26                 :             : };
      27                 :             : 
      28                 :        1993 : [[nodiscard]] inline std::shared_ptr<CThreadInterrupt> ConsumeThreadInterrupt(FuzzedDataProvider& fuzzed_data_provider)
      29                 :             : {
      30         [ -  + ]:        1993 :     return std::make_shared<FuzzedThreadInterrupt>(fuzzed_data_provider);
      31                 :             : }
      32                 :             : 
      33                 :             : #endif // BITCOIN_TEST_FUZZ_UTIL_THREADINTERRUPT_H
        

Generated by: LCOV version 2.0-1