blob: 35f63077105d860684e0949c2935d275f68102e3 [file] [log] [blame]
Zane Shelley0b8368c2021-03-18 17:33:41 -05001#include <stdio.h>
2
Zane Shelley82be3ab2021-12-07 10:36:08 -06003#include <analyzer/analyzer_main.hpp>
Zane Shelley0b8368c2021-03-18 17:33:41 -05004#include <analyzer/resolution.hpp>
Zane Shelleycb766a42022-01-12 17:50:23 -06005#include <util/pdbg.hpp>
Zane Shelley5d63cef2021-09-17 18:10:17 -05006#include <util/trace.hpp>
7
8#include <regex>
Zane Shelley0b8368c2021-03-18 17:33:41 -05009
10#include "gtest/gtest.h"
11
12// Chip string
13constexpr auto chip_str = "/proc0";
14
15// Unit paths
Zane Shelley5d63cef2021-09-17 18:10:17 -050016constexpr auto proc_str = "";
17constexpr auto iolink_str = "pib/perv24/pauc0/iohs0/smpgroup0";
18constexpr auto omi_str = "pib/perv12/mc0/mi0/mcc0/omi0";
19constexpr auto ocmb_str = "pib/perv12/mc0/mi0/mcc0/omi0/ocmb0";
20constexpr auto core_str = "pib/perv39/eq7/fc1/core1";
Zane Shelley0b8368c2021-03-18 17:33:41 -050021
Zane Shelley0b8368c2021-03-18 17:33:41 -050022using namespace analyzer;
23
24TEST(Resolution, TestSet1)
25{
Zane Shelleycb766a42022-01-12 17:50:23 -060026 pdbg_targets_init(nullptr);
27
Zane Shelley0b8368c2021-03-18 17:33:41 -050028 // Create a few resolutions
29 auto c1 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -050030 proc_str, callout::Priority::HIGH, false);
Zane Shelley0b8368c2021-03-18 17:33:41 -050031
32 auto c2 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -050033 omi_str, callout::Priority::MED_A, true);
Zane Shelley0b8368c2021-03-18 17:33:41 -050034
35 auto c3 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -050036 core_str, callout::Priority::MED, true);
Zane Shelley0b8368c2021-03-18 17:33:41 -050037
38 auto c4 = std::make_shared<ProcedureCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -050039 callout::Procedure::NEXTLVL, callout::Priority::LOW);
Zane Shelley0b8368c2021-03-18 17:33:41 -050040
Zane Shelley84721d92021-09-08 13:30:27 -050041 auto c5 = std::make_shared<ClockCalloutResolution>(
42 callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::LOW, false);
43
44 // l1 = (c1, c2, c5)
Zane Shelley723fa232021-08-09 12:02:06 -050045 auto l1 = std::make_shared<ResolutionList>();
46 l1->push(c1);
47 l1->push(c2);
Zane Shelley84721d92021-09-08 13:30:27 -050048 l1->push(c5);
Zane Shelley0b8368c2021-03-18 17:33:41 -050049
Zane Shelley84721d92021-09-08 13:30:27 -050050 // l2 = (c4, c3, c1, c2, c5)
Zane Shelley723fa232021-08-09 12:02:06 -050051 auto l2 = std::make_shared<ResolutionList>();
52 l2->push(c4);
53 l2->push(c3);
54 l2->push(l1);
Zane Shelley0b8368c2021-03-18 17:33:41 -050055
56 // Get some ServiceData objects
Zane Shelleycb766a42022-01-12 17:50:23 -060057 libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef};
Zane Shelley0b8368c2021-03-18 17:33:41 -050058 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley62adf5c2022-01-18 21:06:50 -060059 ServiceData sd1{sig, AnalysisType::SYSTEM_CHECKSTOP,
60 libhei::IsolationData{}};
61 ServiceData sd2{sig, AnalysisType::TERMINATE_IMMEDIATE,
62 libhei::IsolationData{}};
Zane Shelley0b8368c2021-03-18 17:33:41 -050063
64 // Resolve
Zane Shelley723fa232021-08-09 12:02:06 -050065 l1->resolve(sd1);
66 l2->resolve(sd2);
Zane Shelley0b8368c2021-03-18 17:33:41 -050067
Zane Shelley55e7fec2022-01-28 15:29:44 -060068 // Verify the subsystems
69 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
70 callout::SrcSubsystem::PROCESSOR, callout::Priority::HIGH};
71 EXPECT_EQ(sd1.getSubsys(), subsys);
72
73 subsys = {callout::SrcSubsystem::PROCESSOR, callout::Priority::HIGH};
74 EXPECT_EQ(sd2.getSubsys(), subsys);
75
Zane Shelley0b8368c2021-03-18 17:33:41 -050076 // Start verifying
77 nlohmann::json j{};
78 std::string s{};
79
Zane Shelleyc85716c2021-08-17 10:54:06 -050080 j = sd1.getCalloutList();
Zane Shelley0b8368c2021-03-18 17:33:41 -050081 s = R"([
82 {
Zane Shelley9a738f72021-11-03 20:45:30 -050083 "Deconfigured": false,
84 "Guarded": false,
Zane Shelley0b8368c2021-03-18 17:33:41 -050085 "LocationCode": "/proc0",
86 "Priority": "H"
87 },
88 {
Zane Shelley1eff9452021-11-03 13:59:54 -050089 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -060090 "EntityPath": [],
91 "GuardType": "GARD_Unrecoverable",
92 "Guarded": true,
93 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
94 "Priority": "A"
95 },
96 {
97 "Deconfigured": false,
Zane Shelley1eff9452021-11-03 13:59:54 -050098 "Guarded": false,
Zane Shelley84721d92021-09-08 13:30:27 -050099 "LocationCode": "P0",
100 "Priority": "L"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500101 }
102])";
Zane Shelley96d54862021-09-17 11:16:12 -0500103 EXPECT_EQ(s, j.dump(4));
Zane Shelley0b8368c2021-03-18 17:33:41 -0500104
Zane Shelleyc85716c2021-08-17 10:54:06 -0500105 j = sd2.getCalloutList();
Zane Shelley0b8368c2021-03-18 17:33:41 -0500106 s = R"([
107 {
108 "Priority": "L",
Zane Shelley86ccc452021-11-16 13:10:52 -0600109 "Procedure": "next_level_support"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500110 },
111 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500112 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -0600113 "EntityPath": [],
114 "GuardType": "GARD_Predictive",
Zane Shelley9a738f72021-11-03 20:45:30 -0500115 "Guarded": true,
Zane Shelleycb766a42022-01-12 17:50:23 -0600116 "LocationCode": "/proc0/pib/perv39/eq7/fc1/core1",
117 "Priority": "M"
118 },
119 {
120 "Deconfigured": false,
121 "Guarded": false,
Zane Shelley0b8368c2021-03-18 17:33:41 -0500122 "LocationCode": "/proc0",
Zane Shelley0b8368c2021-03-18 17:33:41 -0500123 "Priority": "H"
124 },
125 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500126 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -0600127 "EntityPath": [],
128 "GuardType": "GARD_Predictive",
129 "Guarded": true,
130 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
131 "Priority": "A"
132 },
133 {
134 "Deconfigured": false,
Zane Shelley1eff9452021-11-03 13:59:54 -0500135 "Guarded": false,
Zane Shelley84721d92021-09-08 13:30:27 -0500136 "LocationCode": "P0",
137 "Priority": "L"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500138 }
139])";
Zane Shelley96d54862021-09-17 11:16:12 -0500140 EXPECT_EQ(s, j.dump(4));
141}
142
143TEST(Resolution, HardwareCallout)
144{
Zane Shelleycb766a42022-01-12 17:50:23 -0600145 pdbg_targets_init(nullptr);
146
Zane Shelley96d54862021-09-17 11:16:12 -0500147 auto c1 = std::make_shared<HardwareCalloutResolution>(
148 omi_str, callout::Priority::MED_A, true);
149
Zane Shelleycb766a42022-01-12 17:50:23 -0600150 libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef};
Zane Shelley96d54862021-09-17 11:16:12 -0500151 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley62adf5c2022-01-18 21:06:50 -0600152 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP,
153 libhei::IsolationData{}};
Zane Shelley96d54862021-09-17 11:16:12 -0500154
155 c1->resolve(sd);
156
Zane Shelley55e7fec2022-01-28 15:29:44 -0600157 // Verify the subsystem
158 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
159 callout::SrcSubsystem::MEMORY, callout::Priority::MED_A};
160 EXPECT_EQ(sd.getSubsys(), subsys);
161
Zane Shelley96d54862021-09-17 11:16:12 -0500162 nlohmann::json j{};
163 std::string s{};
164
165 // Callout list
166 j = sd.getCalloutList();
167 s = R"([
168 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500169 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -0600170 "EntityPath": [],
171 "GuardType": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500172 "Guarded": true,
Zane Shelleycb766a42022-01-12 17:50:23 -0600173 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
Zane Shelley96d54862021-09-17 11:16:12 -0500174 "Priority": "A"
175 }
176])";
177 EXPECT_EQ(s, j.dump(4));
178
179 // Callout FFDC
180 j = sd.getCalloutFFDC();
181 s = R"([
182 {
183 "Callout Type": "Hardware Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500184 "Guard": true,
Zane Shelley96d54862021-09-17 11:16:12 -0500185 "Priority": "medium_group_A",
186 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0"
187 }
188])";
189 EXPECT_EQ(s, j.dump(4));
190}
191
Zane Shelley5d63cef2021-09-17 18:10:17 -0500192TEST(Resolution, ConnectedCallout)
193{
Zane Shelleycb766a42022-01-12 17:50:23 -0600194 pdbg_targets_init(nullptr);
195
Zane Shelley5d63cef2021-09-17 18:10:17 -0500196 auto c1 = std::make_shared<ConnectedCalloutResolution>(
197 callout::BusType::SMP_BUS, iolink_str, callout::Priority::MED_A, true);
198
199 auto c2 = std::make_shared<ConnectedCalloutResolution>(
200 callout::BusType::OMI_BUS, ocmb_str, callout::Priority::MED_B, true);
201
202 auto c3 = std::make_shared<ConnectedCalloutResolution>(
203 callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_C, true);
204
Zane Shelleycb766a42022-01-12 17:50:23 -0600205 libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef};
Zane Shelley5d63cef2021-09-17 18:10:17 -0500206 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley62adf5c2022-01-18 21:06:50 -0600207 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP,
208 libhei::IsolationData{}};
Zane Shelley5d63cef2021-09-17 18:10:17 -0500209
210 nlohmann::json j{};
211 std::string s{};
212
213 c1->resolve(sd);
214 c2->resolve(sd);
215 c3->resolve(sd);
216
Zane Shelley55e7fec2022-01-28 15:29:44 -0600217 // Verify the subsystem
218 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
219 callout::SrcSubsystem::CEC_HARDWARE, callout::Priority::MED_A};
220 EXPECT_EQ(sd.getSubsys(), subsys);
221
Zane Shelley5d63cef2021-09-17 18:10:17 -0500222 // Callout list
223 j = sd.getCalloutList();
224 s = R"([
225 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500226 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -0600227 "EntityPath": [],
228 "GuardType": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500229 "Guarded": true,
Zane Shelleycb766a42022-01-12 17:50:23 -0600230 "LocationCode": "/proc0/pib/perv24/pauc0/iohs0/smpgroup0",
Zane Shelley5d63cef2021-09-17 18:10:17 -0500231 "Priority": "A"
232 },
233 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500234 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -0600235 "EntityPath": [],
236 "GuardType": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500237 "Guarded": true,
Zane Shelleycb766a42022-01-12 17:50:23 -0600238 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
Zane Shelley5d63cef2021-09-17 18:10:17 -0500239 "Priority": "B"
240 },
241 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500242 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -0600243 "EntityPath": [],
244 "GuardType": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500245 "Guarded": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500246 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
247 "Priority": "C"
248 }
249])";
250 EXPECT_EQ(s, j.dump(4));
251
252 // Callout FFDC
253 j = sd.getCalloutFFDC();
254 s = R"([
255 {
256 "Bus Type": "SMP_BUS",
257 "Callout Type": "Connected Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500258 "Guard": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500259 "Priority": "medium_group_A",
Zane Shelley37acb282022-01-10 16:05:22 -0600260 "RX Target": "/proc0/pib/perv24/pauc0/iohs0/smpgroup0",
261 "TX Target": "/proc0/pib/perv24/pauc0/iohs0/smpgroup0"
Zane Shelley5d63cef2021-09-17 18:10:17 -0500262 },
263 {
264 "Bus Type": "OMI_BUS",
265 "Callout Type": "Connected Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500266 "Guard": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500267 "Priority": "medium_group_B",
Zane Shelley37acb282022-01-10 16:05:22 -0600268 "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
269 "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0"
Zane Shelley5d63cef2021-09-17 18:10:17 -0500270 },
271 {
272 "Bus Type": "OMI_BUS",
273 "Callout Type": "Connected Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500274 "Guard": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500275 "Priority": "medium_group_C",
Zane Shelley37acb282022-01-10 16:05:22 -0600276 "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
277 "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
Zane Shelley5d63cef2021-09-17 18:10:17 -0500278 }
279])";
280 EXPECT_EQ(s, j.dump(4));
281}
282
Zane Shelley4757a7b2021-09-20 22:23:38 -0500283TEST(Resolution, BusCallout)
284{
Zane Shelleycb766a42022-01-12 17:50:23 -0600285 pdbg_targets_init(nullptr);
286
Zane Shelley4757a7b2021-09-20 22:23:38 -0500287 auto c1 = std::make_shared<HardwareCalloutResolution>(
288 omi_str, callout::Priority::MED_A, true);
289
290 auto c2 = std::make_shared<ConnectedCalloutResolution>(
291 callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_A, true);
292
293 auto c3 = std::make_shared<BusCalloutResolution>(
294 callout::BusType::OMI_BUS, omi_str, callout::Priority::LOW, false);
295
Zane Shelleycb766a42022-01-12 17:50:23 -0600296 libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef};
Zane Shelley4757a7b2021-09-20 22:23:38 -0500297 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley62adf5c2022-01-18 21:06:50 -0600298 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP,
299 libhei::IsolationData{}};
Zane Shelley4757a7b2021-09-20 22:23:38 -0500300
301 nlohmann::json j{};
302 std::string s{};
303
304 c1->resolve(sd);
305 c2->resolve(sd);
306 c3->resolve(sd);
307
Zane Shelley55e7fec2022-01-28 15:29:44 -0600308 // Verify the subsystem
309 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
310 callout::SrcSubsystem::MEMORY, callout::Priority::MED_A};
311 EXPECT_EQ(sd.getSubsys(), subsys);
312
Zane Shelley4757a7b2021-09-20 22:23:38 -0500313 // Callout list
314 j = sd.getCalloutList();
315 s = R"([
316 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500317 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -0600318 "EntityPath": [],
319 "GuardType": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500320 "Guarded": true,
Zane Shelleycb766a42022-01-12 17:50:23 -0600321 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
Zane Shelley4757a7b2021-09-20 22:23:38 -0500322 "Priority": "A"
323 },
324 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500325 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -0600326 "EntityPath": [],
327 "GuardType": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500328 "Guarded": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500329 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
330 "Priority": "A"
331 },
332 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500333 "Deconfigured": false,
334 "Guarded": false,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500335 "LocationCode": "P0",
336 "Priority": "L"
337 }
338])";
339 EXPECT_EQ(s, j.dump(4));
340
341 // Callout FFDC
342 j = sd.getCalloutFFDC();
343 s = R"([
344 {
345 "Callout Type": "Hardware Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500346 "Guard": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500347 "Priority": "medium_group_A",
348 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0"
349 },
350 {
351 "Bus Type": "OMI_BUS",
352 "Callout Type": "Connected Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500353 "Guard": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500354 "Priority": "medium_group_A",
Zane Shelley37acb282022-01-10 16:05:22 -0600355 "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
356 "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
Zane Shelley4757a7b2021-09-20 22:23:38 -0500357 },
358 {
359 "Bus Type": "OMI_BUS",
360 "Callout Type": "Bus Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500361 "Guard": false,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500362 "Priority": "low",
363 "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
364 "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
365 }
366])";
367 EXPECT_EQ(s, j.dump(4));
368}
369
Zane Shelley96d54862021-09-17 11:16:12 -0500370TEST(Resolution, ClockCallout)
371{
Zane Shelleycb766a42022-01-12 17:50:23 -0600372 pdbg_targets_init(nullptr);
373
Zane Shelley96d54862021-09-17 11:16:12 -0500374 auto c1 = std::make_shared<ClockCalloutResolution>(
375 callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::HIGH, false);
376
Zane Shelleycb766a42022-01-12 17:50:23 -0600377 libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef};
Zane Shelley96d54862021-09-17 11:16:12 -0500378 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley62adf5c2022-01-18 21:06:50 -0600379 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP,
380 libhei::IsolationData{}};
Zane Shelley96d54862021-09-17 11:16:12 -0500381
382 c1->resolve(sd);
383
Zane Shelley55e7fec2022-01-28 15:29:44 -0600384 // Verify the subsystem
385 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
386 callout::SrcSubsystem::CEC_CLOCKS, callout::Priority::HIGH};
387 EXPECT_EQ(sd.getSubsys(), subsys);
388
Zane Shelley96d54862021-09-17 11:16:12 -0500389 nlohmann::json j{};
390 std::string s{};
391
392 // Callout list
393 j = sd.getCalloutList();
394 s = R"([
395 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500396 "Deconfigured": false,
397 "Guarded": false,
Zane Shelley96d54862021-09-17 11:16:12 -0500398 "LocationCode": "P0",
399 "Priority": "H"
400 }
401])";
402 EXPECT_EQ(s, j.dump(4));
403
404 // Callout FFDC
405 j = sd.getCalloutFFDC();
406 s = R"([
407 {
408 "Callout Type": "Clock Callout",
409 "Clock Type": "OSC_REF_CLOCK_1",
Zane Shelley1eff9452021-11-03 13:59:54 -0500410 "Priority": "high"
Zane Shelley96d54862021-09-17 11:16:12 -0500411 }
412])";
413 EXPECT_EQ(s, j.dump(4));
414}
415
416TEST(Resolution, ProcedureCallout)
417{
Zane Shelleycb766a42022-01-12 17:50:23 -0600418 pdbg_targets_init(nullptr);
419
Zane Shelley96d54862021-09-17 11:16:12 -0500420 auto c1 = std::make_shared<ProcedureCalloutResolution>(
421 callout::Procedure::NEXTLVL, callout::Priority::LOW);
422
Zane Shelleycb766a42022-01-12 17:50:23 -0600423 libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef};
Zane Shelley96d54862021-09-17 11:16:12 -0500424 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley62adf5c2022-01-18 21:06:50 -0600425 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP,
426 libhei::IsolationData{}};
Zane Shelley96d54862021-09-17 11:16:12 -0500427
428 c1->resolve(sd);
429
Zane Shelley55e7fec2022-01-28 15:29:44 -0600430 // Verify the subsystem
431 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
432 callout::SrcSubsystem::OTHERS, callout::Priority::LOW};
433 EXPECT_EQ(sd.getSubsys(), subsys);
434
Zane Shelley96d54862021-09-17 11:16:12 -0500435 nlohmann::json j{};
436 std::string s{};
437
438 // Callout list
439 j = sd.getCalloutList();
440 s = R"([
441 {
442 "Priority": "L",
Zane Shelley86ccc452021-11-16 13:10:52 -0600443 "Procedure": "next_level_support"
Zane Shelley96d54862021-09-17 11:16:12 -0500444 }
445])";
446 EXPECT_EQ(s, j.dump(4));
447
448 // Callout FFDC
449 j = sd.getCalloutFFDC();
450 s = R"([
451 {
452 "Callout Type": "Procedure Callout",
453 "Priority": "low",
Zane Shelley86ccc452021-11-16 13:10:52 -0600454 "Procedure": "next_level_support"
Zane Shelley96d54862021-09-17 11:16:12 -0500455 }
456])";
457 EXPECT_EQ(s, j.dump(4));
Zane Shelley0b8368c2021-03-18 17:33:41 -0500458}
Zane Shelleya4134772022-01-10 17:22:44 -0600459
460TEST(Resolution, PartCallout)
461{
462 pdbg_targets_init(nullptr);
463
464 auto c1 = std::make_shared<PartCalloutResolution>(callout::PartType::PNOR,
465 callout::Priority::MED);
466
467 libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef};
468 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley62adf5c2022-01-18 21:06:50 -0600469 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP,
470 libhei::IsolationData{}};
Zane Shelleya4134772022-01-10 17:22:44 -0600471
472 c1->resolve(sd);
473
Zane Shelley55e7fec2022-01-28 15:29:44 -0600474 // Verify the subsystem
475 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
476 callout::SrcSubsystem::CEC_HARDWARE, callout::Priority::MED};
477 EXPECT_EQ(sd.getSubsys(), subsys);
478
Zane Shelleya4134772022-01-10 17:22:44 -0600479 nlohmann::json j{};
480 std::string s{};
481
482 // Callout list
483 j = sd.getCalloutList();
484 s = R"([
485 {
486 "Deconfigured": false,
487 "Guarded": false,
488 "LocationCode": "/bmc0",
489 "Priority": "M"
490 }
491])";
492 EXPECT_EQ(s, j.dump(4));
493
494 // Callout FFDC
495 j = sd.getCalloutFFDC();
496 s = R"([
497 {
498 "Callout Type": "Part Callout",
499 "Part Type": "PNOR",
500 "Priority": "medium"
501 }
502])";
503 EXPECT_EQ(s, j.dump(4));
504}