oem-ibm: Implement Host lamp test interface
IBM has a feature called LampTest and what it does is this:
- BMC would set the state of LEDs to [ON] on all the BMC accessible
LEDs.
- For LEDs that are not accessible by BMC, a message is sent to the
Host, so that the Host can exercise all the LEDs on the connected
drawers and anything else that the BMC does not have access to.
This commit adds support to send message to Host when BMC has to tell
the Host to exercise LEDs accessible by host.
When Host sees the effector is set, it goes ahead and turns [ON] all
the LEDs for a specified time and automatically restores the states
at timer expiration. BMC does not have to tell the Host to stop the
test and it is part of Host's lamp test requirement.
TESTED: By setting the asserted property of the LED groups object
busctl set-property xyz.openbmc_project.LED.GroupManager
/xyz/openbmc_project/led/groups/lamp_test
xyz.openbmc_project.Led.Group Asserted b true
And verifying that the setEffecterStates call was made to the
remote state effecter to turn on all LEDs
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I990dce28d3017f20c73ff9029fced0e7ac84868f
diff --git a/oem/ibm/test/host_bmc_lamp_test.cpp b/oem/ibm/test/host_bmc_lamp_test.cpp
new file mode 100644
index 0000000..7d75649
--- /dev/null
+++ b/oem/ibm/test/host_bmc_lamp_test.cpp
@@ -0,0 +1,51 @@
+#include "oem/ibm/host-bmc/host_lamp_test.hpp"
+#include "pldmd/dbus_impl_requester.hpp"
+#include "test/test_instance_id.hpp"
+
+#include <string.h>
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using namespace pldm::led;
+using ::testing::DoAll;
+using ::testing::Return;
+using ::testing::SetArgPointee;
+
+class MockLampTest : public HostLampTest
+{
+ public:
+ MockLampTest(sdbusplus::bus::bus& bus, const std::string& objPath,
+ uint8_t mctp_eid, pldm::InstanceIdDb& instanceIdDb,
+ pldm_pdr* repo,
+ pldm::requester::Handler<pldm::requester::Request>* handler) :
+ HostLampTest(bus, objPath, mctp_eid, instanceIdDb, repo, handler)
+ {}
+
+ MOCK_METHOD(uint16_t, getEffecterID, (), (override));
+ MOCK_METHOD(uint8_t, setHostStateEffecter, (uint16_t effecterId),
+ (override));
+};
+
+TEST(TestLamp, Asserted)
+{
+ sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+ TestInstanceIdDb instanceIdDb;
+
+ MockLampTest lampTest(bus, "/xyz/openbmc_project/led/groups/host_lamp_test",
+ 0, instanceIdDb, nullptr, nullptr);
+
+ lampTest.asserted(false);
+ EXPECT_EQ(lampTest.asserted(), false);
+
+ EXPECT_CALL(lampTest, getEffecterID())
+ .Times(2)
+ .WillOnce(Return(0))
+ .WillOnce(Return(1));
+ EXPECT_CALL(lampTest, setHostStateEffecter(1)).Times(1).WillOnce(Return(0));
+
+ ASSERT_THROW(lampTest.asserted(true), sdbusplus::exception::SdBusError);
+
+ lampTest.asserted(true);
+ EXPECT_EQ(lampTest.asserted(), true);
+}