regulators: Enhance config file parser
Enhance JSON config file parser to convert relative inventory paths to
absolute form.
Tested:
Run local CI with -Dlong-tests=enabled to enable tests for
validate-regulators-config.py.
Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I80237a673f9c5918898db15363847722141388e6
diff --git a/phosphor-regulators/src/config_file_parser.cpp b/phosphor-regulators/src/config_file_parser.cpp
index 6fa34e1..123cb4d 100644
--- a/phosphor-regulators/src/config_file_parser.cpp
+++ b/phosphor-regulators/src/config_file_parser.cpp
@@ -236,7 +236,7 @@
// Required fru property
const json& fruElement = getRequiredProperty(element, "fru");
- std::string fru = parseString(fruElement);
+ std::string fru = parseInventoryPath(fruElement);
++propertyCount;
// Required value property
@@ -257,7 +257,7 @@
// Required fru property
const json& fruElement = getRequiredProperty(element, "fru");
- std::string fru = parseString(fruElement);
+ std::string fru = parseInventoryPath(fruElement);
++propertyCount;
// Required keyword property
@@ -331,7 +331,7 @@
// Required fru property
const json& fruElement = getRequiredProperty(element, "fru");
- std::string fru = parseString(fruElement);
+ std::string fru = parseInventoryPath(fruElement);
++propertyCount;
// Required i2c_interface property
@@ -648,6 +648,18 @@
std::move(elseActions));
}
+std::string parseInventoryPath(const json& element)
+{
+ std::string inventoryPath = parseString(element);
+ std::string absPath = "/xyz/openbmc_project/inventory";
+ if (inventoryPath.front() != '/')
+ {
+ absPath += '/';
+ }
+ absPath += inventoryPath;
+ return absPath;
+}
+
std::unique_ptr<NotAction> parseNot(const json& element)
{
// Required action to execute