For each zone log sensor name with max setpoint
Add sensor name that has the maximum setpoint for a PID zone.
Log a debug message when the sensor is changed.
The name is also added to the log file for each log record.
Tested:
Override one CPU temperature sensor
busctl set-property xyz.openbmc_project.CPUSensor /xyz/openbmc_project/sensors/temperature/DTS_CPU1 xyz.openbmc_project.Sensor.Value Value d 82
Observed log message:
swampd[443]: PID Zone 0 max SetPoint 34.5546 requested by DTS_CPU1
Signed-off-by: Nirav Shah <nirav.j2.shah@intel.com>
Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
Change-Id: Ifc12cb9a106da1bf41dd35697210f74ba1b589db
diff --git a/test/pid_stepwisecontroller_unittest.cpp b/test/pid_stepwisecontroller_unittest.cpp
index d9a7728..a832ed7 100644
--- a/test/pid_stepwisecontroller_unittest.cpp
+++ b/test/pid_stepwisecontroller_unittest.cpp
@@ -44,8 +44,8 @@
.WillOnce(Return(31.0)) // return 40
.WillOnce(Return(32.0)); // return 60
- EXPECT_CALL(z, addSetPoint(40.0)).Times(2);
- EXPECT_CALL(z, addSetPoint(60.0)).Times(1);
+ EXPECT_CALL(z, addSetPoint(40.0, "foo")).Times(2);
+ EXPECT_CALL(z, addSetPoint(60.0, "foo")).Times(1);
for (int ii = 0; ii < 3; ii++)
{
@@ -80,8 +80,8 @@
.WillOnce(Return(27.0)) // return 60
.WillOnce(Return(26.0)); // return 40
- EXPECT_CALL(z, addSetPoint(40.0)).Times(1);
- EXPECT_CALL(z, addSetPoint(60.0)).Times(2);
+ EXPECT_CALL(z, addSetPoint(40.0, "foo")).Times(1);
+ EXPECT_CALL(z, addSetPoint(60.0, "foo")).Times(2);
for (int ii = 0; ii < 3; ii++)
{
diff --git a/test/pid_thermalcontroller_unittest.cpp b/test/pid_thermalcontroller_unittest.cpp
index ef4de66..57a1b9f 100644
--- a/test/pid_thermalcontroller_unittest.cpp
+++ b/test/pid_thermalcontroller_unittest.cpp
@@ -104,7 +104,7 @@
EXPECT_FALSE(p == nullptr);
double value = 90.0;
- EXPECT_CALL(z, addSetPoint(value));
+ EXPECT_CALL(z, addSetPoint(value, "therm1"));
p->outputProc(value);
}
@@ -175,7 +175,7 @@
.WillOnce(Return(9.0))
.WillOnce(Return(7.0));
- EXPECT_CALL(z, addSetPoint(_)).Times(3);
+ EXPECT_CALL(z, addSetPoint(_, "therm1")).Times(3);
std::vector<double> lastReadings = {12.0, 12.0, 7.0};
for (auto& reading : lastReadings)
@@ -208,7 +208,7 @@
.WillOnce(Return(13.0))
.WillOnce(Return(14.0));
- EXPECT_CALL(z, addSetPoint(_)).Times(3);
+ EXPECT_CALL(z, addSetPoint(_, "therm1")).Times(3);
std::vector<double> lastReadings = {8.0, 8.0, 14.0};
for (auto& reading : lastReadings)
diff --git a/test/pid_zone_unittest.cpp b/test/pid_zone_unittest.cpp
index 90d2a2f..172c818 100644
--- a/test/pid_zone_unittest.cpp
+++ b/test/pid_zone_unittest.cpp
@@ -161,14 +161,14 @@
TEST_F(PidZoneTest, RpmSetPoints_AddMaxClear_BehaveAsExpected)
{
// Tests addSetPoint, clearSetPoints, determineMaxSetPointRequest
- // and getMinThermalSetpoint.
+ // and getMinThermalSetPoint.
// At least one value must be above the minimum thermal setpoint used in
// the constructor otherwise it'll choose that value
std::vector<double> values = {100, 200, 300, 400, 500, 5000};
for (auto v : values)
{
- zone->addSetPoint(v);
+ zone->addSetPoint(v, "");
}
// This will pull the maximum RPM setpoint request.
@@ -180,7 +180,7 @@
// This will go through the RPM set point values and grab the maximum.
zone->determineMaxSetPointRequest();
- EXPECT_EQ(zone->getMinThermalSetpoint(), zone->getMaxSetPointRequest());
+ EXPECT_EQ(zone->getMinThermalSetPoint(), zone->getMaxSetPointRequest());
}
TEST_F(PidZoneTest, RpmSetPoints_AddBelowMinimum_BehavesAsExpected)
@@ -191,14 +191,14 @@
std::vector<double> values = {100, 200, 300, 400, 500};
for (auto v : values)
{
- zone->addSetPoint(v);
+ zone->addSetPoint(v, "");
}
// This will pull the maximum RPM setpoint request.
zone->determineMaxSetPointRequest();
// Verifies the value returned in the minimal thermal rpm set point.
- EXPECT_EQ(zone->getMinThermalSetpoint(), zone->getMaxSetPointRequest());
+ EXPECT_EQ(zone->getMinThermalSetPoint(), zone->getMaxSetPointRequest());
}
TEST_F(PidZoneTest, GetFailSafePercent_ReturnsExpected)
diff --git a/test/zone_mock.hpp b/test/zone_mock.hpp
index bab77e3..dd98c15 100644
--- a/test/zone_mock.hpp
+++ b/test/zone_mock.hpp
@@ -19,7 +19,7 @@
MOCK_METHOD0(initializeCache, void());
MOCK_METHOD1(getCachedValue, double(const std::string&));
MOCK_CONST_METHOD0(getRedundantWrite, bool(void));
- MOCK_METHOD1(addSetPoint, void(double));
+ MOCK_METHOD2(addSetPoint, void(double, const std::string&));
MOCK_METHOD0(clearSetPoints, void());
MOCK_METHOD1(addRPMCeiling, void(double));
MOCK_METHOD0(clearRPMCeilings, void());