PEL: Add 3 state fields to PEL UserData section
Add the following to the system info UserData section that gets added
for PELs created by BMC code:
* CurrentBMCState on /xyz/openbmc_project/state/bmc0
* CurrentHostState on /xyz/openbmc_project/state/host0
* CurrentPowerState on /xyz/openbmc_project/state/chassis0
The RequestedPowerTransition property is also read along with the
CurrentPowerState property since it's on the same interface and will
be used in a future commit.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Icdc225f2c9bb6d91e67a4cbe608df97803ccee6c
diff --git a/test/openpower-pels/mocks.hpp b/test/openpower-pels/mocks.hpp
index 5c3bdb1..8fb6506 100644
--- a/test/openpower-pels/mocks.hpp
+++ b/test/openpower-pels/mocks.hpp
@@ -25,10 +25,13 @@
MOCK_METHOD(std::string, getBMCFWVersion, (), (const override));
MOCK_METHOD(std::string, getBMCFWVersionID, (), (const override));
MOCK_METHOD(bool, getHostPELEnablement, (), (const override));
+ MOCK_METHOD(std::string, getBMCState, (), (const override));
+ MOCK_METHOD(std::string, getChassisState, (), (const override));
+ MOCK_METHOD(std::string, getHostState, (), (const override));
void changeHostState(bool newState)
{
- setHostState(newState);
+ setHostUp(newState);
}
void setHMCManaged(bool managed)
diff --git a/test/openpower-pels/pel_test.cpp b/test/openpower-pels/pel_test.cpp
index 2cf58d7..8832038 100644
--- a/test/openpower-pels/pel_test.cpp
+++ b/test/openpower-pels/pel_test.cpp
@@ -319,6 +319,9 @@
MockDataInterface dataIface;
EXPECT_CALL(dataIface, getBMCFWVersionID()).WillOnce(Return("ABCD1234"));
+ EXPECT_CALL(dataIface, getBMCState()).WillOnce(Return("State.Ready"));
+ EXPECT_CALL(dataIface, getChassisState()).WillOnce(Return("State.On"));
+ EXPECT_CALL(dataIface, getHostState()).WillOnce(Return("State.Off"));
std::string pid = "_PID=" + std::to_string(getpid());
std::vector<std::string> ad{pid};
@@ -343,6 +346,15 @@
auto version = json["BMC Version ID"].get<std::string>();
EXPECT_EQ(version, "ABCD1234");
+
+ auto state = json["BMCState"].get<std::string>();
+ EXPECT_EQ(state, "Ready");
+
+ state = json["ChassisState"].get<std::string>();
+ EXPECT_EQ(state, "On");
+
+ state = json["HostState"].get<std::string>();
+ EXPECT_EQ(state, "Off");
}
// Test that the sections that override