blob: 3ac44d1c869127bceb9f77df6cfb995581d119bd [file] [log] [blame]
Zane Shelley2c228cd2021-12-16 23:45:12 -06001#include <stdio.h>
2
3#include <analyzer/plugins/plugin.hpp>
Zane Shelley9491cdb2022-02-01 10:40:45 -06004#include <analyzer/ras-data/ras-data-parser.hpp>
Zane Shelley2c228cd2021-12-16 23:45:12 -06005#include <hei_util.hpp>
6#include <util/pdbg.hpp>
7#include <util/trace.hpp>
8
9#include "gtest/gtest.h"
10
11using namespace analyzer;
12
13static const auto nodeId =
14 static_cast<libhei::NodeId_t>(libhei::hash<libhei::NodeId_t>("PLL_UNLOCK"));
15
16// Sub-test #1 - single PLL unlock attention on proc 1, clock 1
17TEST(PllUnlock, TestSet1)
18{
19 pdbg_targets_init(nullptr);
20
21 libhei::Chip chip1{util::pdbg::getTrgt("/proc1"), P10_20};
22
23 libhei::Signature sig11{chip1, nodeId, 0, 1, libhei::ATTN_TYPE_CHECKSTOP};
24
Zane Shelley2c228cd2021-12-16 23:45:12 -060025 libhei::IsolationData isoData{};
26 isoData.addSignature(sig11);
27 ServiceData sd{sig11, AnalysisType::SYSTEM_CHECKSTOP, isoData};
28
Zane Shelley9491cdb2022-02-01 10:40:45 -060029 RasDataParser rasData{};
30 rasData.getResolution(sig11)->resolve(sd);
Zane Shelley2c228cd2021-12-16 23:45:12 -060031
32 nlohmann::json j{};
33 std::string s{};
34
35 // Callout list
36 j = sd.getCalloutList();
37 s = R"([
38 {
39 "Deconfigured": false,
40 "Guarded": false,
41 "LocationCode": "P0",
42 "Priority": "M"
43 },
44 {
45 "Deconfigured": false,
46 "Guarded": false,
47 "LocationCode": "/proc1",
48 "Priority": "M"
49 }
50])";
51 EXPECT_EQ(s, j.dump(4));
52
53 // Callout FFDC
54 j = sd.getCalloutFFDC();
55 s = R"([
56 {
57 "Callout Type": "Clock Callout",
58 "Clock Type": "OSC_REF_CLOCK_1",
59 "Priority": "medium"
60 },
61 {
62 "Callout Type": "Hardware Callout",
63 "Guard": false,
64 "Priority": "medium",
65 "Target": "/proc1"
66 }
67])";
68 EXPECT_EQ(s, j.dump(4));
69}
70
71// Sub-test #2 - PLL unlock attention on multiple procs and clocks. Isolating
72// only to proc 1 clock 0 PLL unlock attentions.
73TEST(PllUnlock, TestSet2)
74{
75 pdbg_targets_init(nullptr);
76
77 libhei::Chip chip0{util::pdbg::getTrgt("/proc0"), P10_20};
78 libhei::Chip chip1{util::pdbg::getTrgt("/proc1"), P10_20};
79
80 // PLL unlock signatures for each clock per processor.
81 libhei::Signature sig00{chip0, nodeId, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
82 libhei::Signature sig01{chip0, nodeId, 0, 1, libhei::ATTN_TYPE_CHECKSTOP};
83 libhei::Signature sig10{chip1, nodeId, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
84 libhei::Signature sig11{chip1, nodeId, 0, 1, libhei::ATTN_TYPE_CHECKSTOP};
85
86 // Plugins for each processor.
87 auto plugin = PluginMap::getSingleton().get(chip1.getType(), "pll_unlock");
88
89 libhei::IsolationData isoData{};
90 isoData.addSignature(sig00);
91 isoData.addSignature(sig01);
92 isoData.addSignature(sig10);
93 isoData.addSignature(sig11);
94 ServiceData sd{sig10, AnalysisType::SYSTEM_CHECKSTOP, isoData};
95
96 // Call the PLL unlock plugin.
97 plugin(0, chip1, sd);
98
99 nlohmann::json j{};
100 std::string s{};
101
102 // Callout list
103 j = sd.getCalloutList();
104 s = R"([
105 {
106 "Deconfigured": false,
107 "Guarded": false,
108 "LocationCode": "P0",
109 "Priority": "H"
110 },
111 {
112 "Deconfigured": false,
113 "Guarded": false,
114 "LocationCode": "/proc0",
115 "Priority": "M"
116 },
117 {
118 "Deconfigured": false,
119 "Guarded": false,
120 "LocationCode": "/proc1",
121 "Priority": "M"
122 }
123])";
124 EXPECT_EQ(s, j.dump(4));
125
126 // Callout FFDC
127 j = sd.getCalloutFFDC();
128 s = R"([
129 {
130 "Callout Type": "Clock Callout",
131 "Clock Type": "OSC_REF_CLOCK_0",
132 "Priority": "high"
133 },
134 {
135 "Callout Type": "Hardware Callout",
136 "Guard": false,
137 "Priority": "medium",
138 "Target": "/proc0"
139 },
140 {
141 "Callout Type": "Hardware Callout",
142 "Guard": false,
143 "Priority": "medium",
144 "Target": "/proc1"
145 }
146])";
147 EXPECT_EQ(s, j.dump(4));
148}