regulators: Add log_phase_fault to parser
Enhance the JSON configuration file parser to support the new
log_phase_fault action.
Add gtest test cases to exercise new code.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I8ef9974df8ca8be07dd284552bd978802f502338
diff --git a/phosphor-regulators/src/config_file_parser.cpp b/phosphor-regulators/src/config_file_parser.cpp
index 5330f59..6527b5f 100644
--- a/phosphor-regulators/src/config_file_parser.cpp
+++ b/phosphor-regulators/src/config_file_parser.cpp
@@ -120,6 +120,11 @@
action = parseIf(element["if"]);
++propertyCount;
}
+ else if (element.contains("log_phase_fault"))
+ {
+ action = parseLogPhaseFault(element["log_phase_fault"]);
+ ++propertyCount;
+ }
else if (element.contains("not"))
{
action = parseNot(element["not"]);
@@ -715,6 +720,22 @@
return absPath;
}
+std::unique_ptr<LogPhaseFaultAction> parseLogPhaseFault(const json& element)
+{
+ verifyIsObject(element);
+ unsigned int propertyCount{0};
+
+ // Required type property
+ const json& typeElement = getRequiredProperty(element, "type");
+ PhaseFaultType type = parsePhaseFaultType(typeElement);
+ ++propertyCount;
+
+ // Verify no invalid properties exist
+ verifyPropertyCount(element, propertyCount);
+
+ return std::make_unique<LogPhaseFaultAction>(type);
+}
+
std::unique_ptr<NotAction> parseNot(const json& element)
{
// Required action to execute