Add failsafe logger for zones
Tested:
...
Nov 23 21:40:06 tmddp10-nfd01.prod.google.com swampd[4893]:
Zone `0` is in failsafe mode.
With update at `fleeting0`: The sensor has bad readings.
Nov 23 21:40:06 tmddp10-nfd01.prod.google.com swampd[4893]:
Zone `1` is in failsafe mode.
With update at `fleeting1`: The sensor has bad readings.
Nov 23 21:40:06 tmddp10-nfd01.prod.google.com swampd[4893]:
Zone `1` leaves failsafe mode.
With update at `hotswap_in_Input_Power`: The sensor has recovered.
Nov 23 21:40:06 tmddp10-nfd01.prod.google.com swampd[4893]:
Zone `0` leaves failsafe mode.
With update at `hotswap_in_Input_Power`: The sensor has recovered.
...
Change-Id: I2c296addb7ad117c03c04a27de91204796cda036
Signed-off-by: James Zheng <alphetis@google.com>
diff --git a/test/pid_zone_unittest.cpp b/test/pid_zone_unittest.cpp
index 5155971..47b3f97 100644
--- a/test/pid_zone_unittest.cpp
+++ b/test/pid_zone_unittest.cpp
@@ -1,3 +1,6 @@
+#include "failsafeloggers/builder.hpp"
+#include "failsafeloggers/failsafe_logger.hpp"
+#include "failsafeloggers/failsafe_logger_utility.hpp"
#include "pid/ec/logging.hpp"
#include "pid/ec/pid.hpp"
#include "pid/zone.hpp"
@@ -10,6 +13,7 @@
#include <chrono>
#include <cstring>
+#include <unordered_map>
#include <vector>
#include <gmock/gmock.h>
@@ -344,6 +348,10 @@
// This test will add a couple thermal inputs, and verify that the zone
// initializes into failsafe mode, and will read each sensor.
+ // Disable failsafe logger for the unit test.
+ std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>> empty_zone_map;
+ buildFailsafeLoggers(empty_zone_map, 0);
+
std::string name1 = "temp1";
int64_t timeout = 1;
@@ -396,6 +404,10 @@
{
// This will add a couple fan inputs, and verify the values are cached.
+ // Disable failsafe logger for the unit test.
+ std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>> empty_zone_map;
+ buildFailsafeLoggers(empty_zone_map, 0);
+
std::string name1 = "fan1";
int64_t timeout = 2;
@@ -444,6 +456,10 @@
// On the second updateSensors call, the updated timestamp will be beyond
// the timeout limit.
+ // Disable failsafe logger for the unit test.
+ std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>> empty_zone_map;
+ buildFailsafeLoggers(empty_zone_map, 0);
+
int64_t timeout = 1;
std::string name1 = "temp1";
@@ -506,6 +522,10 @@
// only sensor1 goes missing.
// However, sensor2 going missing should still trigger failsafe mode.
+ // Disable failsafe logger for the unit test.
+ std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>> empty_zone_map;
+ buildFailsafeLoggers(empty_zone_map, 0);
+
int64_t timeout = 1;
std::string name1 = "temp1";
@@ -602,6 +622,10 @@
{
// This will add a couple fan inputs, and verify the values are cached.
+ // Disable failsafe logger for the unit test.
+ std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>> empty_zone_map;
+ buildFailsafeLoggers(empty_zone_map, 0);
+
std::string name1 = "fan1";
int64_t timeout = 2;
@@ -655,6 +679,10 @@
{
// This will add a couple fan inputs, and verify the values are cached.
+ // Disable failsafe logger for the unit test.
+ std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>> empty_zone_map;
+ buildFailsafeLoggers(empty_zone_map, 0);
+
std::string name1 = "fan1";
int64_t timeout = 2;
@@ -714,6 +742,10 @@
{
// One can grab a sensor from the manager through the zone.
+ // Disable failsafe logger for the unit test.
+ std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>> empty_zone_map;
+ buildFailsafeLoggers(empty_zone_map, 0);
+
int64_t timeout = 1;
std::string name1 = "temp1";
@@ -804,6 +836,11 @@
{
// This property is implemented by us as read-only, such that trying to
// write to it will have no effect.
+
+ // Disable failsafe logger for the unit test.
+ std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>> empty_zone_map;
+ buildFailsafeLoggers(empty_zone_map, 0);
+
EXPECT_EQ(zone->failSafe(), zone->getFailSafeMode());
}