summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-10-11 10:39:30 -0500
committerMatt Spinler <spinler@us.ibm.com>2019-10-22 09:10:37 -0500
commit42828bd922d6e067089770112de5ec22d2df8ab1 (patch)
tree61a552dbfaa53f7eb1e3104a8a8d73f60548e15f /test
parent31eed996da81cf6e35e7ddd035aa8088be230218 (diff)
downloadphosphor-logging-42828bd922d6e067089770112de5ec22d2df8ab1.tar.gz
phosphor-logging-42828bd922d6e067089770112de5ec22d2df8ab1.zip
PEL: Refactor the test data factory
This commit has no functional changes, it just does some things to make the PEL data creator for testcases, pelDataFactory(), be more manageable: - Change to return a plain vector instead of a unique_ptr<vector>. - Keeps the data for each section in separate vectors and then either returns those as-is or combines them into a PEL. - Change the TestPelType enum to TestPELType to match the style guide. - Have pelDataFactory provide the SRC section instead of srcDataFactory. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I4770aa6a8169e89b6b8f685a9994d845c9e93cfe
Diffstat (limited to 'test')
-rw-r--r--test/openpower-pels/generic_section_test.cpp18
-rw-r--r--test/openpower-pels/pel_manager_test.cpp4
-rw-r--r--test/openpower-pels/pel_test.cpp50
-rw-r--r--test/openpower-pels/pel_utils.cpp151
-rw-r--r--test/openpower-pels/pel_utils.hpp16
-rw-r--r--test/openpower-pels/private_header_test.cpp32
-rw-r--r--test/openpower-pels/repository_test.cpp18
-rw-r--r--test/openpower-pels/src_test.cpp4
-rw-r--r--test/openpower-pels/user_header_test.cpp28
9 files changed, 161 insertions, 160 deletions
diff --git a/test/openpower-pels/generic_section_test.cpp b/test/openpower-pels/generic_section_test.cpp
index 9fb6d9a..7cb9949 100644
--- a/test/openpower-pels/generic_section_test.cpp
+++ b/test/openpower-pels/generic_section_test.cpp
@@ -8,13 +8,13 @@ using namespace openpower::pels;
TEST(GenericSectionTest, UnflattenFlattenTest)
{
// Use the private header data
- auto data = pelDataFactory(TestPelType::privateHeaderSimple);
+ auto data = pelDataFactory(TestPELType::privateHeaderSection);
- Stream stream(*data);
+ Stream stream(data);
Generic section(stream);
EXPECT_EQ(section.header().id, 0x5048);
- EXPECT_EQ(section.header().size, data->size());
+ EXPECT_EQ(section.header().size, data.size());
EXPECT_EQ(section.header().version, 0x01);
EXPECT_EQ(section.header().subType, 0x02);
EXPECT_EQ(section.header().componentID, 0x0304);
@@ -22,11 +22,11 @@ TEST(GenericSectionTest, UnflattenFlattenTest)
const auto& sectionData = section.data();
// The data itself starts after the header
- EXPECT_EQ(sectionData.size(), data->size() - 8);
+ EXPECT_EQ(sectionData.size(), data.size() - 8);
for (size_t i = 0; i < sectionData.size(); i++)
{
- EXPECT_EQ(sectionData[i], (*data)[i + 8]);
+ EXPECT_EQ(sectionData[i], (data)[i + 8]);
}
// Now flatten
@@ -34,16 +34,16 @@ TEST(GenericSectionTest, UnflattenFlattenTest)
Stream newStream(newData);
section.flatten(newStream);
- EXPECT_EQ(*data, newData);
+ EXPECT_EQ(data, newData);
}
TEST(GenericSectionTest, BadDataTest)
{
// Use the private header data to start with
- auto data = pelDataFactory(TestPelType::privateHeaderSimple);
- data->resize(4);
+ auto data = pelDataFactory(TestPELType::privateHeaderSection);
+ data.resize(4);
- Stream stream(*data);
+ Stream stream(data);
Generic section(stream);
ASSERT_FALSE(section.valid());
}
diff --git a/test/openpower-pels/pel_manager_test.cpp b/test/openpower-pels/pel_manager_test.cpp
index 61fbedd..9014dd8 100644
--- a/test/openpower-pels/pel_manager_test.cpp
+++ b/test/openpower-pels/pel_manager_test.cpp
@@ -34,11 +34,11 @@ TEST_F(ManagerTest, TestCreateWithPEL)
// Create a PEL, write it to a file, and pass that filename into
// the create function.
- auto data = pelDataFactory(TestPelType::pelSimple);
+ auto data = pelDataFactory(TestPELType::pelSimple);
fs::path pelFilename = makeTempDir() / "rawpel";
std::ofstream pelFile{pelFilename};
- pelFile.write(reinterpret_cast<const char*>(data->data()), data->size());
+ pelFile.write(reinterpret_cast<const char*>(data.data()), data.size());
pelFile.close();
std::string adItem = "RAWPEL=" + pelFilename.string();
diff --git a/test/openpower-pels/pel_test.cpp b/test/openpower-pels/pel_test.cpp
index 56e356f..b744432 100644
--- a/test/openpower-pels/pel_test.cpp
+++ b/test/openpower-pels/pel_test.cpp
@@ -17,9 +17,9 @@ class PELTest : public CleanLogID
TEST_F(PELTest, FlattenTest)
{
- auto data = pelDataFactory(TestPelType::pelSimple);
- auto origData = *data;
- auto pel = std::make_unique<PEL>(*data);
+ auto data = pelDataFactory(TestPELType::pelSimple);
+ auto origData = data;
+ auto pel = std::make_unique<PEL>(data);
// Check a few fields
EXPECT_TRUE(pel->valid());
@@ -35,8 +35,8 @@ TEST_F(PELTest, FlattenTest)
TEST_F(PELTest, CommitTimeTest)
{
- auto data = pelDataFactory(TestPelType::pelSimple);
- auto pel = std::make_unique<PEL>(*data);
+ auto data = pelDataFactory(TestPELType::pelSimple);
+ auto pel = std::make_unique<PEL>(data);
auto origTime = pel->commitTime();
pel->setCommitTime();
@@ -52,8 +52,8 @@ TEST_F(PELTest, CommitTimeTest)
TEST_F(PELTest, AssignIDTest)
{
- auto data = pelDataFactory(TestPelType::pelSimple);
- auto pel = std::make_unique<PEL>(*data);
+ auto data = pelDataFactory(TestPELType::pelSimple);
+ auto pel = std::make_unique<PEL>(data);
auto origID = pel->id();
pel->assignID();
@@ -69,8 +69,8 @@ TEST_F(PELTest, AssignIDTest)
TEST_F(PELTest, WithLogIDTest)
{
- auto data = pelDataFactory(TestPelType::pelSimple);
- auto pel = std::make_unique<PEL>(*data, 0x42);
+ auto data = pelDataFactory(TestPELType::pelSimple);
+ auto pel = std::make_unique<PEL>(data, 0x42);
EXPECT_TRUE(pel->valid());
EXPECT_EQ(pel->obmcLogID(), 0x42);
@@ -78,21 +78,21 @@ TEST_F(PELTest, WithLogIDTest)
TEST_F(PELTest, InvalidPELTest)
{
- auto data = pelDataFactory(TestPelType::pelSimple);
+ auto data = pelDataFactory(TestPELType::pelSimple);
// Too small
- data->resize(PrivateHeader::flattenedSize());
+ data.resize(PrivateHeader::flattenedSize());
- auto pel = std::make_unique<PEL>(*data);
+ auto pel = std::make_unique<PEL>(data);
EXPECT_TRUE(pel->privateHeader()->valid());
EXPECT_FALSE(pel->userHeader()->valid());
EXPECT_FALSE(pel->valid());
// Now corrupt the private header
- data = pelDataFactory(TestPelType::pelSimple);
- data->at(0) = 0;
- pel = std::make_unique<PEL>(*data);
+ data = pelDataFactory(TestPELType::pelSimple);
+ data.at(0) = 0;
+ pel = std::make_unique<PEL>(data);
EXPECT_FALSE(pel->privateHeader()->valid());
EXPECT_TRUE(pel->userHeader()->valid());
@@ -131,7 +131,7 @@ TEST_F(PELTest, CreateFromRegistryTest)
// there aren't explicit classes for.
TEST_F(PELTest, GenericSectionTest)
{
- auto data = pelDataFactory(TestPelType::pelSimple);
+ auto data = pelDataFactory(TestPELType::pelSimple);
std::vector<uint8_t> section1{0x58, 0x58, // ID 'XX'
0x00, 0x18, // Size
@@ -154,14 +154,14 @@ TEST_F(PELTest, GenericSectionTest)
0x09, 0x22, 0x3A, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
// Add the new sections at the end
- data->insert(data->end(), section1.begin(), section1.end());
- data->insert(data->end(), section2.begin(), section2.end());
+ data.insert(data.end(), section1.begin(), section1.end());
+ data.insert(data.end(), section2.begin(), section2.end());
// Increment the section count
- data->at(27) += 2;
- auto origData = *data;
+ data.at(27) += 2;
+ auto origData = data;
- PEL pel{*data};
+ PEL pel{data};
const auto& sections = pel.optionalSections();
@@ -195,17 +195,17 @@ TEST_F(PELTest, GenericSectionTest)
// Test that an invalid section will still get a Generic object
TEST_F(PELTest, InvalidGenericTest)
{
- auto data = pelDataFactory(TestPelType::pelSimple);
+ auto data = pelDataFactory(TestPELType::pelSimple);
// Not a valid section
std::vector<uint8_t> section1{0x01, 0x02, 0x03};
- data->insert(data->end(), section1.begin(), section1.end());
+ data.insert(data.end(), section1.begin(), section1.end());
// Increment the section count
- data->at(27) += 1;
+ data.at(27) += 1;
- PEL pel{*data};
+ PEL pel{data};
EXPECT_FALSE(pel.valid());
const auto& sections = pel.optionalSections();
diff --git a/test/openpower-pels/pel_utils.cpp b/test/openpower-pels/pel_utils.cpp
index 109c1ce..0af9bf5 100644
--- a/test/openpower-pels/pel_utils.cpp
+++ b/test/openpower-pels/pel_utils.cpp
@@ -15,15 +15,14 @@ std::filesystem::path CleanPELFiles::pelIDFile{};
std::filesystem::path CleanPELFiles::repoPath{};
std::filesystem::path CleanPELFiles::registryPath{};
-constexpr uint8_t simplePEL[] = {
- // private header section header
+const std::vector<uint8_t> privateHeaderSection{
+ // section header
0x50, 0x48, // ID 'PH'
0x00, 0x30, // Size
0x01, 0x02, // version, subtype
0x03, 0x04, // comp ID
- // private header
- 0x20, 0x30, 0x05, 0x09, 0x11, 0x1E, 0x1, 0x63, // create timestamp
+ 0x20, 0x30, 0x05, 0x09, 0x11, 0x1E, 0x1, 0x63, // create timestamp
0x20, 0x31, 0x06, 0x0F, 0x09, 0x22, 0x3A, 0x00, // commit timestamp
0xAA, // creatorID
0x00, // logtype
@@ -32,40 +31,56 @@ constexpr uint8_t simplePEL[] = {
0x90, 0x91, 0x92, 0x93, // OpenBMC log ID
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, // creator version
0x50, 0x51, 0x52, 0x53, // plid
- 0x80, 0x81, 0x82, 0x83, // id
+ 0x80, 0x81, 0x82, 0x83};
- // user header section header
+const std::vector<uint8_t> userHeaderSection{
+ // section header
0x55, 0x48, // ID 'UH'
0x00, 0x18, // Size
0x01, 0x0A, // version, subtype
0x0B, 0x0C, // comp ID
- // user header
0x10, 0x04, // subsystem, scope
0x20, 0x00, // severity, type
0x00, 0x00, 0x00, 0x00, // reserved
0x03, 0x04, // problem domain, vector
0x80, 0xC0, // action flags
0x00, 0x00, 0x00, 0x00 // reserved
-
- // Add more as the code supports more
};
-std::vector<uint8_t> srcFRUIdentityCallout{
+const std::vector<uint8_t> srcSectionNoCallouts{
+
+ // Header
+ 'P', 'S', 0x00, 0x80, 0x01, 0x01, 0x02, 0x02,
+
+ 0x02, 0x00, 0x00, // version, flags, reserved
+ 0x09, 0x00, 0x00, // hex word count, reserved2B
+ 0x00, 0x48, // SRC structure size
+
+ // Hex words 2 - 9
+ 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04,
+ 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07,
+ 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09,
+ // ASCII string
+ 'B', 'D', '8', 'D', '5', '6', '7', '8', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' '};
+
+const std::vector<uint8_t> srcFRUIdentityCallout{
'I', 'D', 0x1C, 0x1D, // type, size, flags
'1', '2', '3', '4', // PN
'5', '6', '7', 0x00, 'A', 'A', 'A', 'A', // CCIN
'1', '2', '3', '4', '5', '6', '7', '8', // SN
'9', 'A', 'B', 'C'};
-std::vector<uint8_t> srcPCEIdentityCallout{
+const std::vector<uint8_t> srcPCEIdentityCallout{
'P', 'E', 0x24, 0x00, // type, size, flags
'T', 'T', 'T', 'T', '-', 'M', 'M', 'M', // MTM
'1', '2', '3', '4', '5', '6', '7', // SN
'8', '9', 'A', 'B', 'C', 'P', 'C', 'E', // Name + null padded
'N', 'A', 'M', 'E', '1', '2', 0x00, 0x00, 0x00};
-std::vector<uint8_t> srcMRUCallout{
+const std::vector<uint8_t> srcMRUCallout{
'M', 'R', 0x28, 0x04, // ID, size, flags
0x00, 0x00, 0x00, 0x00, // Reserved
0x00, 0x00, 0x00, 'H', // priority 0
@@ -78,44 +93,62 @@ std::vector<uint8_t> srcMRUCallout{
0x04, 0x04, 0x04, 0x04, // MRU ID 3
};
-std::vector<uint8_t> srcSectionNoCallouts{
-
- // Header
- 'P', 'S', 0x00, 0x80, 0x01, 0x01, 0x02, 0x02,
-
- // SRC
- 0x02, 0x00, 0x00, // version, flags, reserved
- 0x09, 0x00, 0x00, // hex word count, reserved2B
- 0x00, 0x48, // SRC structure size
-
- // Hex words 2 - 9
- 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04,
- 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07,
- 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09,
- // ASCII string
- 'B', 'D', '8', 'D', '5', '6', '7', '8', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
- ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
- ' ', ' '};
+constexpr size_t sectionCountOffset = 27;
-std::unique_ptr<std::vector<uint8_t>> pelDataFactory(TestPelType type)
+std::vector<uint8_t> pelDataFactory(TestPELType type)
{
- std::unique_ptr<std::vector<uint8_t>> data;
+ std::vector<uint8_t> data;
+
switch (type)
{
- case TestPelType::pelSimple:
- data = std::make_unique<std::vector<uint8_t>>(
- simplePEL, simplePEL + sizeof(simplePEL));
+ case TestPELType::pelSimple:
+ data.insert(data.end(), privateHeaderSection.begin(),
+ privateHeaderSection.end());
+ data.insert(data.end(), userHeaderSection.begin(),
+ userHeaderSection.end());
+ data.at(sectionCountOffset) = 2;
break;
- case TestPelType::privateHeaderSimple:
- data = std::make_unique<std::vector<uint8_t>>(
- simplePEL, simplePEL + PrivateHeader::flattenedSize());
+ case TestPELType::privateHeaderSection:
+ data.insert(data.end(), privateHeaderSection.begin(),
+ privateHeaderSection.end());
break;
- case TestPelType::userHeaderSimple:
- data = std::make_unique<std::vector<uint8_t>>(
- simplePEL + PrivateHeader::flattenedSize(),
- simplePEL + PrivateHeader::flattenedSize() +
- UserHeader::flattenedSize());
+ case TestPELType::userHeaderSection:
+ data.insert(data.end(), userHeaderSection.begin(),
+ userHeaderSection.end());
break;
+ case TestPELType::primarySRCSection:
+ data.insert(data.end(), srcSectionNoCallouts.begin(),
+ srcSectionNoCallouts.end());
+ break;
+ case TestPELType::primarySRCSection2Callouts:
+ {
+ // Start with the no-callouts SRC, and add the callouts section
+ // from above.
+ auto src = srcSectionNoCallouts;
+ auto callouts =
+ srcDataFactory(TestSRCType::calloutSection2Callouts);
+
+ src.insert(src.end(), callouts.begin(), callouts.end());
+
+ // Set the flag that says there are callouts
+ // One byte after the 8B header
+ src[8 + 1] |= 0x01;
+
+ // Set the new sizes
+ uint16_t size = src.size();
+ Stream stream{src};
+
+ stream.offset(2); // In the header
+ stream << size;
+
+ // In the SRC - the size field doesn't include the header
+ size -= 8;
+ stream.offset(8 + 6);
+ stream << size;
+
+ data.insert(data.end(), src.begin(), src.end());
+ break;
+ }
}
return data;
}
@@ -187,38 +220,6 @@ std::vector<uint8_t> srcDataFactory(TestSRCType type)
return data;
}
- case TestSRCType::primarySRCNoCallouts:
- {
- return srcSectionNoCallouts;
- }
- case TestSRCType::primarySRC2Callouts:
- {
- // Start with the no-callouts SRC, and add the callouts section
- // from above.
- auto src = srcSectionNoCallouts;
- auto callouts =
- srcDataFactory(TestSRCType::calloutSection2Callouts);
-
- src.insert(src.end(), callouts.begin(), callouts.end());
-
- // Set the flag that says there are callouts
- // One byte after the 8B header
- src[8 + 1] |= 0x01;
-
- // Set the new sizes
- uint16_t size = src.size();
- Stream stream{src};
-
- stream.offset(2); // In the header
- stream << size;
-
- // In the SRC - the size field doesn't include the header
- size -= 8;
- stream.offset(8 + 6);
- stream << size;
-
- return src;
- }
}
return {};
}
diff --git a/test/openpower-pels/pel_utils.hpp b/test/openpower-pels/pel_utils.hpp
index 6d70dfa..fb608b8 100644
--- a/test/openpower-pels/pel_utils.hpp
+++ b/test/openpower-pels/pel_utils.hpp
@@ -52,11 +52,13 @@ class CleanPELFiles : public ::testing::Test
/**
* @brief Tells the factory which PEL to create
*/
-enum class TestPelType
+enum class TestPELType
{
pelSimple,
- privateHeaderSimple,
- userHeaderSimple
+ privateHeaderSection,
+ userHeaderSection,
+ primarySRCSection,
+ primarySRCSection2Callouts
};
/**
@@ -69,9 +71,7 @@ enum class TestSRCType
mruStructure,
calloutStructureA,
calloutStructureB,
- calloutSection2Callouts,
- primarySRCNoCallouts,
- primarySRC2Callouts
+ calloutSection2Callouts
};
/**
@@ -79,9 +79,9 @@ enum class TestSRCType
*
* @param[in] type - the type of data to create
*
- * @return std::unique_ptr<std::vector<uint8_t>> - the PEL data
+ * @return std::vector<uint8_t> - the PEL data
*/
-std::unique_ptr<std::vector<uint8_t>> pelDataFactory(TestPelType type);
+std::vector<uint8_t> pelDataFactory(TestPELType type);
/**
* @brief SRC data factory, for testing
diff --git a/test/openpower-pels/private_header_test.cpp b/test/openpower-pels/private_header_test.cpp
index ebb515c..07746b3 100644
--- a/test/openpower-pels/private_header_test.cpp
+++ b/test/openpower-pels/private_header_test.cpp
@@ -16,9 +16,9 @@ TEST_F(PrivateHeaderTest, SizeTest)
TEST_F(PrivateHeaderTest, UnflattenFlattenTest)
{
- auto data = pelDataFactory(TestPelType::privateHeaderSimple);
+ auto data = pelDataFactory(TestPELType::privateHeaderSection);
- Stream stream(*data);
+ Stream stream(data);
PrivateHeader ph(stream);
EXPECT_EQ(ph.valid(), true);
@@ -65,7 +65,7 @@ TEST_F(PrivateHeaderTest, UnflattenFlattenTest)
Stream newStream(newData);
ph.flatten(newStream);
- EXPECT_EQ(*data, newData);
+ EXPECT_EQ(data, newData);
// Change a field, then flatten and unflatten again
ph.creatorID() = 0x55;
@@ -73,7 +73,7 @@ TEST_F(PrivateHeaderTest, UnflattenFlattenTest)
newStream.offset(0);
newData.clear();
ph.flatten(newStream);
- EXPECT_NE(*data, newData);
+ EXPECT_NE(data, newData);
newStream.offset(0);
PrivateHeader newPH(newStream);
@@ -84,9 +84,9 @@ TEST_F(PrivateHeaderTest, UnflattenFlattenTest)
TEST_F(PrivateHeaderTest, ShortDataTest)
{
- auto data = pelDataFactory(TestPelType::privateHeaderSimple);
- data->resize(PrivateHeader::flattenedSize() - 1);
- Stream stream(*data);
+ auto data = pelDataFactory(TestPELType::privateHeaderSection);
+ data.resize(PrivateHeader::flattenedSize() - 1);
+ Stream stream(data);
PrivateHeader ph(stream);
@@ -95,10 +95,10 @@ TEST_F(PrivateHeaderTest, ShortDataTest)
TEST_F(PrivateHeaderTest, CorruptDataTest1)
{
- auto data = pelDataFactory(TestPelType::privateHeaderSimple);
- Stream stream(*data);
+ auto data = pelDataFactory(TestPELType::privateHeaderSection);
+ Stream stream(data);
- data->at(0) = 0; // corrupt the section ID
+ data.at(0) = 0; // corrupt the section ID
PrivateHeader ph(stream);
@@ -107,10 +107,10 @@ TEST_F(PrivateHeaderTest, CorruptDataTest1)
TEST_F(PrivateHeaderTest, CorruptDataTest2)
{
- auto data = pelDataFactory(TestPelType::privateHeaderSimple);
- Stream stream(*data);
+ auto data = pelDataFactory(TestPELType::privateHeaderSection);
+ Stream stream(data);
- data->at(4) = 0x22; // corrupt the version
+ data.at(4) = 0x22; // corrupt the version
PrivateHeader ph(stream);
@@ -119,10 +119,10 @@ TEST_F(PrivateHeaderTest, CorruptDataTest2)
TEST_F(PrivateHeaderTest, CorruptDataTest3)
{
- auto data = pelDataFactory(TestPelType::privateHeaderSimple);
- Stream stream(*data);
+ auto data = pelDataFactory(TestPELType::privateHeaderSection);
+ Stream stream(data);
- data->at(27) = 1; // corrupt the section count
+ data.at(27) = 1; // corrupt the section count
PrivateHeader ph(stream);
diff --git a/test/openpower-pels/repository_test.cpp b/test/openpower-pels/repository_test.cpp
index 57952e3..85ceab6 100644
--- a/test/openpower-pels/repository_test.cpp
+++ b/test/openpower-pels/repository_test.cpp
@@ -54,8 +54,8 @@ TEST_F(RepositoryTest, FilenameTest)
TEST_F(RepositoryTest, AddTest)
{
Repository repo{repoPath};
- auto data = pelDataFactory(TestPelType::pelSimple);
- auto pel = std::make_unique<PEL>(*data);
+ auto data = pelDataFactory(TestPELType::pelSimple);
+ auto pel = std::make_unique<PEL>(data);
repo.add(pel);
@@ -84,15 +84,15 @@ TEST_F(RepositoryTest, RestoreTest)
// Add some PELs to the repository
{
- auto data = pelDataFactory(TestPelType::pelSimple);
- auto pel = std::make_unique<PEL>(*data, 1);
+ 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);
+ 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));
@@ -149,9 +149,9 @@ TEST_F(RepositoryTest, TestGetPELData)
EXPECT_FALSE(noData);
// Add a PEL to the repo, and get the data back with getPELData.
- auto data = pelDataFactory(TestPelType::pelSimple);
- auto dataCopy = *data;
- auto pel = std::make_unique<PEL>(*data);
+ auto data = pelDataFactory(TestPELType::pelSimple);
+ auto dataCopy = data;
+ auto pel = std::make_unique<PEL>(data);
auto pelID = pel->id();
repo.add(pel);
diff --git a/test/openpower-pels/src_test.cpp b/test/openpower-pels/src_test.cpp
index 7af3306..7596186 100644
--- a/test/openpower-pels/src_test.cpp
+++ b/test/openpower-pels/src_test.cpp
@@ -7,7 +7,7 @@ using namespace openpower::pels;
TEST(SRCTest, UnflattenFlattenTestNoCallouts)
{
- auto data = srcDataFactory(TestSRCType::primarySRCNoCallouts);
+ auto data = pelDataFactory(TestPELType::primarySRCSection);
Stream stream{data};
SRC src{stream};
@@ -48,7 +48,7 @@ TEST(SRCTest, UnflattenFlattenTestNoCallouts)
TEST(SRCTest, UnflattenFlattenTest2Callouts)
{
- auto data = srcDataFactory(TestSRCType::primarySRC2Callouts);
+ auto data = pelDataFactory(TestPELType::primarySRCSection2Callouts);
Stream stream{data};
SRC src{stream};
diff --git a/test/openpower-pels/user_header_test.cpp b/test/openpower-pels/user_header_test.cpp
index d3eedfc..88ac9a5 100644
--- a/test/openpower-pels/user_header_test.cpp
+++ b/test/openpower-pels/user_header_test.cpp
@@ -15,9 +15,9 @@ TEST(UserHeaderTest, SizeTest)
TEST(UserHeaderTest, UnflattenFlattenTest)
{
- auto data = pelDataFactory(TestPelType::userHeaderSimple);
+ auto data = pelDataFactory(TestPELType::userHeaderSection);
- Stream stream(*data);
+ Stream stream(data);
UserHeader uh(stream);
EXPECT_EQ(uh.valid(), true);
@@ -41,7 +41,7 @@ TEST(UserHeaderTest, UnflattenFlattenTest)
Stream newStream(newData);
uh.flatten(newStream);
- EXPECT_EQ(*data, newData);
+ EXPECT_EQ(data, newData);
// Change a field, then flatten and unflatten again
uh.subsystem() = 0x44;
@@ -49,7 +49,7 @@ TEST(UserHeaderTest, UnflattenFlattenTest)
newStream.offset(0);
newData.clear();
uh.flatten(newStream);
- EXPECT_NE(*data, newData);
+ EXPECT_NE(data, newData);
newStream.offset(0);
UserHeader newUH(newStream);
@@ -60,10 +60,10 @@ TEST(UserHeaderTest, UnflattenFlattenTest)
TEST(UserHeaderTest, ShortDataTest)
{
- auto data = pelDataFactory(TestPelType::userHeaderSimple);
- data->resize(data->size() - 1);
+ auto data = pelDataFactory(TestPELType::userHeaderSection);
+ data.resize(data.size() - 1);
- Stream stream(*data);
+ Stream stream(data);
UserHeader uh(stream);
EXPECT_EQ(uh.valid(), false);
@@ -71,12 +71,12 @@ TEST(UserHeaderTest, ShortDataTest)
TEST(UserHeaderTest, CorruptDataTest1)
{
- auto data = pelDataFactory(TestPelType::userHeaderSimple);
- data->resize(data->size() - 1);
+ auto data = pelDataFactory(TestPELType::userHeaderSection);
+ data.resize(data.size() - 1);
- data->at(0) = 0; // corrupt the section ID
+ data.at(0) = 0; // corrupt the section ID
- Stream stream(*data);
+ Stream stream(data);
UserHeader uh(stream);
EXPECT_EQ(uh.valid(), false);
@@ -84,11 +84,11 @@ TEST(UserHeaderTest, CorruptDataTest1)
TEST(UserHeaderTest, CorruptDataTest2)
{
- auto data = pelDataFactory(TestPelType::userHeaderSimple);
+ auto data = pelDataFactory(TestPELType::userHeaderSection);
- data->at(4) = 0x22; // corrupt the version
+ data.at(4) = 0x22; // corrupt the version
- Stream stream(*data);
+ Stream stream(data);
UserHeader uh(stream);
EXPECT_EQ(uh.valid(), false);
OpenPOWER on IntegriCloud