Get PSU version from vendor specific tool
The code was getting the version from PSU inventory object.
This commit changes the behavior to use a vendor-specific tool to get
the version directly, where the tool is expected to be configured during
build time.
Add an example get_version app that shows the expected behavior of the
tool:
* It accepts an argument of PSU inventory object;
* It outputs the version to stdout.
Tested: 1. Put and configure to use the example get_version on witherspoon,
verify that PSU software objects are created with the version
returned by the exmaple tool.
2. With the Witherspoon specific tool in
https://gerrit.openbmc-project.xyz/c/openbmc/witherspoon-pfault-analysis/+/24811,
verify the version is correctly got from the PSU inventory path
and the software objects are created.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I5195cb6fc8998a76b09abcfe0b107364cb180c01
diff --git a/test/test_item_updater.cpp b/test/test_item_updater.cpp
index b362803..0ae9c76 100644
--- a/test/test_item_updater.cpp
+++ b/test/test_item_updater.cpp
@@ -69,9 +69,8 @@
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psuPath),
- _, StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(std::string(version)))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psuPath)))
+ .WillOnce(Return(std::string(version)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psuPath),
_, StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(false)))); // not present
@@ -96,9 +95,8 @@
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psuPath),
- _, StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(std::string(version)))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psuPath)))
+ .WillOnce(Return(std::string(version)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psuPath),
_, StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(true)))); // present
@@ -129,15 +127,13 @@
.WillOnce(Return(service));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psu1), _))
.WillOnce(Return(service));
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu0), _,
- StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(version0))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psu0)))
+ .WillOnce(Return(std::string(version0)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu0), _,
StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(true)))); // present
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu1), _,
- StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(version1))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psu1)))
+ .WillOnce(Return(std::string(version1)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu1), _,
StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(true)))); // present
@@ -177,15 +173,13 @@
.WillOnce(Return(service));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psu1), _))
.WillOnce(Return(service));
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu0), _,
- StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(version0))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psu0)))
+ .WillOnce(Return(std::string(version0)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu0), _,
StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(true)))); // present
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu1), _,
- StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(version1))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psu1)))
+ .WillOnce(Return(std::string(version1)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu1), _,
StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(true)))); // present
@@ -225,9 +219,8 @@
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psuPath),
- _, StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(std::string(version)))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psuPath)))
+ .WillOnce(Return(std::string(version)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psuPath),
_, StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(true)))); // present
@@ -262,9 +255,8 @@
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psuPath),
- _, StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(std::string(version)))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psuPath)))
+ .WillOnce(Return(std::string(version)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psuPath),
_, StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(false)))); // not present
@@ -296,9 +288,8 @@
.WillOnce(Return(std::vector<std::string>({psuPath})));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psuPath), _))
.WillOnce(Return(service));
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psuPath),
- _, StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(std::string(version)))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psuPath)))
+ .WillOnce(Return(std::string(version)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psuPath),
_, StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(true)))); // present
@@ -349,15 +340,13 @@
.WillOnce(Return(service));
EXPECT_CALL(mockedUtils, getService(_, StrEq(psu1), _))
.WillOnce(Return(service));
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu0), _,
- StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(version0))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psu0)))
+ .WillOnce(Return(std::string(version0)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu0), _,
StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(true)))); // present
- EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu1), _,
- StrEq(VERSION)))
- .WillOnce(Return(any(PropertyType(version1))));
+ EXPECT_CALL(mockedUtils, getVersion(StrEq(psu1)))
+ .WillOnce(Return(std::string(version1)));
EXPECT_CALL(mockedUtils, getPropertyImpl(_, StrEq(service), StrEq(psu1), _,
StrEq(PRESENT)))
.WillOnce(Return(any(PropertyType(true)))); // present