1 #include "../power_off_cause.hpp" 2 3 #include <gtest/gtest.h> 4 5 using namespace phosphor::fan::monitor; 6 7 TEST(PowerOffCauseTest, MissingFanTest) 8 { 9 FanHealth health{{"fan0", {true, {true, true}}}, 10 {"fan1", {true, {true, true}}}, 11 {"fan2", {true, {true, true}}}, 12 {"fan3", {true, {true, true}}}}; 13 14 MissingFanFRUCause cause{2}; 15 EXPECT_FALSE(cause.satisfied(health)); 16 17 health["fan0"] = {false, {false, false}}; 18 EXPECT_FALSE(cause.satisfied(health)); 19 20 health["fan1"] = {false, {false, false}}; 21 EXPECT_TRUE(cause.satisfied(health)); 22 23 health["fan2"] = {false, {false, false}}; 24 EXPECT_TRUE(cause.satisfied(health)); 25 26 health["fan0"] = {false, {true, true}}; 27 health["fan1"] = {false, {true, true}}; 28 health["fan2"] = {false, {true, true}}; 29 EXPECT_TRUE(cause.satisfied(health)); 30 } 31 32 TEST(PowerOffCauseTest, NonfuncRotorTest) 33 { 34 FanHealth health{{"fan0", {true, {true, true}}}, 35 {"fan1", {true, {true, true}}}, 36 {"fan2", {true, {true, true}}}, 37 {"fan3", {true, {true, true}}}}; 38 39 NonfuncFanRotorCause cause{2}; 40 EXPECT_FALSE(cause.satisfied(health)); 41 42 health["fan0"] = {true, {true, false}}; 43 EXPECT_FALSE(cause.satisfied(health)); 44 45 health["fan1"] = {true, {false, true}}; 46 EXPECT_TRUE(cause.satisfied(health)); 47 48 health["fan2"] = {true, {true, false}}; 49 EXPECT_TRUE(cause.satisfied(health)); 50 51 health["fan0"] = {false, {true, true}}; 52 health["fan1"] = {false, {true, true}}; 53 health["fan2"] = {false, {true, true}}; 54 EXPECT_FALSE(cause.satisfied(health)); 55 } 56