PEL:test: Refactor mocked checkDumpStatus usage
When creating an instance of the SRC class in a testcase, it needs a
filled in mock of the checkDumpStatus() function. Instead of manually
doing that everywhere a PEL or SRC class is created, just do it in the
constructor of the mock DataInterface class.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I74790c67251465aae87d318ea37891d9eabab5e5
diff --git a/test/openpower-pels/mocks.hpp b/test/openpower-pels/mocks.hpp
index 094c670..103d7e8 100644
--- a/test/openpower-pels/mocks.hpp
+++ b/test/openpower-pels/mocks.hpp
@@ -18,7 +18,13 @@
class MockDataInterface : public DataInterfaceBase
{
public:
- MockDataInterface() {}
+ MockDataInterface()
+ {
+ ON_CALL(*this, checkDumpStatus)
+ .WillByDefault(
+ ::testing::Return(std::vector<bool>({false, false, false})));
+ }
+
MOCK_METHOD(std::string, getMachineTypeModel, (), (const override));
MOCK_METHOD(std::string, getMachineSerialNumber, (), (const override));
MOCK_METHOD(std::string, getServerFWVersion, (), (const override));
diff --git a/test/openpower-pels/pel_manager_test.cpp b/test/openpower-pels/pel_manager_test.cpp
index da3f2c6..5f0e579 100644
--- a/test/openpower-pels/pel_manager_test.cpp
+++ b/test/openpower-pels/pel_manager_test.cpp
@@ -282,14 +282,6 @@
std::unique_ptr<DataInterfaceBase> dataIface =
std::make_unique<MockDataInterface>();
- MockDataInterface* mockIface =
- reinterpret_cast<MockDataInterface*>(dataIface.get());
-
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(*mockIface, checkDumpStatus(dumpType))
- .WillRepeatedly(Return(std::vector<bool>{false, false, false}));
-
std::unique_ptr<JournalBase> journal = std::make_unique<MockJournal>();
openpower::pels::Manager manager{
@@ -903,11 +895,6 @@
MockDataInterface* mockIface =
reinterpret_cast<MockDataInterface*>(dataIface.get());
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(*mockIface, checkDumpStatus(dumpType))
- .WillRepeatedly(Return(std::vector<bool>{false, false, false}));
-
std::unique_ptr<JournalBase> journal = std::make_unique<MockJournal>();
openpower::pels::Manager manager{
@@ -1101,14 +1088,6 @@
std::unique_ptr<DataInterfaceBase> dataIface =
std::make_unique<MockDataInterface>();
- MockDataInterface* mockIface =
- reinterpret_cast<MockDataInterface*>(dataIface.get());
-
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(*mockIface, checkDumpStatus(dumpType))
- .WillRepeatedly(Return(std::vector<bool>{false, false, false}));
-
std::unique_ptr<JournalBase> journal = std::make_unique<MockJournal>();
openpower::pels::Manager manager{
diff --git a/test/openpower-pels/pel_test.cpp b/test/openpower-pels/pel_test.cpp
index 9fa8f2b..a996358 100644
--- a/test/openpower-pels/pel_test.cpp
+++ b/test/openpower-pels/pel_test.cpp
@@ -167,11 +167,6 @@
NiceMock<MockJournal> journal;
PelFFDC ffdc;
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillRepeatedly(Return(std::vector<bool>{false, false, false}));
-
PEL pel{regEntry, 42, timestamp, phosphor::logging::Entry::Level::Error,
ad, ffdc, dataIface, journal};
@@ -248,11 +243,6 @@
NiceMock<MockDataInterface> dataIface;
NiceMock<MockJournal> journal;
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
PEL pel{regEntry, 42, timestamp, phosphor::logging::Entry::Level::Error,
ad, ffdc, dataIface, journal};
@@ -777,11 +767,6 @@
ffdc.emplace_back(std::move(getCustomFFDC(dir, customData)));
ffdc.emplace_back(std::move(getCustomFFDC(dir, hugeCustomData)));
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
PEL pel{regEntry, 42, timestamp, phosphor::logging::Entry::Level::Error,
ad, ffdc, dataIface, journal};
@@ -870,11 +855,6 @@
.WillOnce(DoAll(SetArgReferee<1>("1234567"), SetArgReferee<2>("CCCC"),
SetArgReferee<3>("123456789ABC")));
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillRepeatedly(Return(std::vector<bool>{false, false, false}));
-
auto dataPath = getPELReadOnlyDataPath();
std::ofstream file{dataPath / "systemA_dev_callouts.json"};
file << calloutJSON;
@@ -1015,11 +995,6 @@
.WillOnce(DoAll(SetArgReferee<1>("1234567"), SetArgReferee<2>("CCCC"),
SetArgReferee<3>("123456789ABC")));
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
message::Entry regEntry;
regEntry.name = "test";
regEntry.subsystem = 5;
@@ -1087,11 +1062,6 @@
NiceMock<MockDataInterface> dataIface;
NiceMock<MockJournal> journal;
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillRepeatedly(Return(std::vector<bool>{false, false, false}));
-
message::Entry regEntry;
regEntry.name = "test";
regEntry.subsystem = 5;
@@ -1170,11 +1140,6 @@
NiceMock<MockJournal> journal;
PelFFDC ffdc;
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillRepeatedly(Return(std::vector<bool>{false, false, false}));
-
size_t pelSectsWithOneUD{0};
{
diff --git a/test/openpower-pels/src_test.cpp b/test/openpower-pels/src_test.cpp
index ed8af4b..bb1ba7c 100644
--- a/test/openpower-pels/src_test.cpp
+++ b/test/openpower-pels/src_test.cpp
@@ -205,11 +205,6 @@
EXPECT_CALL(dataIface, getMotherboardCCIN).WillOnce(Return("ABCD"));
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
SRC src{entry, ad, dataIface};
EXPECT_TRUE(src.valid());
@@ -269,11 +264,6 @@
AdditionalData ad{adData};
NiceMock<MockDataInterface> dataIface;
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillRepeatedly(Return(std::vector<bool>{false, false, false}));
-
// First it isn't a number, then it is too long,
// then it is empty.
EXPECT_CALL(dataIface, getMotherboardCCIN)
@@ -316,11 +306,6 @@
AdditionalData ad{adData};
NiceMock<MockDataInterface> dataIface;
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
SRC src{*entry, ad, dataIface};
EXPECT_TRUE(src.valid());
@@ -351,11 +336,6 @@
.WillOnce(DoAll(SetArgReferee<1>("1234567"), SetArgReferee<2>("CCCC"),
SetArgReferee<3>("123456789ABC")));
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
SRC src{entry, ad, dataIface};
EXPECT_TRUE(src.valid());
@@ -408,11 +388,6 @@
.Times(1)
.WillOnce(InvokeWithoutArgs(func));
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
EXPECT_CALL(dataIface, getHWCalloutFields(_, _, _, _)).Times(0);
SRC src{entry, ad, dataIface};
@@ -454,11 +429,6 @@
.Times(1)
.WillOnce(InvokeWithoutArgs(func));
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
SRC src{entry, ad, dataIface};
EXPECT_TRUE(src.valid());
ASSERT_TRUE(src.callouts());
@@ -550,11 +520,6 @@
EXPECT_CALL(dataIface, getSystemNames).WillOnce(Return(names));
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
SRC src{entry, ad, dataIface};
const auto& hexwords = src.hexwordData();
@@ -596,11 +561,6 @@
EXPECT_CALL(dataIface, expandLocationCode).WillOnce(Return("P0-C8"));
EXPECT_CALL(dataIface, getSystemNames).WillOnce(Return(names));
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
SRC src{entry, ad, dataIface};
auto& callouts = src.callouts()->callouts();
@@ -636,11 +596,6 @@
NiceMock<MockDataInterface> dataIface;
std::vector<std::string> names{"systemC"};
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
EXPECT_CALL(dataIface, getSystemNames).WillOnce(Return(names));
EXPECT_CALL(dataIface, expandLocationCode("P0-C8", 0))
@@ -736,11 +691,6 @@
NiceMock<MockDataInterface> dataIface;
std::vector<std::string> names{"systemA"};
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
EXPECT_CALL(dataIface, getSystemNames).WillOnce(Return(names));
EXPECT_CALL(dataIface, getLocationCode("motherboard"))
@@ -794,11 +744,6 @@
NiceMock<MockDataInterface> dataIface;
std::vector<std::string> names{"systemA"};
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
EXPECT_CALL(dataIface, getSystemNames).WillOnce(Return(names));
SRC src{entry, ad, dataIface};
@@ -861,11 +806,6 @@
NiceMock<MockDataInterface> dataIface;
std::vector<std::string> names{"systemA"};
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillRepeatedly(Return(std::vector<bool>{false, false, false}));
-
EXPECT_CALL(dataIface, getSystemNames)
.Times(5)
.WillRepeatedly(Return(names));
@@ -1083,11 +1023,6 @@
AdditionalData ad;
NiceMock<MockDataInterface> dataIface;
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
// Callout 0 mock calls
{
EXPECT_CALL(dataIface, expandLocationCode("P0-C1", 0))
@@ -1274,11 +1209,6 @@
AdditionalData ad;
NiceMock<MockDataInterface> dataIface;
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillRepeatedly(Return(std::vector<bool>{false, false, false}));
-
// Callout 0 mock calls
// Expand location code will fail, so the unexpanded location
// code should show up in the callout instead.
@@ -1359,11 +1289,6 @@
AdditionalData ad{adData};
NiceMock<MockDataInterface> dataIface;
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
EXPECT_CALL(dataIface, getLocationCode("motherboard"))
.WillOnce(Return("UTMS-P1"));
@@ -1458,11 +1383,6 @@
EXPECT_CALL(dataIface, getMotherboardCCIN).WillOnce(Return("ABCD"));
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
-
SRC src{entry, ad, dataIface};
EXPECT_TRUE(src.valid());
@@ -1549,10 +1469,6 @@
AdditionalData ad;
NiceMock<MockDataInterface> dataIface;
- std::vector<std::string> dumpType{"bmc/entry", "resource/entry",
- "system/entry"};
- EXPECT_CALL(dataIface, checkDumpStatus(dumpType))
- .WillOnce(Return(std::vector<bool>{false, false, false}));
EXPECT_CALL(dataIface, getRawProgressSRC())
.WillOnce(Return(std::vector<uint8_t>{
2, 8, 0, 9, 0, 0, 0, 72, 0, 0, 0, 224, 0, 0, 0,