1*f1e85e20SMatt Spinler #include "extensions/openpower-pels/pel_rules.hpp"
2*f1e85e20SMatt Spinler
3*f1e85e20SMatt Spinler #include <gtest/gtest.h>
4*f1e85e20SMatt Spinler
5*f1e85e20SMatt Spinler using namespace openpower::pels;
6*f1e85e20SMatt Spinler
7*f1e85e20SMatt Spinler struct CheckParams
8*f1e85e20SMatt Spinler {
9*f1e85e20SMatt Spinler // pel_rules::check() inputs
10*f1e85e20SMatt Spinler uint16_t actionFlags;
11*f1e85e20SMatt Spinler uint8_t eventType;
12*f1e85e20SMatt Spinler uint8_t severity;
13*f1e85e20SMatt Spinler
14*f1e85e20SMatt Spinler // pel_rules::check() expected outputs
15*f1e85e20SMatt Spinler uint16_t expectedActionFlags;
16*f1e85e20SMatt Spinler uint8_t expectedEventType;
17*f1e85e20SMatt Spinler };
18*f1e85e20SMatt Spinler
19*f1e85e20SMatt Spinler const uint8_t sevInfo = 0x00;
20*f1e85e20SMatt Spinler const uint8_t sevRecovered = 0x10;
21*f1e85e20SMatt Spinler const uint8_t sevPredictive = 0x20;
22*f1e85e20SMatt Spinler const uint8_t sevUnrecov = 0x40;
23*f1e85e20SMatt Spinler const uint8_t sevCrit = 0x50;
24*f1e85e20SMatt Spinler const uint8_t sevDiagnostic = 0x60;
25*f1e85e20SMatt Spinler const uint8_t sevSymptom = 0x70;
26*f1e85e20SMatt Spinler
27*f1e85e20SMatt Spinler const uint8_t typeNA = 0x00;
28*f1e85e20SMatt Spinler const uint8_t typeMisc = 0x01;
29*f1e85e20SMatt Spinler const uint8_t typeTracing = 0x02;
30*f1e85e20SMatt Spinler const uint8_t typeDumpNotif = 0x08;
31*f1e85e20SMatt Spinler
TEST(PELRulesTest,TestCheckRules)32*f1e85e20SMatt Spinler TEST(PELRulesTest, TestCheckRules)
33*f1e85e20SMatt Spinler {
34*f1e85e20SMatt Spinler // Impossible to cover all combinations, but
35*f1e85e20SMatt Spinler // do some interesting ones.
36*f1e85e20SMatt Spinler std::vector<CheckParams> testParams{
37*f1e85e20SMatt Spinler // Informational errors w/ empty action flags
38*f1e85e20SMatt Spinler // and different event types.
39*f1e85e20SMatt Spinler {0, typeNA, sevInfo, 0x6000, typeMisc},
40*f1e85e20SMatt Spinler {0, typeMisc, sevInfo, 0x6000, typeMisc},
41*f1e85e20SMatt Spinler {0, typeTracing, sevInfo, 0x6000, typeTracing},
42*f1e85e20SMatt Spinler {0, typeDumpNotif, sevInfo, 0x2000, typeDumpNotif},
43*f1e85e20SMatt Spinler
44*f1e85e20SMatt Spinler // Informational errors with wrong action flags
45*f1e85e20SMatt Spinler {0x8900, typeNA, sevInfo, 0x6000, typeMisc},
46*f1e85e20SMatt Spinler
47*f1e85e20SMatt Spinler // Informational errors with extra valid action flags
48*f1e85e20SMatt Spinler {0x00C0, typeMisc, sevInfo, 0x60C0, typeMisc},
49*f1e85e20SMatt Spinler
50*f1e85e20SMatt Spinler // Informational - don't report
51*f1e85e20SMatt Spinler {0x1000, typeMisc, sevInfo, 0x5000, typeMisc},
52*f1e85e20SMatt Spinler
53*f1e85e20SMatt Spinler // Recovered will report as hidden
54*f1e85e20SMatt Spinler {0, typeNA, sevRecovered, 0x6000, typeNA},
55*f1e85e20SMatt Spinler
56*f1e85e20SMatt Spinler // The 5 error severities will have:
57*f1e85e20SMatt Spinler // service action, report, call home
58*f1e85e20SMatt Spinler {0, typeNA, sevPredictive, 0xA800, typeNA},
59*f1e85e20SMatt Spinler {0, typeNA, sevUnrecov, 0xA800, typeNA},
60*f1e85e20SMatt Spinler {0, typeNA, sevCrit, 0xA800, typeNA},
61*f1e85e20SMatt Spinler {0, typeNA, sevDiagnostic, 0xA800, typeNA},
62*f1e85e20SMatt Spinler {0, typeNA, sevSymptom, 0xA800, typeNA}};
63*f1e85e20SMatt Spinler
64*f1e85e20SMatt Spinler for (const auto& entry : testParams)
65*f1e85e20SMatt Spinler {
66*f1e85e20SMatt Spinler auto [actionFlags, type] = pel_rules::check(
67*f1e85e20SMatt Spinler entry.actionFlags, entry.eventType, entry.severity);
68*f1e85e20SMatt Spinler
69*f1e85e20SMatt Spinler EXPECT_EQ(actionFlags, entry.expectedActionFlags);
70*f1e85e20SMatt Spinler EXPECT_EQ(type, entry.expectedEventType);
71*f1e85e20SMatt Spinler }
72*f1e85e20SMatt Spinler }
73