test: require `TryGetTotalRam()` detection
What changed, and why it matters
This commit only changes a test file and build configuration. It removes the option to skip a test when the system cannot detect total RAM, and instead requires the RAM detection to succeed. It does not change any production wallet, networking, consensus, or node code, so it has no direct security impact on running Bitcoin Core software.
No security action required. Review as a normal test-quality change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies src/test/system_ram_tests.cpp and src/test/CMakeLists.txt. Previously, TryGetTotalRam() returning std::nullopt caused the test to warn and skip. Now BOOST_REQUIRE(total) forces the test to fail if RAM detection is unavailable, and the skip regex is removed from CMake. The production implementation of TryGetTotalRam() and the dbcache logic that consumes it are untouched. This is purely a test-hardening change.
Changed components
src/test/system_ram_tests.cppsrc/test/CMakeLists.txtInspect captured patch +3 / −11
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index a813b076..5c614ab3 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -192,7 +192,6 @@ function(add_boost_test source_file)
SKIP_REGULAR_EXPRESSION
"no test cases matching filter"
"skipping script_assets_test"
- "skipping total_ram"
)
endforeach()
endfunction()
diff --git a/src/test/system_ram_tests.cpp b/src/test/system_ram_tests.cpp
index 79e4ebfb..ec1ca873 100644
--- a/src/test/system_ram_tests.cpp
+++ b/src/test/system_ram_tests.cpp
@@ -3,24 +3,17 @@
// file COPYING or https://opensource.org/license/mit/.
#include <common/system.h>
-#include <test/util/setup_common.h>
+#include <util/byte_units.h>
#include <boost/test/unit_test.hpp>
-#include <cstdint>
-#include <optional>
-
BOOST_AUTO_TEST_SUITE(system_ram_tests)
BOOST_AUTO_TEST_CASE(total_ram)
{
const auto total{TryGetTotalRam()};
- if (!total) {
- BOOST_WARN_MESSAGE(false, "skipping total_ram: total RAM unknown");
- return;
- }
-
- BOOST_CHECK_GE(*total, 1000_MiB);
+ BOOST_REQUIRE(total);
+ BOOST_CHECK_GE(*total, 1_GiB);
BOOST_CHECK_LT(*total, 10'000_GiB); // ~10 TiB memory is unlikely
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.