LCOV - code coverage report
Current view: top level - src/test/fuzz - checkqueue.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 0.0 % 25 0
Test Date: 2024-08-28 04:44:32 Functions: 0.0 % 2 0
Branches: 0.0 % 28 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2020-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                 :             : #include <checkqueue.h>
       6                 :             : #include <test/fuzz/FuzzedDataProvider.h>
       7                 :             : #include <test/fuzz/fuzz.h>
       8                 :             : #include <test/fuzz/util.h>
       9                 :             : 
      10                 :             : #include <cstdint>
      11                 :             : #include <string>
      12                 :             : #include <vector>
      13                 :             : 
      14                 :             : namespace {
      15                 :             : struct DumbCheck {
      16                 :             :     bool result = false;
      17                 :             : 
      18                 :           0 :     explicit DumbCheck(const bool _result) : result(_result)
      19                 :             :     {
      20                 :             :     }
      21                 :             : 
      22                 :           0 :     bool operator()() const
      23                 :             :     {
      24                 :           0 :         return result;
      25                 :             :     }
      26                 :             : };
      27                 :             : } // namespace
      28                 :             : 
      29         [ #  # ]:           0 : FUZZ_TARGET(checkqueue)
      30                 :             : {
      31                 :           0 :     FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      32                 :             : 
      33                 :           0 :     const unsigned int batch_size = fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(0, 1024);
      34                 :           0 :     CCheckQueue<DumbCheck> check_queue_1{batch_size, /*worker_threads_num=*/0};
      35         [ #  # ]:           0 :     CCheckQueue<DumbCheck> check_queue_2{batch_size, /*worker_threads_num=*/0};
      36                 :           0 :     std::vector<DumbCheck> checks_1;
      37                 :           0 :     std::vector<DumbCheck> checks_2;
      38                 :           0 :     const int size = fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 1024);
      39         [ #  # ]:           0 :     for (int i = 0; i < size; ++i) {
      40                 :           0 :         const bool result = fuzzed_data_provider.ConsumeBool();
      41         [ #  # ]:           0 :         checks_1.emplace_back(result);
      42         [ #  # ]:           0 :         checks_2.emplace_back(result);
      43                 :             :     }
      44         [ #  # ]:           0 :     if (fuzzed_data_provider.ConsumeBool()) {
      45         [ #  # ]:           0 :         check_queue_1.Add(std::move(checks_1));
      46                 :             :     }
      47         [ #  # ]:           0 :     if (fuzzed_data_provider.ConsumeBool()) {
      48         [ #  # ]:           0 :         (void)check_queue_1.Wait();
      49                 :             :     }
      50                 :             : 
      51         [ #  # ]:           0 :     CCheckQueueControl<DumbCheck> check_queue_control{&check_queue_2};
      52         [ #  # ]:           0 :     if (fuzzed_data_provider.ConsumeBool()) {
      53         [ #  # ]:           0 :         check_queue_control.Add(std::move(checks_2));
      54                 :             :     }
      55         [ #  # ]:           0 :     if (fuzzed_data_provider.ConsumeBool()) {
      56         [ #  # ]:           0 :         (void)check_queue_control.Wait();
      57                 :             :     }
      58                 :           0 : }
        

Generated by: LCOV version 2.0-1