regulators: Add Sensors to Services hierarchy
Add the Sensors service to the Services hierarchy:
* Add Sensors class to Services
* Add DBusSensors class to BMCServices
* Add MockSensors class to MockServices
Tested:
* DBusSensors
* Acquired DBusSensors reference from BMCServices object
* Successfully executed a sensor monitoring cycle using the reference
* MockSensors
* Acquired MockSensors reference from MockServices object
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: Ida06baed47c0d8711ab3acba71f67df3646ea122
diff --git a/phosphor-regulators/src/services.hpp b/phosphor-regulators/src/services.hpp
index 44d438e..42701c3 100644
--- a/phosphor-regulators/src/services.hpp
+++ b/phosphor-regulators/src/services.hpp
@@ -15,9 +15,11 @@
*/
#pragma once
+#include "dbus_sensors.hpp"
#include "error_logging.hpp"
#include "journal.hpp"
#include "presence_service.hpp"
+#include "sensors.hpp"
#include "vpd.hpp"
#include <sdbusplus/bus.hpp>
@@ -74,6 +76,13 @@
virtual PresenceService& getPresenceService() = 0;
/**
+ * Returns the sensors interface.
+ *
+ * @return sensors interface
+ */
+ virtual Sensors& getSensors() = 0;
+
+ /**
* Returns the interface to hardware VPD (Vital Product Data).
*
* @return hardware VPD interface
@@ -103,7 +112,8 @@
* @param bus D-Bus bus object
*/
explicit BMCServices(sdbusplus::bus::bus& bus) :
- bus{bus}, errorLogging{bus}, presenceService{bus}, vpd{bus}
+ bus{bus}, errorLogging{bus},
+ presenceService{bus}, sensors{bus}, vpd{bus}
{
}
@@ -131,6 +141,12 @@
return presenceService;
}
+ /** @copydoc Services::getSensors() */
+ virtual Sensors& getSensors() override
+ {
+ return sensors;
+ }
+
/** @copydoc Services::getVPD() */
virtual VPD& getVPD() override
{
@@ -160,6 +176,11 @@
DBusPresenceService presenceService;
/**
+ * Implementation of the Sensors interface using D-Bus.
+ */
+ DBusSensors sensors;
+
+ /**
* Implementation of the VPD interface using D-Bus method calls.
*/
DBusVPD vpd;
diff --git a/phosphor-regulators/test/mock_services.hpp b/phosphor-regulators/test/mock_services.hpp
index b121e13..8e3a100 100644
--- a/phosphor-regulators/test/mock_services.hpp
+++ b/phosphor-regulators/test/mock_services.hpp
@@ -20,8 +20,10 @@
#include "mock_error_logging.hpp"
#include "mock_journal.hpp"
#include "mock_presence_service.hpp"
+#include "mock_sensors.hpp"
#include "mock_vpd.hpp"
#include "presence_service.hpp"
+#include "sensors.hpp"
#include "services.hpp"
#include "vpd.hpp"
@@ -70,6 +72,12 @@
return presenceService;
}
+ /** @copydoc Services::getSensors() */
+ virtual Sensors& getSensors() override
+ {
+ return sensors;
+ }
+
/** @copydoc Services::getVPD() */
virtual VPD& getVPD() override
{
@@ -115,6 +123,18 @@
}
/**
+ * Returns the MockSensors object that implements the Sensors interface.
+ *
+ * This allows test cases to use the object in EXPECT_CALL() statements.
+ *
+ * @return mock sensors interface object
+ */
+ virtual MockSensors& getMockSensors()
+ {
+ return sensors;
+ }
+
+ /**
* Returns the MockVPD object that implements the VPD interface.
*
* This allows test cases to use the object in EXPECT_CALL() statements.
@@ -148,6 +168,11 @@
MockPresenceService presenceService{};
/**
+ * Mock implementation of the Sensors interface.
+ */
+ MockSensors sensors{};
+
+ /**
* Mock implementation of the VPD interface.
*/
MockVPD vpd{};