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