hwmonio:: Add Interface base class and tests
Enable injecting hwmonio::HwmonIO mocks for testing.
Tested: Ran on quanta-q71l and saw all sensors exported to dbus as
expected with the expected values.
Change-Id: I35912bf2a733932d9e1e774ff53b0114ae16560b
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/targets.hpp b/targets.hpp
index cb25dee..9867ba9 100644
--- a/targets.hpp
+++ b/targets.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <experimental/filesystem>
+#include <memory>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Sensor/Device/error.hpp>
@@ -165,13 +166,16 @@
"FILE=%s", sysfsFullPath.c_str()));
}
- target = std::make_shared<T>(ioAccess.path(),
- devPath,
- targetId,
- bus,
- objPath.c_str(),
- deferSignals,
- targetSpeed);
+ // ioAccess.path() is a path like: /sys/class/hwmon/hwmon1
+ target = std::make_shared<T>(
+ std::move(std::make_unique<hwmonio::HwmonIO>(
+ ioAccess.path())),
+ devPath,
+ targetId,
+ bus,
+ objPath.c_str(),
+ deferSignals,
+ targetSpeed);
obj[type] = target;
}
}