summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-11-06 16:19:46 -0600
committerMatt Spinler <spinler@us.ibm.com>2019-12-03 15:08:08 -0600
commit0ff00485b1e8f9b57eafc2065b3b8cd82471c58d (patch)
tree9b4200769f540bfe4d834164e69cfc804e7d4f97 /test
parent421f6531c5563d1e4e66b17062ebb9e632ca967b (diff)
downloadphosphor-logging-0ff00485b1e8f9b57eafc2065b3b8cd82471c58d.tar.gz
phosphor-logging-0ff00485b1e8f9b57eafc2065b3b8cd82471c58d.zip
PEL: Keep PEL attributes in Repository map
Instead of the Repository class only storing the path to a PEL file for a corresponding PEL ID, change it to a structure that includes the PEL's size and action flags as well as the path. This way, a PEL won't have to be read from the filesystem to find these values every time someone needs them. These new fields will be needed by the code that sends PELs to the host. Change-Id: I7650b6cbad12cc120426854767403f5cba2ee572
Diffstat (limited to 'test')
-rw-r--r--test/openpower-pels/repository_test.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/openpower-pels/repository_test.cpp b/test/openpower-pels/repository_test.cpp
index 34de855..8596840 100644
--- a/test/openpower-pels/repository_test.cpp
+++ b/test/openpower-pels/repository_test.cpp
@@ -255,3 +255,48 @@ TEST_F(RepositoryTest, TestSubscriptions)
repo.remove(id);
EXPECT_EQ(removed.size(), 0);
}
+
+TEST_F(RepositoryTest, TestGetAttributes)
+{
+ uint32_t pelID = 0;
+ std::bitset<16> actionFlags;
+
+ {
+ Repository repo{repoPath};
+
+ // Add a PEL to the repo
+ auto data = pelDataFactory(TestPELType::pelSimple);
+ auto pel = std::make_unique<PEL>(data);
+ repo.add(pel);
+
+ pelID = pel->id();
+ actionFlags = pel->userHeader().actionFlags();
+
+ using ID = Repository::LogID;
+ ID id{ID::Pel(pelID)};
+
+ auto a = repo.getPELAttributes(id);
+ EXPECT_TRUE(a);
+ EXPECT_EQ((*a).get().actionFlags, actionFlags);
+
+ id.pelID.id = 0;
+ a = repo.getPELAttributes(id);
+ EXPECT_FALSE(a);
+ }
+
+ {
+ // Restore the repository and check again
+ Repository repo{repoPath};
+
+ using ID = Repository::LogID;
+ ID id{ID::Pel(pelID)};
+
+ auto a = repo.getPELAttributes(id);
+ EXPECT_TRUE(a);
+ EXPECT_EQ((*a).get().actionFlags, actionFlags);
+
+ id.pelID.id = 0;
+ a = repo.getPELAttributes(id);
+ EXPECT_FALSE(a);
+ }
+}
OpenPOWER on IntegriCloud