Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
system_ram_tests.cpp
Go to the documentation of this file.
1
// Copyright (c) 2025-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or https://opensource.org/license/mit/.
4
5
#include <
common/system.h
>
6
#include <
test/util/setup_common.h
>
7
8
#include <boost/test/unit_test.hpp>
9
10
#include <cstdint>
11
#include <optional>
12
13
BOOST_AUTO_TEST_SUITE(system_ram_tests)
14
15
BOOST_AUTO_TEST_CASE
(total_ram)
16
{
17
const
auto
total{
GetTotalRAM
()};
18
if
(!total) {
19
BOOST_WARN_MESSAGE(
false
,
"skipping total_ram: total RAM unknown"
);
20
return
;
21
}
22
23
BOOST_CHECK_GE(*total, 1000_MiB);
24
25
if
constexpr
(SIZE_MAX == UINT64_MAX) {
26
// Upper bound check only on 64-bit: 32-bit systems can reasonably have max memory,
27
// but extremely large values on 64-bit likely indicate detection errors
28
BOOST_CHECK_LT
(*total, 10'000'000_MiB);
// >10 TiB memory is unlikely
29
}
30
}
31
32
BOOST_AUTO_TEST_SUITE_END
()
BOOST_CHECK_LT
BOOST_CHECK_LT(ZeroL, OneL)
GetTotalRAM
std::optional< size_t > GetTotalRAM()
Return the total RAM available on the current system, if detectable.
Definition
system.cpp:114
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(ipc_tests)
Definition
ipc_tests.cpp:13
setup_common.h
system.h
Generated on
for Bitcoin Core by
1.17.0