Add IpmbSensor unit tests
Because everything was packed into IpmbSensor.cpp, which also included
main(), this commit breaks it up into the patterns we have in other
sensors, with <X>main.cpp containing the things for main.
While this doesn't clean up everything, it at least makes
processResponse unit testable, and adds one minor test for it.
Change-Id: I1eabf650ff635211e5b9a94816c2ffce250ed252
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/src/IpmbSensor.hpp b/src/IpmbSensor.hpp
index 58f20d5..d22e36d 100644
--- a/src/IpmbSensor.hpp
+++ b/src/IpmbSensor.hpp
@@ -10,6 +10,9 @@
#include <string>
#include <vector>
+constexpr const char* sensorType = "IpmbSensor";
+constexpr const char* sdrInterface = "IpmbDevice";
+
enum class IpmbType
{
none,
@@ -97,7 +100,9 @@
std::string getSubTypeUnits() const;
void loadDefaults();
void runInitCmd();
- bool processReading(const std::vector<uint8_t>& data, double& resp);
+ static bool processReading(ReadingFormat readingFormat, uint8_t command,
+ const std::vector<uint8_t>& data, double& resp,
+ size_t errCount);
void parseConfigValues(const SensorBaseConfigMap& entry);
bool sensorClassType(const std::string& sensorClass);
void sensorSubType(const std::string& sensorTypeName);
@@ -126,3 +131,14 @@
void ipmbRequestCompletionCb(const boost::system::error_code& ec,
const IpmbMethodType& response);
};
+
+void createSensors(
+ boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer,
+ boost::container::flat_map<std::string, std::shared_ptr<IpmbSensor>>&
+ sensors,
+ std::shared_ptr<sdbusplus::asio::connection>& dbusConnection);
+
+void interfaceRemoved(
+ sdbusplus::message_t& message,
+ boost::container::flat_map<std::string, std::shared_ptr<IpmbSensor>>&
+ sensors);