Rename getPSUInventoryPath to getPSUInventoryPaths
Rename the utils method/function getPSUInventoryPath() to
getPSUInventoryPaths(). The method/function returns multiple paths in a
vector, so the name should be plural. This will make the return type
more clear. Currently the name implies only one path will be returned.
Tested:
* Verified all automated tests build and run successfully
* Verified getPSUInventoryPaths() returns correct data
Change-Id: I7e215c37e3ce1eb27313bc51348c7f7335c8f67a
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/src/activation.cpp b/src/activation.cpp
index ed985a1..c52e1b6 100644
--- a/src/activation.cpp
+++ b/src/activation.cpp
@@ -155,7 +155,7 @@
return activation(); // Return the previous activation status
}
- auto psuPaths = utils::getPSUInventoryPath(bus);
+ auto psuPaths = utils::getPSUInventoryPaths(bus);
if (psuPaths.empty())
{
lg2::warning("No PSU inventory found");
diff --git a/src/item_updater.cpp b/src/item_updater.cpp
index aea02ee..2760245 100644
--- a/src/item_updater.cpp
+++ b/src/item_updater.cpp
@@ -394,7 +394,7 @@
{
try
{
- auto paths = utils::getPSUInventoryPath(bus);
+ auto paths = utils::getPSUInventoryPaths(bus);
for (const auto& p : paths)
{
try
@@ -558,7 +558,7 @@
const auto& activation = it->second;
const auto& assocs = activation->associations();
- auto paths = utils::getPSUInventoryPath(bus);
+ auto paths = utils::getPSUInventoryPaths(bus);
for (const auto& p : paths)
{
// If there is a present PSU that is not associated with the latest
diff --git a/src/utils.cpp b/src/utils.cpp
index 6b7f602..abea750 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -59,7 +59,8 @@
return utils;
}
-std::vector<std::string> Utils::getPSUInventoryPath(sdbusplus::bus_t& bus) const
+std::vector<std::string>
+ Utils::getPSUInventoryPaths(sdbusplus::bus_t& bus) const
{
std::vector<std::string> paths;
try
diff --git a/src/utils.hpp b/src/utils.hpp
index 3b033fc..020d528 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -26,7 +26,7 @@
/**
* @brief Get PSU inventory object path from DBus
*/
-std::vector<std::string> getPSUInventoryPath(sdbusplus::bus_t& bus);
+std::vector<std::string> getPSUInventoryPaths(sdbusplus::bus_t& bus);
/** @brief Get service name from object path and interface
*
@@ -128,7 +128,7 @@
virtual ~UtilsInterface() = default;
virtual std::vector<std::string>
- getPSUInventoryPath(sdbusplus::bus_t& bus) const = 0;
+ getPSUInventoryPaths(sdbusplus::bus_t& bus) const = 0;
virtual std::string getService(sdbusplus::bus_t& bus, const char* path,
const char* interface) const = 0;
@@ -168,7 +168,7 @@
{
public:
std::vector<std::string>
- getPSUInventoryPath(sdbusplus::bus_t& bus) const override;
+ getPSUInventoryPaths(sdbusplus::bus_t& bus) const override;
std::string getService(sdbusplus::bus_t& bus, const char* path,
const char* interface) const override;
@@ -206,9 +206,9 @@
return getUtils().getServices(bus, path, interface);
}
-inline std::vector<std::string> getPSUInventoryPath(sdbusplus::bus_t& bus)
+inline std::vector<std::string> getPSUInventoryPaths(sdbusplus::bus_t& bus)
{
- return getUtils().getPSUInventoryPath(bus);
+ return getUtils().getPSUInventoryPaths(bus);
}
inline std::string getVersionId(const std::string& version)
diff --git a/test/mocked_utils.hpp b/test/mocked_utils.hpp
index 873c73b..7c293cf 100644
--- a/test/mocked_utils.hpp
+++ b/test/mocked_utils.hpp
@@ -16,7 +16,7 @@
~MockedUtils() override = default;
- MOCK_CONST_METHOD1(getPSUInventoryPath,
+ MOCK_CONST_METHOD1(getPSUInventoryPaths,
std::vector<std::string>(sdbusplus::bus_t& bus));
MOCK_CONST_METHOD3(getService,
diff --git a/test/test_activation.cpp b/test/test_activation.cpp
index 4beffbc..273f132 100644
--- a/test/test_activation.cpp
+++ b/test/test_activation.cpp
@@ -115,7 +115,7 @@
activation = std::make_unique<Activation>(
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(
Return(std::vector<std::string>({}))); // No PSU inventory
activation->requestedActivation(RequestedStatus::Active);
@@ -136,7 +136,7 @@
activation = std::make_unique<Activation>(
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(
Return(std::vector<std::string>({psu0}))); // One PSU inventory
activation->requestedActivation(RequestedStatus::Active);
@@ -165,7 +165,7 @@
activation = std::make_unique<Activation>(
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(Return(
std::vector<std::string>({psu0, psu1, psu2, psu3}))); // 4 PSUs
activation->requestedActivation(RequestedStatus::Active);
@@ -217,7 +217,7 @@
activation = std::make_unique<Activation>(
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(Return(
std::vector<std::string>({psu0, psu1, psu2, psu3}))); // 4 PSUs
activation->requestedActivation(RequestedStatus::Active);
@@ -249,7 +249,7 @@
activation = std::make_unique<Activation>(
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(
Return(std::vector<std::string>({psu0}))); // One PSU inventory
ON_CALL(sdbusMock, sd_bus_call(_, _, _, _, nullptr))
@@ -266,7 +266,7 @@
activation = std::make_unique<Activation>(
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(Return(std::vector<std::string>({psu0})));
activation->requestedActivation(RequestedStatus::Active);
@@ -280,7 +280,7 @@
activation = std::make_unique<Activation>(
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(Return(std::vector<std::string>({psu0})));
activation->requestedActivation(RequestedStatus::Active);
@@ -297,7 +297,7 @@
activation = std::make_unique<Activation>(
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(
Return(std::vector<std::string>({psu0}))); // One PSU inventory
activation->requestedActivation(RequestedStatus::Active);
@@ -325,7 +325,7 @@
activation = std::make_unique<Activation>(
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(Return(
std::vector<std::string>({psu0, psu1, psu2, psu3}))); // 4 PSUs
activation->requestedActivation(RequestedStatus::Active);
@@ -366,7 +366,7 @@
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(
Return(std::vector<std::string>({psu0}))); // One PSU inventory
@@ -389,7 +389,7 @@
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(
Return(std::vector<std::string>({psu0}))); // One PSU inventory
@@ -410,7 +410,7 @@
mockedBus, dBusPath, versionId, extVersion, status, associations,
filePath, &mockedAssociationInterface, &mockedActivationListener);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(
Return(std::vector<std::string>({psu0}))); // One PSU inventory
diff --git a/test/test_item_updater.cpp b/test/test_item_updater.cpp
index ad01f42..7523bfc 100644
--- a/test/test_item_updater.cpp
+++ b/test/test_item_updater.cpp
@@ -83,7 +83,7 @@
constexpr auto service = "com.example.Software.Psu";
constexpr auto version = "version0";
std::string objPath = getObjPath(version);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
@@ -107,7 +107,7 @@
constexpr auto service = "com.example.Software.Psu";
constexpr auto version = "version0";
std::string objPath = getObjPath(version);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
@@ -139,7 +139,7 @@
auto objPath0 = getObjPath(version0);
auto objPath1 = getObjPath(version1);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psu0, psu1})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psu0), _))
.WillOnce(Return(service));
@@ -189,7 +189,7 @@
auto objPath0 = getObjPath(version0);
auto objPath1 = getObjPath(version1);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psu0, psu1})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psu0), _))
.WillOnce(Return(service));
@@ -241,7 +241,7 @@
constexpr auto service = "com.example.Software.Psu";
constexpr auto version = "version0";
std::string objPath = getObjPath(version);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
@@ -279,7 +279,7 @@
constexpr auto service = "com.example.Software.Psu";
constexpr auto version = "version0";
std::string objPath = getObjPath(version);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
@@ -313,7 +313,7 @@
constexpr auto service = "com.example.Software.Psu";
constexpr auto version = "version0";
std::string objPath = getObjPath(version);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
@@ -375,7 +375,7 @@
auto objPath0 = getObjPath(version0);
auto objPath1 = getObjPath(version1);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psu0, psu1})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psu0), _))
.WillOnce(Return(service));
@@ -458,7 +458,7 @@
constexpr auto service = "com.example.Software.Psu";
constexpr auto version = "version0";
std::string objPath = getObjPath(version);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
@@ -492,7 +492,7 @@
constexpr auto service = "com.example.Software.Psu";
constexpr auto version = "version0";
std::string objPath = getObjPath(version);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
@@ -538,7 +538,7 @@
auto objPath0 = getObjPath(version0);
auto objPath1 = getObjPath(version1);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psu0, psu1})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psu0), _))
.WillOnce(Return(service));
@@ -606,7 +606,7 @@
auto objPath0 = getObjPath(version0);
auto objPath1 = getObjPath(version1);
- EXPECT_CALL(mockedUtils, getPSUInventoryPath(_))
+ EXPECT_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillOnce(Return(std::vector<std::string>({psu0, psu1})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psu0), _))
.WillOnce(Return(service));
@@ -665,7 +665,7 @@
std::string versionId =
version; // In testing versionId is the same as version
std::string objPath = getObjPath(version);
- ON_CALL(mockedUtils, getPSUInventoryPath(_))
+ ON_CALL(mockedUtils, getPSUInventoryPaths(_))
.WillByDefault(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service))
diff --git a/test/test_utils.cpp b/test/test_utils.cpp
index 114b93a..d12e1f3 100644
--- a/test/test_utils.cpp
+++ b/test/test_utils.cpp
@@ -57,7 +57,7 @@
EXPECT_CALL(sdbusMock, sd_bus_message_exit_container(IsNull()))
.WillOnce(Return(0)); /* end of std::vector */
- auto ret = utils::getPSUInventoryPath(bus);
+ auto ret = utils::getPSUInventoryPaths(bus);
EXPECT_EQ(2U, ret.size());
EXPECT_EQ(path0, ret[0]);
EXPECT_EQ(path1, ret[1]);