enable unit-tests: enable for SensorManager
Enabled unit-tests in general for the project, and more
specifically started with a benign construction test for
the SensorManager object.
Tested: Verified continues to build and link, and unit-test
passes.
Tested: Ran on quanta-q71l board and it behaved as expected.
Change-Id: I4ad9a0c57efd0b9ccc37d26faa0cc1b82026b8d7
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/pid/zone.cpp b/pid/zone.cpp
index 393f6e6..ed8cd0f 100644
--- a/pid/zone.cpp
+++ b/pid/zone.cpp
@@ -211,7 +211,7 @@
for (auto& f : _fanInputs)
{
- auto& sensor = _mgr->getSensor(f);
+ auto& sensor = _mgr.getSensor(f);
ReadReturn r = sensor->read();
_cachedValuesByName[f] = r.value;
@@ -243,7 +243,7 @@
for (auto& t : _thermalInputs)
{
- auto& sensor = _mgr->getSensor(t);
+ auto& sensor = _mgr.getSensor(t);
ReadReturn r = sensor->read();
int64_t timeout = sensor->GetTimeout();
@@ -319,9 +319,9 @@
}
}
-std::unique_ptr<Sensor>& PIDZone::getSensor(std::string name)
+const std::unique_ptr<Sensor>& PIDZone::getSensor(std::string name)
{
- return _mgr->getSensor(name);
+ return _mgr.getSensor(name);
}
bool PIDZone::manual(bool value)
@@ -344,7 +344,7 @@
std::map<int64_t, std::shared_ptr<PIDZone>> BuildZones(
std::map<int64_t, PIDConf>& ZonePids,
std::map<int64_t, struct zone>& ZoneConfigs,
- std::shared_ptr<SensorManager> mgr,
+ SensorManager& mgr,
sdbusplus::bus::bus& ModeControlBus)
{
std::map<int64_t, std::shared_ptr<PIDZone>> zones;
@@ -446,7 +446,7 @@
std::map<int64_t, std::shared_ptr<PIDZone>> BuildZonesFromConfig(
std::string& path,
- std::shared_ptr<SensorManager> mgr,
+ SensorManager& mgr,
sdbusplus::bus::bus& ModeControlBus)
{
using namespace libconfig;
diff --git a/pid/zone.hpp b/pid/zone.hpp
index c7b52c7..1cf517c 100644
--- a/pid/zone.hpp
+++ b/pid/zone.hpp
@@ -34,7 +34,7 @@
PIDZone(int64_t zone,
float minThermalRpm,
float failSafePercent,
- std::shared_ptr<SensorManager> mgr,
+ const SensorManager& mgr,
sdbusplus::bus::bus& bus,
const char* objPath,
bool defer)
@@ -64,7 +64,7 @@
float getFailSafePercent(void) const;
float getMinThermalRpmSetPt(void) const;
- std::unique_ptr<Sensor>& getSensor(std::string name);
+ const std::unique_ptr<Sensor>& getSensor(std::string name);
void determineMaxRPMRequest(void);
void updateFanTelemetry(void);
void updateSensors(void);
@@ -106,7 +106,7 @@
std::vector<std::string> _fanInputs;
std::vector<std::string> _thermalInputs;
std::map<std::string, double> _cachedValuesByName;
- std::shared_ptr<SensorManager> _mgr;
+ const SensorManager& _mgr;
std::vector<std::unique_ptr<PIDController>> _fans;
std::vector<std::unique_ptr<PIDController>> _thermals;
@@ -115,10 +115,10 @@
std::map<int64_t, std::shared_ptr<PIDZone>> BuildZones(
std::map<int64_t, PIDConf>& ZonePids,
std::map<int64_t, struct zone>& ZoneConfigs,
- std::shared_ptr<SensorManager> mgmr,
+ SensorManager& mgmr,
sdbusplus::bus::bus& ModeControlBus);
std::map<int64_t, std::shared_ptr<PIDZone>> BuildZonesFromConfig(
std::string& path,
- std::shared_ptr<SensorManager> mgmr,
+ SensorManager& mgmr,
sdbusplus::bus::bus& ModeControlBus);