Create regulators RunRuleAction class
Create the RunRuleAction class that implements the run_rule action in
the JSON config file.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I382d072f6648f7609b0eb2b4e8a51b7fb18d54db
diff --git a/phosphor-regulators/test/actions/action_environment_tests.cpp b/phosphor-regulators/test/actions/action_environment_tests.cpp
index ff13c83..d861a25 100644
--- a/phosphor-regulators/test/actions/action_environment_tests.cpp
+++ b/phosphor-regulators/test/actions/action_environment_tests.cpp
@@ -20,7 +20,9 @@
#include <cstddef> // for size_t
#include <exception>
+#include <memory>
#include <stdexcept>
+#include <vector>
#include <gtest/gtest.h>
@@ -54,8 +56,8 @@
IDMap idMap{};
ActionEnvironment env{idMap, ""};
EXPECT_EQ(env.getRuleDepth(), 0);
- env.incrementRuleDepth();
- env.incrementRuleDepth();
+ env.incrementRuleDepth("set_voltage_rule");
+ env.incrementRuleDepth("set_voltage_rule");
EXPECT_EQ(env.getRuleDepth(), 2);
env.decrementRuleDepth();
EXPECT_EQ(env.getRuleDepth(), 1);
@@ -157,9 +159,9 @@
IDMap idMap{};
ActionEnvironment env{idMap, ""};
EXPECT_EQ(env.getRuleDepth(), 0);
- env.incrementRuleDepth();
+ env.incrementRuleDepth("set_voltage_rule");
EXPECT_EQ(env.getRuleDepth(), 1);
- env.incrementRuleDepth();
+ env.incrementRuleDepth("set_voltage_rule");
EXPECT_EQ(env.getRuleDepth(), 2);
env.decrementRuleDepth();
EXPECT_EQ(env.getRuleDepth(), 1);
@@ -220,7 +222,7 @@
{
for (size_t i = 1; i <= env.maxRuleDepth; ++i)
{
- env.incrementRuleDepth();
+ env.incrementRuleDepth("set_voltage_rule");
EXPECT_EQ(env.getRuleDepth(), i);
}
}
@@ -232,11 +234,12 @@
// Test where rule depth has exceeded maximum
try
{
- env.incrementRuleDepth();
+ env.incrementRuleDepth("set_voltage_rule");
}
catch (const std::runtime_error& r_error)
{
- EXPECT_STREQ(r_error.what(), "Maximum rule depth exceeded.");
+ EXPECT_STREQ(r_error.what(),
+ "Maximum rule depth exceeded by rule set_voltage_rule.");
}
catch (const std::exception& error)
{