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());