platform-mc: PDR handling
Get PDRs of new terminus if it supports GetPDR PLDM command. It doesn't
handle the event receiver related initialization steps, and either
doesn't support primary PDR repository to maintain terminus locator PDR
information yet.
Added parse PDR member functions to terminus class for parsing Numeric
sensor PDR and sensor auxiliary names PDR.
Added sensor auxiliary names PDR and numeric sensor PDR struct in
libpldm/platform.h
Signed-off-by: Gilbert Chen <gilbert.chen@arm.com>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I30a0cc594a3c08fc17f2dad861b5c5d41c80ebdd
diff --git a/platform-mc/test/terminus_test.cpp b/platform-mc/test/terminus_test.cpp
index 32fd7b7..8919b19 100644
--- a/platform-mc/test/terminus_test.cpp
+++ b/platform-mc/test/terminus_test.cpp
@@ -1,3 +1,5 @@
+#include "libpldm/entity.h"
+
#include "platform-mc/terminus.hpp"
#include <gtest/gtest.h>
@@ -21,3 +23,59 @@
EXPECT_EQ(tid, t1.getTid());
}
+
+TEST(TerminusTest, parseSensorAuxiliaryNamesPDRTest)
+{
+ auto t1 = pldm::platform_mc::Terminus(1,
+ 1 << PLDM_BASE | 1 << PLDM_PLATFORM);
+ std::vector<uint8_t> pdr1{
+ 0x0,
+ 0x0,
+ 0x0,
+ 0x1, // record handle
+ 0x1, // PDRHeaderVersion
+ PLDM_SENSOR_AUXILIARY_NAMES_PDR, // PDRType
+ 0x0,
+ 0x0, // recordChangeNumber
+ 0x0,
+ 21, // dataLength
+ 0,
+ 0x0, // PLDMTerminusHandle
+ 0x1,
+ 0x0, // sensorID
+ 0x1, // sensorCount
+ 0x1, // nameStringCount
+ 'e',
+ 'n',
+ 0x0, // nameLanguageTag
+ 0x0,
+ 'T',
+ 0x0,
+ 'E',
+ 0x0,
+ 'M',
+ 0x0,
+ 'P',
+ 0x0,
+ '1',
+ 0x0,
+ 0x0 // sensorName
+ };
+
+ t1.pdrs.emplace_back(pdr1);
+ t1.parseTerminusPDRs();
+
+ auto sensorAuxNames = t1.getSensorAuxiliaryNames(0);
+ EXPECT_EQ(nullptr, sensorAuxNames);
+
+ sensorAuxNames = t1.getSensorAuxiliaryNames(1);
+ EXPECT_NE(nullptr, sensorAuxNames);
+
+ const auto& [sensorId, sensorCnt, names] = *sensorAuxNames;
+ EXPECT_EQ(1, sensorId);
+ EXPECT_EQ(1, sensorCnt);
+ EXPECT_EQ(1, names.size());
+ EXPECT_EQ(1, names[0].size());
+ EXPECT_EQ("en", names[0][0].first);
+ EXPECT_EQ("TEMP1", names[0][0].second);
+}