zone: Add debug thermal/power interface
- Add xyz.openbmc_project.Debug.Pid.ThermalPower interface to
fanctrl/zoneX/pid dbus to record some datas in thermal/power
PID loop.
Tested:
```
busctl introspect xyz.openbmc_project.State.FanCtrl /xyz/openbmc_project/settings/fanctrl/zone0/CPU0_PID xyz.openbmc_project.Debug.Pid.ThermalPower
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
.ClassType property s "Temperature" emits-change
.Input property d 36.594 emits-change
.Leader property s "Die_CPU0" emits-change
.Output property d 4200 emits-change
.Setpoint property d 70 emits-change
```
Signed-off-by: Harvey Wu <Harvey.Wu@quantatw.com>
Change-Id: I6846c3878c2ca5eaeeb6eaf48aaf0f604a2beccf
diff --git a/test/pid_zone_unittest.cpp b/test/pid_zone_unittest.cpp
index 391d026..3a51d88 100644
--- a/test/pid_zone_unittest.cpp
+++ b/test/pid_zone_unittest.cpp
@@ -28,6 +28,8 @@
static std::string modeInterface = "xyz.openbmc_project.Control.Mode";
static std::string debugZoneInterface = "xyz.openbmc_project.Debug.Pid.Zone";
static std::string enableInterface = "xyz.openbmc_project.Object.Enable";
+static std::string debugThermalPowerInterface =
+ "xyz.openbmc_project.Debug.Pid.ThermalPower";
namespace
{
@@ -73,6 +75,13 @@
SetupDbusObject(&sdbus_mock_enable, defer, pidsensorpath.c_str(),
enableInterface, propertiesenable, &de);
+ EXPECT_CALL(sdbus_mock_enable,
+ sd_bus_add_object_vtable(
+ IsNull(), NotNull(), StrEq(pidsensorpath.c_str()),
+ StrEq(debugThermalPowerInterface), NotNull(), NotNull()))
+ .Times(::testing::AnyNumber())
+ .WillOnce(Return(0));
+
DbusPidZone p(zone, minThermalOutput, failSafePercent, cycleTime, m,
bus_mock_mode, objPath, defer);
// Success.
@@ -109,6 +118,13 @@
SetupDbusObject(&sdbus_mock_enable, defer, pidsensorpath.c_str(),
enableInterface, propertiesenable,
&propertyenable_index);
+ EXPECT_CALL(sdbus_mock_enable,
+ sd_bus_add_object_vtable(IsNull(), NotNull(),
+ StrEq(pidsensorpath.c_str()),
+ StrEq(debugThermalPowerInterface),
+ NotNull(), NotNull()))
+ .Times(::testing::AnyNumber())
+ .WillOnce(Return(0));
zone = std::make_unique<DbusPidZone>(zoneId, minThermalOutput,
failSafePercent, cycleTime, mgr,
@@ -128,12 +144,14 @@
int64_t zoneId = 1;
double minThermalOutput = 1000.0;
double failSafePercent = 0;
+ double setpoint = 50.0;
bool defer = true;
const char* objPath = "/path/";
SensorManager mgr;
conf::CycleTime cycleTime;
std::string sensorname = "temp1";
+ std::string sensorType = "temp";
std::string pidsensorpath = "/xyz/openbmc_project/settings/fanctrl/zone1/" +
sensorname;
@@ -174,8 +192,8 @@
return 0;
}));
- zone->addPidControlProcess(sensorname, bus_mock_enable,
- pidsensorpath.c_str(), defer);
+ zone->addPidControlProcess(sensorname, sensorType, setpoint,
+ bus_mock_enable, pidsensorpath.c_str(), defer);
EXPECT_TRUE(zone->isPidProcessEnabled(sensorname));
}
@@ -232,8 +250,8 @@
return 0;
}));
- zone->addPidControlProcess(sensorname, bus_mock_enable,
- pidsensorpath.c_str(), defer);
+ zone->addPidControlProcess(sensorname, sensorType, setpoint,
+ bus_mock_enable, pidsensorpath.c_str(), defer);
// At least one value must be above the minimum thermal setpoint used in
// the constructor otherwise it'll choose that value
@@ -276,8 +294,8 @@
return 0;
}));
- zone->addPidControlProcess(sensorname, bus_mock_enable,
- pidsensorpath.c_str(), defer);
+ zone->addPidControlProcess(sensorname, sensorType, setpoint,
+ bus_mock_enable, pidsensorpath.c_str(), defer);
std::vector<double> values = {100, 200, 300, 400, 500};
diff --git a/test/zone_mock.hpp b/test/zone_mock.hpp
index ba167f4..8ba9c85 100644
--- a/test/zone_mock.hpp
+++ b/test/zone_mock.hpp
@@ -51,6 +51,10 @@
MOCK_METHOD0(initializeLog, void());
MOCK_METHOD1(writeLog, void(const std::string&));
+
+ MOCK_METHOD4(updateThermalPowerDebugInterface,
+ void(std::string pidName, std::string leader, double input,
+ double output));
};
} // namespace pid_control