print zone failsafe reason when enter failsafe mode
Tested:
```
Jun 24 01:52:45 bmc sel-logger[640]: cpu0_nbm critical high threshold assert. Reading=49.000000 Threshold=45.000000.
Jun 24 01:52:46 bmc swampd[2944]: Zone 2 fans, entering failsafe mode, output pwm: 100
Jun 24 01:52:46 bmc swampd[2944]: Fail sensor: cpu0_nbm, reason: Sensor threshold asserted
Jun 24 01:52:46 bmc swampd[2944]: Zone 0 fans, entering failsafe mode, output pwm: 100
Jun 24 01:52:46 bmc swampd[2944]: Fail sensor: cpu0_nbm, reason: Sensor threshold asserted
```
Signed-off-by: Harvey Wu <Harvey.Wu@quantatw.com>
Change-Id: I607d01b6bed11b00a40153db6521a9c9d23da519
diff --git a/test/pid_zone_unittest.cpp b/test/pid_zone_unittest.cpp
index 47b3f97..ea8ac91 100644
--- a/test/pid_zone_unittest.cpp
+++ b/test/pid_zone_unittest.cpp
@@ -317,9 +317,15 @@
zone->addPidFailSafePercent(input2, values[1]);
zone->addPidFailSafePercent(input3, values[2]);
- zone->markSensorMissing("temp1");
+ zone->markSensorMissing("temp1", "Sensor threshold asserted");
EXPECT_EQ(failSafePercent, zone->getFailSafePercent());
+
+ std::map<std::string, std::pair<std::string, double>> failSensorList =
+ zone->getFailSafeSensors();
+ EXPECT_EQ(1, failSensorList.size());
+ EXPECT_EQ("Sensor threshold asserted", failSensorList["temp1"].first);
+ EXPECT_EQ(failSafePercent, failSensorList["temp1"].second);
}
TEST_F(PidZoneTest, GetFailSafePercent_MultiFailedReturnsExpected)
@@ -336,11 +342,21 @@
zone->addPidFailSafePercent(input2, values[1]);
zone->addPidFailSafePercent(input3, values[2]);
- zone->markSensorMissing("temp1");
- zone->markSensorMissing("temp2");
- zone->markSensorMissing("temp3");
+ zone->markSensorMissing("temp1", "Sensor threshold asserted");
+ zone->markSensorMissing("temp2", "Sensor reading bad");
+ zone->markSensorMissing("temp3", "Sensor unavailable");
EXPECT_EQ(80, zone->getFailSafePercent());
+
+ std::map<std::string, std::pair<std::string, double>> failSensorList =
+ zone->getFailSafeSensors();
+ EXPECT_EQ(3, failSensorList.size());
+ EXPECT_EQ("Sensor threshold asserted", failSensorList["temp1"].first);
+ EXPECT_EQ(60, failSensorList["temp1"].second);
+ EXPECT_EQ("Sensor reading bad", failSensorList["temp2"].first);
+ EXPECT_EQ(80, failSensorList["temp2"].second);
+ EXPECT_EQ("Sensor unavailable", failSensorList["temp3"].first);
+ EXPECT_EQ(70, failSensorList["temp3"].second);
}
TEST_F(PidZoneTest, ThermalInputs_FailsafeToValid_ReadsSensors)