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/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);