summaryrefslogtreecommitdiffstats
path: root/test/openpower-pels
diff options
context:
space:
mode:
Diffstat (limited to 'test/openpower-pels')
-rw-r--r--test/openpower-pels/pel_manager_test.cpp16
-rw-r--r--test/openpower-pels/repository_test.cpp67
2 files changed, 83 insertions, 0 deletions
diff --git a/test/openpower-pels/pel_manager_test.cpp b/test/openpower-pels/pel_manager_test.cpp
index a5b16f5..9d788c9 100644
--- a/test/openpower-pels/pel_manager_test.cpp
+++ b/test/openpower-pels/pel_manager_test.cpp
@@ -62,5 +62,21 @@ TEST_F(ManagerTest, TestCreateWithPEL)
EXPECT_TRUE(found);
+ // Now remove it based on its OpenBMC event log ID
+ manager.erase(42);
+
+ found = false;
+
+ for (auto& f : fs::directory_iterator(getPELRepoPath() / "logs"))
+ {
+ if (std::regex_search(f.path().string(), expr))
+ {
+ found = true;
+ break;
+ }
+ }
+
+ EXPECT_FALSE(found);
+
fs::remove_all(pelFilename.parent_path());
}
diff --git a/test/openpower-pels/repository_test.cpp b/test/openpower-pels/repository_test.cpp
index 97019e8..6963184 100644
--- a/test/openpower-pels/repository_test.cpp
+++ b/test/openpower-pels/repository_test.cpp
@@ -71,3 +71,70 @@ TEST_F(RepositoryTest, AddTest)
auto pelData = pel->data();
EXPECT_EQ(*newData, pelData);
}
+
+TEST_F(RepositoryTest, RestoreTest)
+{
+ using pelID = Repository::LogID::Pel;
+ using obmcID = Repository::LogID::Obmc;
+
+ std::vector<Repository::LogID> ids;
+
+ {
+ Repository repo{repoPath};
+
+ // Add some PELs to the repository
+ {
+ auto data = pelDataFactory(TestPelType::pelSimple);
+ auto pel = std::make_unique<PEL>(*data, 1);
+ pel->assignID();
+ repo.add(pel);
+ ids.emplace_back(pelID(pel->id()), obmcID(1));
+ }
+ {
+ auto data = pelDataFactory(TestPelType::pelSimple);
+ auto pel = std::make_unique<PEL>(*data, 2);
+ pel->assignID();
+ repo.add(pel);
+ ids.emplace_back(pelID(pel->id()), obmcID(2));
+ }
+
+ // Check they're there
+ EXPECT_TRUE(repo.hasPEL(ids[0]));
+ EXPECT_TRUE(repo.hasPEL(ids[1]));
+
+ // Do some other search tests while we're here.
+
+ // Search based on PEL ID
+ Repository::LogID id(pelID(ids[0].pelID));
+ EXPECT_TRUE(repo.hasPEL(id));
+
+ // Search based on OBMC log ID
+ id.pelID.id = 0;
+ id.obmcID = ids[0].obmcID;
+ EXPECT_TRUE(repo.hasPEL(id));
+
+ // ... based on the other PEL ID
+ id.pelID = ids[1].pelID;
+ id.obmcID.id = 0;
+ EXPECT_TRUE(repo.hasPEL(id));
+
+ // Not found
+ id.pelID.id = 99;
+ id.obmcID.id = 100;
+ EXPECT_FALSE(repo.hasPEL(id));
+ }
+
+ {
+ // Restore and check they're still there, then
+ // remove them.
+ Repository repo{repoPath};
+ EXPECT_TRUE(repo.hasPEL(ids[0]));
+ EXPECT_TRUE(repo.hasPEL(ids[1]));
+
+ repo.remove(ids[0]);
+ EXPECT_FALSE(repo.hasPEL(ids[0]));
+
+ repo.remove(ids[1]);
+ EXPECT_FALSE(repo.hasPEL(ids[1]));
+ }
+}
OpenPOWER on IntegriCloud