LCOV - code coverage report
Current view: top level - src/test - caches_tests.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 100.0 % 16 16
Test Date: 2025-10-04 04:34:28 Functions: 100.0 % 2 2
Branches: 50.0 % 86 43

             Branch data     Line data    Source code
       1                 :             : #include <node/caches.h>
       2                 :             : #include <util/byte_units.h>
       3                 :             : 
       4                 :             : #include <boost/test/unit_test.hpp>
       5                 :             : 
       6                 :             : using namespace node;
       7                 :             : 
       8                 :             : BOOST_AUTO_TEST_SUITE(caches_tests)
       9                 :             : 
      10   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(oversized_dbcache_warning)
          +  -  +  -  -  
          +  +  -  +  -  
          +  -  +  -  +  
          -  -  +  +  -  
          +  -  +  -  +  
          -  +  -  -  +  
          +  -  +  -  +  
          -  +  -  +  -  
          -  +  +  -  +  
          -  +  -  +  -  
          +  -  -  +  +  
                      - ]
      11                 :             : {
      12                 :             :     // memory restricted setup - cap is DEFAULT_DB_CACHE (450 MiB)
      13         [ +  - ]:           2 :     BOOST_CHECK(!ShouldWarnOversizedDbCache(/*dbcache=*/4_MiB, /*total_ram=*/1024_MiB));    // Under cap
      14         [ +  - ]:           2 :     BOOST_CHECK( ShouldWarnOversizedDbCache(/*dbcache=*/512_MiB, /*total_ram=*/1024_MiB));  // At cap
      15         [ +  - ]:           2 :     BOOST_CHECK( ShouldWarnOversizedDbCache(/*dbcache=*/1500_MiB, /*total_ram=*/1024_MiB)); // Over cap
      16                 :             : 
      17                 :             :     // 2 GiB RAM - cap is 75%
      18         [ +  - ]:           2 :     BOOST_CHECK(!ShouldWarnOversizedDbCache(/*dbcache=*/1500_MiB, /*total_ram=*/2048_MiB)); // Under cap
      19         [ +  - ]:           2 :     BOOST_CHECK( ShouldWarnOversizedDbCache(/*dbcache=*/1600_MiB, /*total_ram=*/2048_MiB)); // Over cap
      20                 :             : 
      21                 :           1 :     if constexpr (SIZE_MAX == UINT64_MAX) {
      22                 :             :         // 4 GiB RAM - cap is 75%
      23         [ +  - ]:           2 :         BOOST_CHECK(!ShouldWarnOversizedDbCache(/*dbcache=*/2500_MiB, /*total_ram=*/4096_MiB)); // Under cap
      24         [ +  - ]:           2 :         BOOST_CHECK( ShouldWarnOversizedDbCache(/*dbcache=*/3500_MiB, /*total_ram=*/4096_MiB)); // Over cap
      25                 :             : 
      26                 :             :         // 8 GiB RAM - cap is 75%
      27         [ +  - ]:           2 :         BOOST_CHECK(!ShouldWarnOversizedDbCache(/*dbcache=*/6000_MiB, /*total_ram=*/8192_MiB)); // Under cap
      28         [ +  - ]:           2 :         BOOST_CHECK( ShouldWarnOversizedDbCache(/*dbcache=*/7000_MiB, /*total_ram=*/8192_MiB)); // Over cap
      29                 :             : 
      30                 :             :         // 16 GiB RAM - cap is 75%
      31         [ +  - ]:           2 :         BOOST_CHECK(!ShouldWarnOversizedDbCache(/*dbcache=*/10'000_MiB, /*total_ram=*/16384_MiB)); // Under cap
      32         [ +  - ]:           2 :         BOOST_CHECK( ShouldWarnOversizedDbCache(/*dbcache=*/15'000_MiB, /*total_ram=*/16384_MiB)); // Over cap
      33                 :             : 
      34                 :             :         // 32 GiB RAM - cap is 75%
      35         [ +  - ]:           2 :         BOOST_CHECK(!ShouldWarnOversizedDbCache(/*dbcache=*/20'000_MiB, /*total_ram=*/32768_MiB)); // Under cap
      36         [ +  - ]:           2 :         BOOST_CHECK( ShouldWarnOversizedDbCache(/*dbcache=*/30'000_MiB, /*total_ram=*/32768_MiB)); // Over cap
      37                 :             :     }
      38                 :           1 : }
      39                 :             : 
      40                 :             : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1