summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-12-12 11:27:10 -0600
committerMatt Spinler <spinler@us.ibm.com>2020-01-27 08:06:26 -0600
commitcc3b64aebb1760750888324f116d11a952acd203 (patch)
treefd6bc0c48ed0f0313ea0473bd6bf300294bed8d8 /test
parent7d800a4e5d1305fa64ce02b99b0ec522bc454bbd (diff)
downloadphosphor-logging-cc3b64aebb1760750888324f116d11a952acd203.tar.gz
phosphor-logging-cc3b64aebb1760750888324f116d11a952acd203.zip
PEL: Support for the host acking a PEL
After the host firmware successfully transfers a PEL to the OS, it will respond with an 'Ack' command that the PLDM daemon sends over to this daemon via a D-Bus method call. Add support to the HostNotifier class for this. It will change the state field in the PEL to 'acked' so that it doesn't get sent up again. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: Id2a9985965017d9431419c1375d5374a2d0ae00b
Diffstat (limited to 'test')
-rw-r--r--test/openpower-pels/host_notifier_test.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/openpower-pels/host_notifier_test.cpp b/test/openpower-pels/host_notifier_test.cpp
index afb5dc2..62c79b2 100644
--- a/test/openpower-pels/host_notifier_test.cpp
+++ b/test/openpower-pels/host_notifier_test.cpp
@@ -571,3 +571,75 @@ TEST_F(HostNotifierTest, TestCancelCmd)
EXPECT_EQ(mockHostIface.numCmdsProcessed(), 1);
EXPECT_EQ(notifier.queueSize(), 0);
}
+
+// Test that acking a PEL persist across power cycles
+TEST_F(HostNotifierTest, TestPowerCycleAndAcks)
+{
+ Repository repo{repoPath};
+ MockDataInterface dataIface;
+
+ sdeventplus::Event sdEvent{event};
+
+ std::unique_ptr<HostInterface> hostIface =
+ std::make_unique<MockHostInterface>(event, dataIface);
+
+ MockHostInterface& mockHostIface =
+ reinterpret_cast<MockHostInterface&>(*hostIface);
+
+ HostNotifier notifier{repo, dataIface, std::move(hostIface)};
+
+ auto send = [&mockHostIface](uint32_t id, uint32_t size) {
+ return mockHostIface.send(0);
+ };
+
+ EXPECT_CALL(mockHostIface, sendNewLogCmd(_, _))
+ .WillRepeatedly(Invoke(send));
+
+ // Add 2 PELs with host off
+ auto pel = makePEL();
+ repo.add(pel);
+ auto id1 = pel->id();
+
+ pel = makePEL();
+ repo.add(pel);
+ auto id2 = pel->id();
+
+ dataIface.changeHostState(true);
+
+ runEvents(sdEvent, 2);
+
+ // The were both sent.
+ EXPECT_EQ(mockHostIface.numCmdsProcessed(), 2);
+ EXPECT_EQ(notifier.queueSize(), 0);
+
+ dataIface.changeHostState(false);
+
+ // Those PELs weren't acked, so they will get sent again
+ EXPECT_EQ(notifier.queueSize(), 2);
+
+ // Power back on and send them again
+ dataIface.changeHostState(true);
+ runEvents(sdEvent, 2);
+
+ EXPECT_EQ(mockHostIface.numCmdsProcessed(), 4);
+ EXPECT_EQ(notifier.queueSize(), 0);
+
+ // Ack them and verify the state in the PEL.
+ notifier.ackPEL(id1);
+ notifier.ackPEL(id2);
+
+ Repository::LogID id{Repository::LogID::Pel{id1}};
+ auto data = repo.getPELData(id);
+ PEL pelFromRepo1{*data};
+ EXPECT_EQ(pelFromRepo1.hostTransmissionState(), TransmissionState::acked);
+
+ id.pelID.id = id2;
+ data = repo.getPELData(id);
+ PEL pelFromRepo2{*data};
+ EXPECT_EQ(pelFromRepo2.hostTransmissionState(), TransmissionState::acked);
+
+ // Power back off, and they should't get re-added
+ dataIface.changeHostState(false);
+
+ EXPECT_EQ(notifier.queueSize(), 0);
+}
OpenPOWER on IntegriCloud