regulators: Add Services to ActionEnvironment
Add Services& services to the ActionEnvironment constructor.
Add Services& getServices() to the ActionEnvironment class.
Add Services& services to the ActionEnvironment class.
Update the ActionEnvironment test for the new getServices() method.
Update classes that create an ActionEnvironment.
Update all affected testcases that create an ActionEnvironment.
Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I12ac9f301746965aa282b69432a71ad525739c9e
diff --git a/phosphor-regulators/src/actions/action_environment.hpp b/phosphor-regulators/src/actions/action_environment.hpp
index ce06aff..bfd1b37 100644
--- a/phosphor-regulators/src/actions/action_environment.hpp
+++ b/phosphor-regulators/src/actions/action_environment.hpp
@@ -17,6 +17,7 @@
#include "id_map.hpp"
#include "pmbus_utils.hpp"
+#include "services.hpp"
#include <cstddef> // for size_t
#include <optional>
@@ -64,11 +65,12 @@
*
* @param idMap mapping from IDs to the associated Device/Rule objects
* @param deviceID current device ID
+ * @param services system services like error logging and the journal
*/
- explicit ActionEnvironment(const IDMap& idMap,
- const std::string& deviceID) :
+ explicit ActionEnvironment(const IDMap& idMap, const std::string& deviceID,
+ Services& services) :
idMap{idMap},
- deviceID{deviceID}
+ deviceID{deviceID}, services{services}
{
}
@@ -154,6 +156,16 @@
}
/**
+ * Returns the services in this action environment.
+ *
+ * @return system services
+ */
+ Services& getServices() const
+ {
+ return services;
+ }
+
+ /**
* Returns the current volts value, if set.
*
* @return current volts value
@@ -216,6 +228,11 @@
std::string deviceID{};
/**
+ * System services like error logging and the journal.
+ */
+ Services& services;
+
+ /**
* Current volts value (if set).
*/
std::optional<double> volts{};
diff --git a/phosphor-regulators/src/configuration.cpp b/phosphor-regulators/src/configuration.cpp
index 81b2c17..04babc7 100644
--- a/phosphor-regulators/src/configuration.cpp
+++ b/phosphor-regulators/src/configuration.cpp
@@ -56,7 +56,8 @@
services.getJournal().logDebug(message);
// Create ActionEnvironment
- ActionEnvironment environment{system.getIDMap(), device.getID()};
+ ActionEnvironment environment{system.getIDMap(), device.getID(),
+ services};
if (volts.has_value())
{
environment.setVolts(volts.value());
diff --git a/phosphor-regulators/src/sensor_monitoring.cpp b/phosphor-regulators/src/sensor_monitoring.cpp
index 07ae635..1ce1eee 100644
--- a/phosphor-regulators/src/sensor_monitoring.cpp
+++ b/phosphor-regulators/src/sensor_monitoring.cpp
@@ -35,7 +35,8 @@
try
{
// Create ActionEnvironment
- ActionEnvironment environment{system.getIDMap(), device.getID()};
+ ActionEnvironment environment{system.getIDMap(), device.getID(),
+ services};
// Execute the actions
action_utils::execute(actions, environment);
diff --git a/phosphor-regulators/test/actions/action_environment_tests.cpp b/phosphor-regulators/test/actions/action_environment_tests.cpp
index 54afc2e..ffb75e9 100644
--- a/phosphor-regulators/test/actions/action_environment_tests.cpp
+++ b/phosphor-regulators/test/actions/action_environment_tests.cpp
@@ -17,6 +17,7 @@
#include "device.hpp"
#include "i2c_interface.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include "pmbus_utils.hpp"
#include "rule.hpp"
@@ -37,6 +38,9 @@
// Create IDMap
IDMap idMap{};
+ // Create mock services.
+ MockServices services{};
+
// Create Device and add to IDMap
std::unique_ptr<i2c::I2CInterface> i2cInterface =
i2c::create(1, 0x70, i2c::I2CInterface::InitialState::CLOSED);
@@ -49,7 +53,7 @@
// Verify object state after constructor
try
{
- ActionEnvironment env{idMap, "regulator1"};
+ ActionEnvironment env{idMap, "regulator1", services};
EXPECT_EQ(env.getDevice().getID(), "regulator1");
EXPECT_EQ(env.getDeviceID(), "regulator1");
EXPECT_EQ(env.getRuleDepth(), 0);
@@ -64,7 +68,8 @@
TEST(ActionEnvironmentTests, AddSensorReading)
{
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
pmbus_utils::SensorReading reading;
reading.type = pmbus_utils::SensorValueType::iout;
reading.value = 1;
@@ -86,7 +91,8 @@
TEST(ActionEnvironmentTests, DecrementRuleDepth)
{
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
EXPECT_EQ(env.getRuleDepth(), 0);
env.incrementRuleDepth("set_voltage_rule");
env.incrementRuleDepth("set_voltage_rule");
@@ -104,6 +110,9 @@
// Create IDMap
IDMap idMap{};
+ // Create mock services.
+ MockServices services{};
+
// Create Device and add to IDMap
std::unique_ptr<i2c::I2CInterface> i2cInterface =
i2c::create(1, 0x70, i2c::I2CInterface::InitialState::CLOSED);
@@ -113,7 +122,7 @@
std::move(i2cInterface)};
idMap.addDevice(reg1);
- ActionEnvironment env{idMap, "regulator1"};
+ ActionEnvironment env{idMap, "regulator1", services};
// Test where current device ID is in the IDMap
try
@@ -148,7 +157,8 @@
TEST(ActionEnvironmentTests, GetDeviceID)
{
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
EXPECT_EQ(env.getDeviceID(), "");
env.setDeviceID("regulator1");
EXPECT_EQ(env.getDeviceID(), "regulator1");
@@ -158,11 +168,15 @@
{
// Create IDMap
IDMap idMap{};
+
+ // Create mock services.
+ MockServices services{};
+
Rule setVoltageRule{"set_voltage_rule",
std::vector<std::unique_ptr<Action>>{}};
idMap.addRule(setVoltageRule);
- ActionEnvironment env{idMap, ""};
+ ActionEnvironment env{idMap, "", services};
// Test where rule ID is in the IDMap
try
@@ -196,7 +210,8 @@
TEST(ActionEnvironmentTests, GetRuleDepth)
{
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
EXPECT_EQ(env.getRuleDepth(), 0);
env.incrementRuleDepth("set_voltage_rule");
EXPECT_EQ(env.getRuleDepth(), 1);
@@ -211,7 +226,8 @@
TEST(ActionEnvironmentTests, GetSensorReadings)
{
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
pmbus_utils::SensorReading reading;
reading.type = pmbus_utils::SensorValueType::pout;
reading.value = 1.3;
@@ -230,10 +246,19 @@
EXPECT_EQ(env.getSensorReadings()[1].value, -1);
}
+TEST(ActionEnvironmentTests, GetServices)
+{
+ IDMap idMap{};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
+ EXPECT_EQ(&(env.getServices()), &services);
+}
+
TEST(ActionEnvironmentTests, GetVolts)
{
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
EXPECT_EQ(env.getVolts().has_value(), false);
env.setVolts(1.31);
EXPECT_EQ(env.getVolts().has_value(), true);
@@ -243,7 +268,8 @@
TEST(ActionEnvironmentTests, IncrementRuleDepth)
{
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
EXPECT_EQ(env.getRuleDepth(), 0);
// Test where rule depth has not exceeded maximum
@@ -279,7 +305,8 @@
TEST(ActionEnvironmentTests, SetDeviceID)
{
IDMap idMap{};
- ActionEnvironment env{idMap, "regulator1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "regulator1", services};
EXPECT_EQ(env.getDeviceID(), "regulator1");
env.setDeviceID("regulator2");
EXPECT_EQ(env.getDeviceID(), "regulator2");
@@ -290,7 +317,8 @@
try
{
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
EXPECT_EQ(env.getVolts().has_value(), false);
env.setVolts(2.35);
EXPECT_EQ(env.getVolts().has_value(), true);
diff --git a/phosphor-regulators/test/actions/action_utils_tests.cpp b/phosphor-regulators/test/actions/action_utils_tests.cpp
index ede5fa8..640c085 100644
--- a/phosphor-regulators/test/actions/action_utils_tests.cpp
+++ b/phosphor-regulators/test/actions/action_utils_tests.cpp
@@ -18,6 +18,7 @@
#include "action_utils.hpp"
#include "id_map.hpp"
#include "mock_action.hpp"
+#include "mock_services.hpp"
#include <exception>
#include <memory>
@@ -37,7 +38,9 @@
{
// Create ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ // Create mock services.
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
// Test where vector is empty
try
diff --git a/phosphor-regulators/test/actions/and_action_tests.cpp b/phosphor-regulators/test/actions/and_action_tests.cpp
index 3b62273..d3453b1 100644
--- a/phosphor-regulators/test/actions/and_action_tests.cpp
+++ b/phosphor-regulators/test/actions/and_action_tests.cpp
@@ -18,6 +18,7 @@
#include "and_action.hpp"
#include "id_map.hpp"
#include "mock_action.hpp"
+#include "mock_services.hpp"
#include <exception>
#include <memory>
@@ -47,7 +48,8 @@
{
// Create ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
// Test where empty vector of actions is specified
try
diff --git a/phosphor-regulators/test/actions/i2c_action_tests.cpp b/phosphor-regulators/test/actions/i2c_action_tests.cpp
index 07542f5..3c155cb 100644
--- a/phosphor-regulators/test/actions/i2c_action_tests.cpp
+++ b/phosphor-regulators/test/actions/i2c_action_tests.cpp
@@ -18,6 +18,7 @@
#include "i2c_action.hpp"
#include "i2c_interface.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include <memory>
@@ -64,14 +65,15 @@
EXPECT_CALL(*i2cInterface, isOpen).Times(1).WillOnce(Return(false));
EXPECT_CALL(*i2cInterface, open).Times(1);
- // Create Device, IDMap, ActionEnvironment, and I2CAction
+ // Create Device, IDMap, MockServices, ActionEnvironment, and I2CAction
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CActionImpl action{};
// Get I2CInterface. Should succeed without an exception.
@@ -91,14 +93,15 @@
EXPECT_CALL(*i2cInterface, isOpen).Times(1).WillOnce(Return(true));
EXPECT_CALL(*i2cInterface, open).Times(0);
- // Create Device, IDMap, ActionEnvironment, and I2CAction
+ // Create Device, IDMap, MockServices, ActionEnvironment, and I2CAction
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CActionImpl action{};
// Get I2CInterface. Should succeed without an exception.
@@ -112,9 +115,10 @@
// Test where fails: getting current device fails
try
{
- // Create IDMap, ActionEnvironment, and I2CAction
+ // Create IDMap, MockServices, ActionEnvironment, and I2CAction
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CActionImpl action{};
// Get I2CInterface. Should throw an exception since "reg1" is not a
@@ -150,7 +154,8 @@
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CActionImpl action{};
// Get I2CInterface. Should throw an exception from the open() call.
diff --git a/phosphor-regulators/test/actions/i2c_compare_bit_action_tests.cpp b/phosphor-regulators/test/actions/i2c_compare_bit_action_tests.cpp
index d3d0ab0..609026e 100644
--- a/phosphor-regulators/test/actions/i2c_compare_bit_action_tests.cpp
+++ b/phosphor-regulators/test/actions/i2c_compare_bit_action_tests.cpp
@@ -19,6 +19,7 @@
#include "i2c_compare_bit_action.hpp"
#include "i2c_interface.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include <cstdint>
@@ -95,14 +96,15 @@
EXPECT_CALL(*i2cInterface, read(0x7C, A<uint8_t&>()))
.WillRepeatedly(SetArgReferee<1>(0x96));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Test where actual bit value is equal to expected bit value.
// Test all bits in register value 0x96 == 1001 0110).
@@ -146,9 +148,10 @@
// Test where fails: Getting I2CInterface fails
try
{
- // Create IDMap and ActionEnvironment
+ // Create IDMap, MockServices, and ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CCompareBitAction action{0x7C, 5, 1};
action.execute(env);
@@ -175,14 +178,15 @@
.WillOnce(Throw(
i2c::I2CException{"Failed to read byte", "/dev/i2c-1", 0x70}));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CCompareBitAction action{0x7C, 5, 1};
action.execute(env);
diff --git a/phosphor-regulators/test/actions/i2c_compare_byte_action_tests.cpp b/phosphor-regulators/test/actions/i2c_compare_byte_action_tests.cpp
index 1bd4748..0a81c71 100644
--- a/phosphor-regulators/test/actions/i2c_compare_byte_action_tests.cpp
+++ b/phosphor-regulators/test/actions/i2c_compare_byte_action_tests.cpp
@@ -19,6 +19,7 @@
#include "i2c_compare_byte_action.hpp"
#include "i2c_interface.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include <cstdint>
@@ -69,14 +70,15 @@
.Times(1)
.WillOnce(SetArgReferee<1>(0xD7));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Actual value: 0xD7 = 1101 0111
// Mask : 0x7E = 0111 1110
@@ -100,14 +102,15 @@
.Times(1)
.WillOnce(SetArgReferee<1>(0xD7));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CCompareByteAction action{0xA0, 0xD7};
EXPECT_EQ(action.execute(env), true);
@@ -128,14 +131,15 @@
.Times(1)
.WillOnce(SetArgReferee<1>(0xD7));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Actual value: 0xD7 = 1101 0111
// Mask : 0x7E = 0111 1110
@@ -159,14 +163,15 @@
.Times(1)
.WillOnce(SetArgReferee<1>(0xD7));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CCompareByteAction action{0xA0, 0xD6};
EXPECT_EQ(action.execute(env), false);
@@ -179,9 +184,10 @@
// Test where fails: Getting I2CInterface fails
try
{
- // Create IDMap and ActionEnvironment
+ // Create IDMap, MockServices, and ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CCompareByteAction action{0xA0, 0xD6};
action.execute(env);
@@ -208,14 +214,15 @@
.WillOnce(Throw(
i2c::I2CException{"Failed to read byte", "/dev/i2c-1", 0x70}));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CCompareByteAction action{0xA0, 0xD6};
action.execute(env);
diff --git a/phosphor-regulators/test/actions/i2c_compare_bytes_action_tests.cpp b/phosphor-regulators/test/actions/i2c_compare_bytes_action_tests.cpp
index 5685db7..62d807a 100644
--- a/phosphor-regulators/test/actions/i2c_compare_bytes_action_tests.cpp
+++ b/phosphor-regulators/test/actions/i2c_compare_bytes_action_tests.cpp
@@ -19,6 +19,7 @@
#include "i2c_compare_bytes_action.hpp"
#include "i2c_interface.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include <cstdint>
@@ -160,14 +161,15 @@
.Times(1)
.WillOnce(SetArrayArgument<2>(actualValues, actualValues + 2));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Actual values: 0xD7 = 1101 0111 0x96 = 1001 0110
// Masks : 0x7E = 0111 1110 0x3C = 0011 1100
@@ -195,14 +197,15 @@
.Times(1)
.WillOnce(SetArrayArgument<2>(actualValues, actualValues + 3));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
std::vector<uint8_t> values{0x56, 0x14, 0xDA};
I2CCompareBytesAction action{0x7C, values};
@@ -226,14 +229,15 @@
.Times(1)
.WillOnce(SetArrayArgument<2>(actualValues, actualValues + 2));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Actual values: 0xD7 = 1101 0111 0x96 = 1001 0110
// Masks : 0x7E = 0111 1110 0x3C = 0011 1100
@@ -261,14 +265,15 @@
.Times(1)
.WillOnce(SetArrayArgument<2>(actualValues, actualValues + 3));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
std::vector<uint8_t> values{0x56, 0x14, 0xDB};
I2CCompareBytesAction action{0x7C, values};
@@ -292,14 +297,15 @@
.Times(1)
.WillOnce(SetArrayArgument<2>(actualValues, actualValues + 1));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Actual values: 0xD7 = 1101 0111
// Masks : 0x7E = 0111 1110
@@ -317,9 +323,10 @@
// Test where fails: Getting I2CInterface fails
try
{
- // Create IDMap and ActionEnvironment
+ // Create IDMap, MockServices, and ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
std::vector<uint8_t> values{0x56, 0x14, 0xDB};
I2CCompareBytesAction action{0x7C, values};
@@ -348,14 +355,15 @@
.WillOnce(Throw(i2c::I2CException{"Failed to read i2c block data",
"/dev/i2c-1", 0x70}));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
std::vector<uint8_t> values{0x56, 0x14};
I2CCompareBytesAction action{0x7C, values};
diff --git a/phosphor-regulators/test/actions/i2c_write_bit_action_tests.cpp b/phosphor-regulators/test/actions/i2c_write_bit_action_tests.cpp
index d3a7c18..97df0e9 100644
--- a/phosphor-regulators/test/actions/i2c_write_bit_action_tests.cpp
+++ b/phosphor-regulators/test/actions/i2c_write_bit_action_tests.cpp
@@ -19,6 +19,7 @@
#include "i2c_interface.hpp"
#include "i2c_write_bit_action.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include <cstdint>
@@ -100,14 +101,15 @@
write(TypedEq<uint8_t>(0xA0), TypedEq<uint8_t>(0x96)))
.Times(1);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Register value : 0xB6 = 1011 0110
// 0 in position 5 : 0x00 = --0- ----
@@ -134,14 +136,15 @@
write(TypedEq<uint8_t>(0x7C), TypedEq<uint8_t>(0xB6)))
.Times(1);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Register value : 0x96 = 1001 0110
// 1 in position 5 : 0x20 = 0010 0000
@@ -157,9 +160,10 @@
// Test where fails: Getting I2CInterface fails
try
{
- // Create IDMap and ActionEnvironment
+ // Create IDMap, MockServices, and ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CWriteBitAction action{0x7C, 5, 1};
action.execute(env);
@@ -187,14 +191,15 @@
i2c::I2CException{"Failed to read byte", "/dev/i2c-1", 0x70}));
EXPECT_CALL(*i2cInterface, write(A<uint8_t>(), A<uint8_t>())).Times(0);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CWriteBitAction action{0x7C, 5, 1};
action.execute(env);
@@ -243,14 +248,15 @@
.WillOnce(Throw(
i2c::I2CException{"Failed to write byte", "/dev/i2c-1", 0x70}));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Register value : 0xB6 = 1011 0110
// 0 in position 5 : 0x00 = --0- ----
diff --git a/phosphor-regulators/test/actions/i2c_write_byte_action_tests.cpp b/phosphor-regulators/test/actions/i2c_write_byte_action_tests.cpp
index 4972f5b..b09e3fa 100644
--- a/phosphor-regulators/test/actions/i2c_write_byte_action_tests.cpp
+++ b/phosphor-regulators/test/actions/i2c_write_byte_action_tests.cpp
@@ -19,6 +19,7 @@
#include "i2c_interface.hpp"
#include "i2c_write_byte_action.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include <cstdint>
@@ -71,14 +72,15 @@
write(TypedEq<uint8_t>(0x7C), TypedEq<uint8_t>(0x0A)))
.Times(1);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CWriteByteAction action{0x7C, 0x0A};
EXPECT_EQ(action.execute(env), true);
@@ -102,14 +104,15 @@
write(TypedEq<uint8_t>(0xA0), TypedEq<uint8_t>(0xEA)))
.Times(1);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Value to write : 0xD6 = 1101 0110
// Mask : 0xC3 = 1100 0011
@@ -129,9 +132,11 @@
// Test where fails: Getting I2CInterface fails
try
{
- // Create IDMap and ActionEnvironment
+
+ // Create IDMap, MockServices, and ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CWriteByteAction action{0x7C, 0x0A};
action.execute(env);
@@ -159,14 +164,15 @@
i2c::I2CException{"Failed to read byte", "/dev/i2c-1", 0x70}));
EXPECT_CALL(*i2cInterface, write(A<uint8_t>(), A<uint8_t>())).Times(0);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CWriteByteAction action{0xA0, 0xD6, 0xC3};
action.execute(env);
@@ -212,14 +218,15 @@
.WillOnce(Throw(
i2c::I2CException{"Failed to write byte", "/dev/i2c-1", 0x70}));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CWriteByteAction action{0x7C, 0x1A};
action.execute(env);
diff --git a/phosphor-regulators/test/actions/i2c_write_bytes_action_tests.cpp b/phosphor-regulators/test/actions/i2c_write_bytes_action_tests.cpp
index bcc196a..57829a8 100644
--- a/phosphor-regulators/test/actions/i2c_write_bytes_action_tests.cpp
+++ b/phosphor-regulators/test/actions/i2c_write_bytes_action_tests.cpp
@@ -19,6 +19,7 @@
#include "i2c_interface.hpp"
#include "i2c_write_bytes_action.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include <cstdint>
@@ -163,14 +164,15 @@
.With(Args<2, 1>(ElementsAre(0x56, 0x14, 0xDA)))
.Times(1);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
std::vector<uint8_t> values{0x56, 0x14, 0xDA};
I2CWriteBytesAction action{0x7C, values};
@@ -198,14 +200,15 @@
.With(Args<2, 1>(ElementsAre(0xEA, 0xB3)))
.Times(1);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Byte 1 Byte 2
// Value to write : 0xD6 = 1101 0110 : 0xD2 = 1101 0010
@@ -242,14 +245,15 @@
.With(Args<2, 1>(ElementsAre(0xEA)))
.Times(1);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Value to write : 0xD6 = 1101 0110
// Mask : 0xC3 = 1100 0011
@@ -271,9 +275,10 @@
// Test where fails: Getting I2CInterface fails
try
{
- // Create IDMap and ActionEnvironment
+ // Create IDMap, MockServices, and ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
std::vector<uint8_t> values{0x56, 0x14, 0xDB};
I2CWriteBytesAction action{0x7C, values};
@@ -306,14 +311,15 @@
A<i2c::I2CInterface::Mode>()))
.Times(0);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
std::vector<uint8_t> values{0xD6, 0xD2};
std::vector<uint8_t> masks{0xC3, 0x96};
@@ -366,14 +372,15 @@
.WillOnce(Throw(i2c::I2CException{"Failed to write i2c block data",
"/dev/i2c-1", 0x70}));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
std::vector<uint8_t> values{0x56, 0x14, 0xDA};
I2CWriteBytesAction action{0x7C, values};
diff --git a/phosphor-regulators/test/actions/if_action_tests.cpp b/phosphor-regulators/test/actions/if_action_tests.cpp
index 87f2f9e..7a14dae 100644
--- a/phosphor-regulators/test/actions/if_action_tests.cpp
+++ b/phosphor-regulators/test/actions/if_action_tests.cpp
@@ -18,6 +18,7 @@
#include "id_map.hpp"
#include "if_action.hpp"
#include "mock_action.hpp"
+#include "mock_services.hpp"
#include <exception>
#include <memory>
@@ -74,7 +75,8 @@
{
// Create ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
// Test where action throws an exception
try
diff --git a/phosphor-regulators/test/actions/not_action_tests.cpp b/phosphor-regulators/test/actions/not_action_tests.cpp
index 8e89862..97a6b61 100644
--- a/phosphor-regulators/test/actions/not_action_tests.cpp
+++ b/phosphor-regulators/test/actions/not_action_tests.cpp
@@ -17,6 +17,7 @@
#include "action_environment.hpp"
#include "id_map.hpp"
#include "mock_action.hpp"
+#include "mock_services.hpp"
#include "not_action.hpp"
#include <exception>
@@ -42,7 +43,8 @@
{
// Create ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
// Test where negated action throws an exception
try
diff --git a/phosphor-regulators/test/actions/or_action_tests.cpp b/phosphor-regulators/test/actions/or_action_tests.cpp
index b2c89d1..a9ab622 100644
--- a/phosphor-regulators/test/actions/or_action_tests.cpp
+++ b/phosphor-regulators/test/actions/or_action_tests.cpp
@@ -17,6 +17,7 @@
#include "action_environment.hpp"
#include "id_map.hpp"
#include "mock_action.hpp"
+#include "mock_services.hpp"
#include "or_action.hpp"
#include <exception>
@@ -47,7 +48,9 @@
{
// Create ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ // Create MockServices.
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
// Test where empty vector of actions is specified
try
diff --git a/phosphor-regulators/test/actions/pmbus_read_sensor_action_tests.cpp b/phosphor-regulators/test/actions/pmbus_read_sensor_action_tests.cpp
index cfc4f7e..f907e79 100644
--- a/phosphor-regulators/test/actions/pmbus_read_sensor_action_tests.cpp
+++ b/phosphor-regulators/test/actions/pmbus_read_sensor_action_tests.cpp
@@ -19,6 +19,7 @@
#include "i2c_action.hpp"
#include "i2c_interface.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include "pmbus_error.hpp"
#include "pmbus_read_sensor_action.hpp"
@@ -103,14 +104,15 @@
.WillOnce(SetArgReferee<1>(0xD2E0));
EXPECT_CALL(*i2cInterface, read(A<uint8_t>(), A<uint8_t&>())).Times(0);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
pmbus_utils::SensorValueType type{pmbus_utils::SensorValueType::iout};
@@ -147,14 +149,15 @@
.WillOnce(SetArgReferee<1>(0x0002));
EXPECT_CALL(*i2cInterface, read(A<uint8_t>(), A<uint8_t&>())).Times(0);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
pmbus_utils::SensorValueType type{pmbus_utils::SensorValueType::vout};
@@ -191,14 +194,15 @@
EXPECT_CALL(*i2cInterface, read(TypedEq<uint8_t>(0x20), A<uint8_t&>()))
.Times(1)
.WillOnce(SetArgReferee<1>(0b0001'0111));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
pmbus_utils::SensorValueType type{
@@ -222,9 +226,10 @@
// Test where fails: Unable to get I2C interface to current device
try
{
- // Create IDMap and ActionEnvironment
+ // Create IDMap, MockServices, and ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
pmbus_utils::SensorValueType type{pmbus_utils::SensorValueType::pout};
@@ -259,14 +264,15 @@
.Times(1)
.WillOnce(SetArgReferee<1>(0b0010'0000));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
pmbus_utils::SensorValueType type{pmbus_utils::SensorValueType::vout};
@@ -319,14 +325,15 @@
.WillOnce(Throw(
i2c::I2CException{"Failed to read byte", "/dev/i2c-1", 0x70}));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
pmbus_utils::SensorValueType type{
@@ -379,14 +386,15 @@
.WillOnce(Throw(
i2c::I2CException{"Failed to read word", "/dev/i2c-1", 0x70}));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
pmbus_utils::SensorValueType type{pmbus_utils::SensorValueType::pout};
diff --git a/phosphor-regulators/test/actions/pmbus_write_vout_command_action_tests.cpp b/phosphor-regulators/test/actions/pmbus_write_vout_command_action_tests.cpp
index 0afa0d8..d515cad 100644
--- a/phosphor-regulators/test/actions/pmbus_write_vout_command_action_tests.cpp
+++ b/phosphor-regulators/test/actions/pmbus_write_vout_command_action_tests.cpp
@@ -18,6 +18,7 @@
#include "device.hpp"
#include "i2c_interface.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include "pmbus_error.hpp"
#include "pmbus_utils.hpp"
@@ -123,14 +124,15 @@
.Times(1)
.WillOnce(SetArgReferee<1>(0x014D));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
// Linear format volts value = (1.3 / 2^(-8)) = 332.8 = 333 = 0x014D
@@ -165,15 +167,16 @@
.Times(1);
EXPECT_CALL(*i2cInterface, read(A<uint8_t>(), A<uint16_t&>())).Times(0);
- // Create Device, IDMap, and ActionEnvironment. Set volts value to 3.3
- // in ActionEnvironment.
+ // Create Device, IDMap, MockServices, and ActionEnvironment. Set
+ // volts value to 3.3 in ActionEnvironment.
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
env.setVolts(3.3);
// Create and execute action
@@ -193,9 +196,10 @@
// Test where fails: No volts value defined
try
{
- // Create IDMap and ActionEnvironment
+ // Create IDMap, MockServices, and ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
std::optional<double> volts{};
@@ -221,9 +225,10 @@
// Test where fails: Unable to get I2C interface to current device
try
{
- // Create IDMap and ActionEnvironment
+ // Create IDMap, MockServices, and ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
std::optional<double> volts{1.3};
@@ -258,14 +263,15 @@
i2c::I2CException{"Failed to read byte", "/dev/i2c-1", 0x70}));
EXPECT_CALL(*i2cInterface, write(A<uint8_t>(), A<uint16_t>())).Times(0);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
std::optional<double> volts{3.3};
@@ -317,14 +323,15 @@
.WillOnce(SetArgReferee<1>(0b0010'0000));
EXPECT_CALL(*i2cInterface, write(A<uint8_t>(), A<uint16_t>())).Times(0);
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
std::optional<double> volts{3.3};
@@ -378,14 +385,15 @@
.WillOnce(Throw(i2c::I2CException{"Failed to write word data",
"/dev/i2c-1", 0x70}));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
// Linear format volts value = (1.3 / 2^(-8)) = 332.8 = 333 = 0x014D
@@ -442,14 +450,15 @@
.WillOnce(Throw(i2c::I2CException{"Failed to read word data",
"/dev/i2c-1", 0x70}));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
// Linear format volts value = (1.3 / 2^(-8)) = 332.8 = 333 = 0x014D
@@ -505,14 +514,15 @@
.Times(1)
.WillOnce(SetArgReferee<1>(0x014C));
- // Create Device, IDMap, and ActionEnvironment
+ // Create Device, IDMap, MockServices, and ActionEnvironment
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
// Create and execute action
// Linear format volts value = (1.3 / 2^(-8)) = 332.8 = 333 = 0x014D
diff --git a/phosphor-regulators/test/actions/run_rule_action_tests.cpp b/phosphor-regulators/test/actions/run_rule_action_tests.cpp
index b688a78..23da62e 100644
--- a/phosphor-regulators/test/actions/run_rule_action_tests.cpp
+++ b/phosphor-regulators/test/actions/run_rule_action_tests.cpp
@@ -18,6 +18,7 @@
#include "device.hpp"
#include "id_map.hpp"
#include "mock_action.hpp"
+#include "mock_services.hpp"
#include "rule.hpp"
#include "run_rule_action.hpp"
@@ -47,7 +48,8 @@
try
{
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
RunRuleAction runRuleAction{"set_voltage_rule"};
runRuleAction.execute(env);
ADD_FAILURE() << "Should not have reached this line.";
@@ -77,7 +79,8 @@
// Create ActionEnvironment
IDMap idMap{};
idMap.addRule(rule);
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
// Create RunRuleAction
RunRuleAction runRuleAction{"exception_rule"};
@@ -100,7 +103,8 @@
// Create ActionEnvironment
IDMap idMap{};
idMap.addRule(rule);
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
// Create RunRuleAction
RunRuleAction runRuleAction{"infinite_rule"};
@@ -137,7 +141,8 @@
// Create ActionEnvironment
IDMap idMap{};
idMap.addRule(rule);
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
// Create RunRuleAction
RunRuleAction runRuleAction{"set_voltage_rule"};
@@ -169,7 +174,8 @@
// Create ActionEnvironment
IDMap idMap{};
idMap.addRule(rule);
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
// Create RunRuleAction
RunRuleAction runRuleAction{"set_voltage_rule"};
diff --git a/phosphor-regulators/test/actions/set_device_action_tests.cpp b/phosphor-regulators/test/actions/set_device_action_tests.cpp
index 129113e..2651f13 100644
--- a/phosphor-regulators/test/actions/set_device_action_tests.cpp
+++ b/phosphor-regulators/test/actions/set_device_action_tests.cpp
@@ -17,6 +17,7 @@
#include "device.hpp"
#include "i2c_interface.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include "set_device_action.hpp"
@@ -39,6 +40,9 @@
// Create IDMap
IDMap idMap{};
+ // Create MockServices.
+ MockServices services{};
+
// Create Device regulator1 and add to IDMap
std::unique_ptr<i2c::I2CInterface> i2cInterface =
i2c::create(1, 0x70, i2c::I2CInterface::InitialState::CLOSED);
@@ -58,7 +62,7 @@
idMap.addDevice(reg2);
// Create ActionEnvironment
- ActionEnvironment env{idMap, "regulator1"};
+ ActionEnvironment env{idMap, "regulator1", services};
// Create action
SetDeviceAction action{"regulator2"};
diff --git a/phosphor-regulators/test/rule_tests.cpp b/phosphor-regulators/test/rule_tests.cpp
index f6e5d82..6852686 100644
--- a/phosphor-regulators/test/rule_tests.cpp
+++ b/phosphor-regulators/test/rule_tests.cpp
@@ -17,6 +17,7 @@
#include "action_environment.hpp"
#include "id_map.hpp"
#include "mock_action.hpp"
+#include "mock_services.hpp"
#include "rule.hpp"
#include <exception>
@@ -50,7 +51,8 @@
{
// Create ActionEnvironment
IDMap idMap{};
- ActionEnvironment env{idMap, ""};
+ MockServices services{};
+ ActionEnvironment env{idMap, "", services};
// Test where an action throws an exception
try