Fix CI error
The test case doUpdateOnePSUNotPresent() recently started failing in CI
on the meson pass that contains the following option:
* -Db_sanitize=address,undefined
This option turns on memory checking, and that results in slightly
different gtest execution.
There appears to be one or more gmock bugs when ON_CALL and EXPECT_CALL
are used on the same mock method. Modify doUpdateOnePSUNotPresent() to
use ON_CALL instead of EXPECT_CALL. This is consistent with the other
methods in this file.
Also wrap the SdBusMock objects in test cases with NiceMock<> to
simplify future test case debug. The test cases do not set many
expectations on the sdbusplus functions that are called, and this
results in a huge number of 'Uninteresting mock function call' warning
messages. Using NiceMock eliminates these warnings.
Tested:
* Verified all automated test cases pass
Change-Id: I9f7ef8f314378ad928579c3b5707aab4fa091a23
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/test/test_activation.cpp b/test/test_activation.cpp
index 0af1b71..97cba77 100644
--- a/test/test_activation.cpp
+++ b/test/test_activation.cpp
@@ -11,6 +11,7 @@
using namespace phosphor::software::updater;
using ::testing::_;
+using ::testing::NiceMock;
using ::testing::Return;
using ::testing::StrEq;
@@ -69,7 +70,7 @@
return activation->getUpdateService(psuInventoryPath);
}
- sdbusplus::SdBusMock sdbusMock;
+ NiceMock<sdbusplus::SdBusMock> sdbusMock;
sdbusplus::bus_t mockedBus = sdbusplus::get_mocked_new(&sdbusMock);
const utils::MockedUtils& mockedUtils;
MockedAssociationInterface mockedAssociationInterface;
@@ -271,8 +272,8 @@
filePath, &mockedAssociationInterface, &mockedActivationListener);
ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(Return(std::vector<std::string>({psu0})));
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, _, _, _, StrEq(PRESENT)))
- .WillOnce(Return(any(PropertyType(false)))); // not present
+ ON_CALL(mockedUtils, getPropertyImpl(_, _, _, _, StrEq(PRESENT)))
+ .WillByDefault(Return(any(PropertyType(false)))); // not present
activation->requestedActivation(RequestedStatus::Active);
EXPECT_EQ(Status::Ready, activation->activation());
diff --git a/test/test_item_updater.cpp b/test/test_item_updater.cpp
index 4f9af37..6c96d84 100644
--- a/test/test_item_updater.cpp
+++ b/test/test_item_updater.cpp
@@ -9,6 +9,7 @@
using namespace phosphor::software::updater;
using ::testing::_;
using ::testing::ContainerEq;
+using ::testing::NiceMock;
using ::testing::Pointee;
using ::testing::Return;
using ::testing::ReturnArg;
@@ -63,7 +64,7 @@
}
static constexpr auto dBusPath = SOFTWARE_OBJPATH;
- sdbusplus::SdBusMock sdbusMock;
+ NiceMock<sdbusplus::SdBusMock> sdbusMock;
sdbusplus::bus_t mockedBus = sdbusplus::get_mocked_new(&sdbusMock);
const utils::MockedUtils& mockedUtils;
std::unique_ptr<ItemUpdater> itemUpdater;
diff --git a/test/test_utils.cpp b/test/test_utils.cpp
index d12e1f3..16912b5 100644
--- a/test/test_utils.cpp
+++ b/test/test_utils.cpp
@@ -10,12 +10,13 @@
using ::testing::_;
using ::testing::Invoke;
using ::testing::IsNull;
+using ::testing::NiceMock;
using ::testing::Return;
using ::testing::StrEq;
TEST(Utils, GetPSUInventoryPath)
{
- sdbusplus::SdBusMock sdbusMock;
+ NiceMock<sdbusplus::SdBusMock> sdbusMock;
auto bus = sdbusplus::get_mocked_new(&sdbusMock);
EXPECT_CALL(sdbusMock, sd_bus_message_new_method_call(