test: pid: thermalcontroller
Tests for the pid/thermalcontroller module.
Fixes a bug where one could pass an incorrect number of inputs
to the thermalcontroller. This can still be side-stepped by calling the
constructor directly.
Tested: Ran on quanta-q71l board and it behaved as expected.
Change-Id: I3153ae4d907d9f90787b03e9d013d4349d911948
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/pid/thermalcontroller.cpp b/pid/thermalcontroller.cpp
index dee2d4e..81e3e80 100644
--- a/pid/thermalcontroller.cpp
+++ b/pid/thermalcontroller.cpp
@@ -26,6 +26,12 @@
float setpoint,
ec::pidinfo initial)
{
+ // ThermalController currently only supports precisely one input.
+ if (inputs.size() != 1)
+ {
+ return nullptr;
+ }
+
auto thermal = std::make_unique<ThermalController>(id, inputs, owner);
ec::pid_info_t* info = thermal->get_pid_info();