Verify the value of the tempX_label file
- The intent behind this commit is to verify the value of
the tempX_label file.
- In the future, the value of this file will be changed to
`D0000002` (OCC sensor ID).
- OCC Sensor Ids(D0000002)
- First byte is type - D0
- Second byte is reserved - 00
- Third+Fourth bytes are instance id - 0002
Tested: built openpower-occ-control successfully and unit test worked
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I5e89ce9592898f79b9fe926dd7bbe5691bf535a5
diff --git a/test/utest.cpp b/test/utest.cpp
index 04fa492..ff75a60 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -1,4 +1,5 @@
#include "powercap.hpp"
+#include "utils.hpp"
#include <experimental/filesystem>
#include <occ_events.hpp>
@@ -7,6 +8,7 @@
#include <gtest/gtest.h>
using namespace open_power::occ;
+using namespace open_power::occ::utils;
class VerifyOccInput : public ::testing::Test
{
@@ -66,3 +68,17 @@
EXPECT_STREQ(parsed.c_str(), "bar");
}
+
+TEST(VerifyLabelValue, checkLabelValue)
+{
+ const std::string value = "D0000002";
+
+ auto labelValue = checkLabelValue(value);
+ EXPECT_NE(labelValue, std::nullopt);
+
+ std::string reType = "D0";
+ uint16_t reID = 2;
+ auto& [type, instanceID] = *labelValue;
+ EXPECT_EQ(type, reType);
+ EXPECT_EQ(instanceID, reID);
+}