1 #include "../power_off_cause.hpp"
2
3 #include <gtest/gtest.h>
4
5 using namespace phosphor::fan::monitor;
6
TEST(PowerOffCauseTest,MissingFanTest)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
TEST(PowerOffCauseTest,NonfuncRotorTest)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
TEST(PowerOffCauseTest,FansWithNonFuncRotorsTest)57 TEST(PowerOffCauseTest, FansWithNonFuncRotorsTest)
58 {
59 {
60 FanHealth health{{"fan0", {true, {true, true}}},
61 {"fan1", {true, {true, true}}},
62 {"fan2", {true, {true, true}}},
63 {"fan3", {true, {true, true}}}};
64
65 FanFRUsWithNonfuncRotorsCause cause{2};
66 EXPECT_FALSE(cause.satisfied(health));
67 }
68
69 {
70 FanHealth health{{"fan0", {true, {true, true}}},
71 {"fan1", {true, {true, true}}},
72 {"fan2", {true, {false, true}}},
73 {"fan3", {true, {true, true}}}};
74
75 FanFRUsWithNonfuncRotorsCause cause{2};
76 EXPECT_FALSE(cause.satisfied(health));
77 }
78
79 {
80 FanHealth health{{"fan0", {true, {true, true}}},
81 {"fan1", {true, {false, false}}},
82 {"fan2", {true, {true, true}}},
83 {"fan3", {true, {true, true}}}};
84
85 FanFRUsWithNonfuncRotorsCause cause{2};
86 EXPECT_FALSE(cause.satisfied(health));
87 }
88
89 {
90 FanHealth health{{"fan0", {true, {true, true}}},
91 {"fan1", {true, {false, false}}},
92 {"fan2", {true, {true, true}}},
93 {"fan3", {true, {true, false}}}};
94
95 FanFRUsWithNonfuncRotorsCause cause{2};
96 EXPECT_TRUE(cause.satisfied(health));
97 }
98
99 {
100 FanHealth health{{"fan0", {true, {false, true}}},
101 {"fan1", {true, {true, true}}},
102 {"fan2", {true, {true, false}}},
103 {"fan3", {true, {true, true}}}};
104
105 FanFRUsWithNonfuncRotorsCause cause{2};
106 EXPECT_TRUE(cause.satisfied(health));
107 }
108 }
109