summaryrefslogtreecommitdiff
path: root/src/mongo/util/processinfo_test.cpp
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
commit959575a5ca598bf5f37fb5cebe7ed1d80d3d71f7 (patch)
treeacc8d60aedb12b70048e676e8a7349deb0010db8 /src/mongo/util/processinfo_test.cpp
parent76588293975fc059cf076779e4283e6ffaf8afff (diff)
New upstream version 6.0.20upstream
Diffstat (limited to 'src/mongo/util/processinfo_test.cpp')
-rw-r--r--src/mongo/util/processinfo_test.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/mongo/util/processinfo_test.cpp b/src/mongo/util/processinfo_test.cpp
index 050835f97ac..ab35a6b7374 100644
--- a/src/mongo/util/processinfo_test.cpp
+++ b/src/mongo/util/processinfo_test.cpp
@@ -33,13 +33,30 @@
#include <iostream>
#include <vector>
+#include "mongo/bson/bsonobj.h"
+#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/processinfo.h"
using boost::optional;
-using mongo::ProcessInfo;
-namespace mongo_test {
+namespace mongo {
+
+namespace {
+using StringMap = std::map<std::string, uint64_t>;
+
+StringMap toStringMap(BSONObj& obj) {
+ StringMap map;
+
+ for (const auto& e : obj) {
+ map[e.fieldName()] = e.numberLong();
+ }
+
+ return map;
+}
+
+#define ASSERT_KEY(_key) ASSERT_TRUE(stringMap.find(_key) != stringMap.end());
+
TEST(ProcessInfo, SysInfoIsInitialized) {
ProcessInfo processInfo;
if (processInfo.supported()) {
@@ -47,6 +64,20 @@ TEST(ProcessInfo, SysInfoIsInitialized) {
}
}
+TEST(FTDCProcSysInfo, TestSysInfo) {
+ auto sysInfo = ProcessInfo();
+ BSONObjBuilder builder;
+ sysInfo.appendSystemDetails(builder);
+
+ BSONObj obj = builder.obj();
+ auto stringMap = toStringMap(obj);
+ ASSERT_KEY("extra");
+
+ BSONObj extra = obj.getObjectField("extra");
+ stringMap = toStringMap(extra);
+ ASSERT_KEY("cpuString");
+}
+
TEST(ProcessInfo, GetNumAvailableCores) {
#if defined(__APPLE__) || defined(__linux__) || (defined(__sun) && defined(__SVR4)) || \
defined(_WIN32)
@@ -59,4 +90,5 @@ TEST(ProcessInfo, GetNumAvailableCores) {
TEST(ProcessInfo, GetNumCoresReturnsNonZeroNumberOfProcessors) {
ASSERT_GREATER_THAN(ProcessInfo::getNumCores(), 0u);
}
-} // namespace mongo_test
+} // namespace
+} // namespace mongo