diff options
author | Matt Spinler <spinler@us.ibm.com> | 2019-11-21 13:31:27 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2019-12-09 13:47:57 -0600 |
commit | 29d18c116394b5d6b2a57876a4cac6ce86e7716a (patch) | |
tree | e5c079bc38e19532cda39b2fe824da8853b8a892 /test | |
parent | a3c12a48a4ca3f7f4ced6cf1d9d9cf03d05a05d5 (diff) | |
download | phosphor-logging-29d18c116394b5d6b2a57876a4cac6ce86e7716a.tar.gz phosphor-logging-29d18c116394b5d6b2a57876a4cac6ce86e7716a.zip |
PEL: Add Repo API to update transmission states
Provided APIs for the Repository class to update the host and HMC
transmission states on a PEL it contains. It saves the updated PEL data
in the filesystem.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Iadbc589ee85d4408339e1171c36b8324910f4f0a
Diffstat (limited to 'test')
-rw-r--r-- | test/openpower-pels/repository_test.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/test/openpower-pels/repository_test.cpp b/test/openpower-pels/repository_test.cpp index 8596840..5c4db47 100644 --- a/test/openpower-pels/repository_test.cpp +++ b/test/openpower-pels/repository_test.cpp @@ -300,3 +300,89 @@ TEST_F(RepositoryTest, TestGetAttributes) EXPECT_FALSE(a); } } + +TEST_F(RepositoryTest, TestSetHostState) +{ + // Add a PEL to the repo + auto data = pelDataFactory(TestPELType::pelSimple); + auto pel = std::make_unique<PEL>(data); + using ID = Repository::LogID; + ID id{ID::Pel(pel->id())}; + + { + Repository repo{repoPath}; + + repo.add(pel); + + auto a = repo.getPELAttributes(id); + EXPECT_EQ((*a).get().hostState, TransmissionState::newPEL); + + repo.setPELHostTransState(pel->id(), TransmissionState::acked); + + // First, check the attributes + a = repo.getPELAttributes(id); + EXPECT_EQ((*a).get().hostState, TransmissionState::acked); + + // Next, check the PEL data itself + auto pelData = repo.getPELData(id); + PEL newPEL{*pelData}; + EXPECT_EQ(newPEL.hostTransmissionState(), TransmissionState::acked); + } + + { + // Now restore, and check again + Repository repo{repoPath}; + + // First, check the attributes + auto a = repo.getPELAttributes(id); + EXPECT_EQ((*a).get().hostState, TransmissionState::acked); + + // Next, check the PEL data itself + auto pelData = repo.getPELData(id); + PEL newPEL{*pelData}; + EXPECT_EQ(newPEL.hostTransmissionState(), TransmissionState::acked); + } +} + +TEST_F(RepositoryTest, TestSetHMCState) +{ + // Add a PEL to the repo + auto data = pelDataFactory(TestPELType::pelSimple); + auto pel = std::make_unique<PEL>(data); + using ID = Repository::LogID; + ID id{ID::Pel(pel->id())}; + + { + Repository repo{repoPath}; + + repo.add(pel); + + auto a = repo.getPELAttributes(id); + EXPECT_EQ((*a).get().hmcState, TransmissionState::newPEL); + + repo.setPELHMCTransState(pel->id(), TransmissionState::acked); + + // First, check the attributes + a = repo.getPELAttributes(id); + EXPECT_EQ((*a).get().hmcState, TransmissionState::acked); + + // Next, check the PEL data itself + auto pelData = repo.getPELData(id); + PEL newPEL{*pelData}; + EXPECT_EQ(newPEL.hmcTransmissionState(), TransmissionState::acked); + } + + { + // Now restore, and check again + Repository repo{repoPath}; + + // First, check the attributes + auto a = repo.getPELAttributes(id); + EXPECT_EQ((*a).get().hmcState, TransmissionState::acked); + + // Next, check the PEL data itself + auto pelData = repo.getPELData(id); + PEL newPEL{*pelData}; + EXPECT_EQ(newPEL.hmcTransmissionState(), TransmissionState::acked); + } +} |