blob: 55be8281c29ebc444e2006286ae2018d70187622 [file] [log] [blame]
Zane Shelley0b8368c2021-03-18 17:33:41 -05001#include <stdio.h>
2
3#include <analyzer/resolution.hpp>
Zane Shelley5d63cef2021-09-17 18:10:17 -05004#include <util/trace.hpp>
5
6#include <regex>
Zane Shelley0b8368c2021-03-18 17:33:41 -05007
8#include "gtest/gtest.h"
9
10// Chip string
11constexpr auto chip_str = "/proc0";
12
13// Unit paths
Zane Shelley5d63cef2021-09-17 18:10:17 -050014constexpr auto proc_str = "";
15constexpr auto iolink_str = "pib/perv24/pauc0/iohs0/smpgroup0";
16constexpr auto omi_str = "pib/perv12/mc0/mi0/mcc0/omi0";
17constexpr auto ocmb_str = "pib/perv12/mc0/mi0/mcc0/omi0/ocmb0";
18constexpr auto core_str = "pib/perv39/eq7/fc1/core1";
Zane Shelley0b8368c2021-03-18 17:33:41 -050019
20// Local implementation of this function.
21namespace analyzer
22{
23
Zane Shelley84721d92021-09-08 13:30:27 -050024//------------------------------------------------------------------------------
25
Zane Shelley96d54862021-09-17 11:16:12 -050026// Helper function to get the root cause chip target path from the service data.
27std::string __getRootCauseChipPath(const ServiceData& i_sd)
28{
29 return std::string{(const char*)i_sd.getRootCause().getChip().getChip()};
30}
31
32//------------------------------------------------------------------------------
33
34// Helper function to get a unit target path from the given unit path, which is
35// a devtree path relative the the containing chip. An empty string indicates
36// the chip target path should be returned.
37std::string __getUnitPath(const std::string& i_chipPath,
38 const std::string& i_unitPath)
39{
40 auto path = i_chipPath; // default, if i_unitPath is empty
41
42 if (!i_unitPath.empty())
43 {
44 path += "/" + i_unitPath;
45 }
46
47 return path;
48}
49
50//------------------------------------------------------------------------------
51
Zane Shelley5d63cef2021-09-17 18:10:17 -050052// Helper function to get the connected target Path on the other side of the
53// given bus.
54std::tuple<std::string, std::string>
55 __getConnectedPath(const std::string& i_rxPath,
56 const callout::BusType& i_busType)
57{
58 std::string txUnitPath{};
59 std::string txChipPath{};
60
61 // Need to get the target type from the RX path.
62 const std::regex re{"(/proc0)(.*)/([a-z]+)([0-9]+)"};
63 std::smatch match;
64 std::regex_match(i_rxPath, match, re);
65 assert(5 == match.size());
66 std::string rxType = match[3].str();
67
68 if (callout::BusType::SMP_BUS == i_busType && "smpgroup" == rxType)
69 {
70 // Use the RX unit path on a different processor.
71 txUnitPath = "/proc1" + match[2].str() + "/" + rxType + match[4].str();
72 txChipPath = "/proc1";
73 }
74 else if (callout::BusType::OMI_BUS == i_busType && "omi" == rxType)
75 {
76 // Append the OCMB to the RX path.
77 txUnitPath = i_rxPath + "/ocmb0";
78 txChipPath = txUnitPath;
79 }
80 else if (callout::BusType::OMI_BUS == i_busType && "ocmb" == rxType)
81 {
82 // Strip the OCMB off of the RX path.
83 txUnitPath = match[1].str() + match[2].str();
84 txChipPath = "/proc0";
85 }
86 else
87 {
88 // This would be a code bug.
89 throw std::logic_error("Unsupported config: i_rxTarget=" + i_rxPath +
90 " i_busType=" + i_busType.getString());
91 }
92
93 assert(!txUnitPath.empty()); // just in case we missed something above
94
95 return std::make_tuple(txUnitPath, txChipPath);
96}
97
98//------------------------------------------------------------------------------
99
Zane Shelley9a738f72021-11-03 20:45:30 -0500100void __calloutTarget(ServiceData& io_sd, const std::string& i_locCode,
101 const callout::Priority& i_priority, bool i_guard)
102{
103 nlohmann::json callout;
104 callout["LocationCode"] = i_locCode;
105 callout["Priority"] = i_priority.getUserDataString();
106 callout["Deconfigured"] = false;
107 callout["Guarded"] = i_guard;
108 io_sd.addCallout(callout);
109}
110
111//------------------------------------------------------------------------------
112
Zane Shelley1eff9452021-11-03 13:59:54 -0500113void __calloutBackplane(ServiceData& io_sd, const callout::Priority& i_priority)
114{
115 // TODO: There isn't a device tree object for this. So will need to hardcode
116 // the location code for now. In the future, we will need a mechanism
117 // to make this data driven.
118
119 nlohmann::json callout;
120 callout["LocationCode"] = "P0";
121 callout["Priority"] = i_priority.getUserDataString();
122 callout["Deconfigured"] = false;
123 callout["Guarded"] = false;
124 io_sd.addCallout(callout);
125}
126
127//------------------------------------------------------------------------------
128
Zane Shelley0b8368c2021-03-18 17:33:41 -0500129void HardwareCalloutResolution::resolve(ServiceData& io_sd) const
130{
Zane Shelley96d54862021-09-17 11:16:12 -0500131 // Get the location code and entity path for this target.
132 auto locCode = __getRootCauseChipPath(io_sd);
133 auto entityPath = __getUnitPath(locCode, iv_unitPath);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500134
Zane Shelleyc85716c2021-08-17 10:54:06 -0500135 // Add the actual callout to the service data.
Zane Shelley9a738f72021-11-03 20:45:30 -0500136 __calloutTarget(io_sd, locCode, iv_priority, iv_guard);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500137
Zane Shelley95135822021-08-23 09:00:05 -0500138 // Add the guard info to the service data.
Zane Shelley96d54862021-09-17 11:16:12 -0500139 Guard guard = io_sd.addGuard(entityPath, iv_guard);
140
141 // Add the callout FFDC to the service data.
142 nlohmann::json ffdc;
143 ffdc["Callout Type"] = "Hardware Callout";
144 ffdc["Target"] = entityPath;
145 ffdc["Priority"] = iv_priority.getRegistryString();
146 ffdc["Guard Type"] = guard.getString();
147 io_sd.addCalloutFFDC(ffdc);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500148}
149
Zane Shelleyc85716c2021-08-17 10:54:06 -0500150//------------------------------------------------------------------------------
151
Zane Shelley5d63cef2021-09-17 18:10:17 -0500152void ConnectedCalloutResolution::resolve(ServiceData& io_sd) const
153{
154 // Get the chip target path from the root cause signature.
155 auto chipPath = __getRootCauseChipPath(io_sd);
156
157 // Get the endpoint target path for the receiving side of the bus.
158 auto rxPath = __getUnitPath(chipPath, iv_unitPath);
159
160 // Get the endpoint target path for the transfer side of the bus.
161 auto txPath = __getConnectedPath(rxPath, iv_busType);
162
163 // Callout the TX endpoint.
Zane Shelley9a738f72021-11-03 20:45:30 -0500164 __calloutTarget(io_sd, std::get<1>(txPath), iv_priority, iv_guard);
Zane Shelley5d63cef2021-09-17 18:10:17 -0500165
166 // Guard the TX endpoint.
167 Guard txGuard = io_sd.addGuard(std::get<0>(txPath), iv_guard);
168
169 // Add the callout FFDC to the service data.
170 nlohmann::json ffdc;
171 ffdc["Callout Type"] = "Connected Callout";
172 ffdc["Bus Type"] = iv_busType.getString();
173 ffdc["Target"] = std::get<0>(txPath);
174 ffdc["Priority"] = iv_priority.getRegistryString();
175 ffdc["Guard Type"] = txGuard.getString();
176 io_sd.addCalloutFFDC(ffdc);
177}
178
179//------------------------------------------------------------------------------
180
Zane Shelley4757a7b2021-09-20 22:23:38 -0500181void BusCalloutResolution::resolve(ServiceData& io_sd) const
182{
183 // Get the chip target path from the root cause signature.
184 auto chipPath = __getRootCauseChipPath(io_sd);
185
186 // Get the endpoint target path for the receiving side of the bus.
187 auto rxPath = __getUnitPath(chipPath, iv_unitPath);
188
189 // Get the endpoint target path for the transfer side of the bus.
190 auto txPath = __getConnectedPath(rxPath, iv_busType);
191
192 // Callout the RX endpoint.
Zane Shelley9a738f72021-11-03 20:45:30 -0500193 __calloutTarget(io_sd, chipPath, iv_priority, iv_guard);
Zane Shelley4757a7b2021-09-20 22:23:38 -0500194
195 // Callout the TX endpoint.
Zane Shelley9a738f72021-11-03 20:45:30 -0500196 __calloutTarget(io_sd, std::get<1>(txPath), iv_priority, iv_guard);
Zane Shelley4757a7b2021-09-20 22:23:38 -0500197
198 // Callout everything else in between.
199 // TODO: For P10 (OMI bus and XBUS), the callout is simply the backplane.
Zane Shelley1eff9452021-11-03 13:59:54 -0500200 __calloutBackplane(io_sd, iv_priority);
Zane Shelley4757a7b2021-09-20 22:23:38 -0500201
202 // Guard the RX endpoint.
203 Guard guard = io_sd.addGuard(rxPath, iv_guard);
204
205 // Guard the TX endpoint.
206 // No need to check return because it is the same as RX target.
207 io_sd.addGuard(std::get<0>(txPath), iv_guard);
208
209 // TODO: Currently no guard for "everything else in between".
210
211 // Add the callout FFDC to the service data.
212 nlohmann::json ffdc;
213 ffdc["Callout Type"] = "Bus Callout";
214 ffdc["Bus Type"] = iv_busType.getString();
215 ffdc["RX Target"] = rxPath;
216 ffdc["TX Target"] = std::get<0>(txPath);
217 ffdc["Priority"] = iv_priority.getRegistryString();
218 ffdc["Guard Type"] = guard.getString();
219 io_sd.addCalloutFFDC(ffdc);
220}
221
222//------------------------------------------------------------------------------
223
Zane Shelleyc85716c2021-08-17 10:54:06 -0500224void ProcedureCalloutResolution::resolve(ServiceData& io_sd) const
225{
226 // Add the actual callout to the service data.
227 nlohmann::json callout;
228 callout["Procedure"] = iv_procedure.getString();
229 callout["Priority"] = iv_priority.getUserDataString();
230 io_sd.addCallout(callout);
Zane Shelley96d54862021-09-17 11:16:12 -0500231
232 // Add the callout FFDC to the service data.
233 nlohmann::json ffdc;
234 ffdc["Callout Type"] = "Procedure Callout";
235 ffdc["Procedure"] = iv_procedure.getString();
236 ffdc["Priority"] = iv_priority.getRegistryString();
237 io_sd.addCalloutFFDC(ffdc);
Zane Shelleyc85716c2021-08-17 10:54:06 -0500238}
239
Zane Shelley84721d92021-09-08 13:30:27 -0500240//------------------------------------------------------------------------------
241
242void ClockCalloutResolution::resolve(ServiceData& io_sd) const
243{
Zane Shelley1eff9452021-11-03 13:59:54 -0500244 // Callout the clock target.
245 // TODO: For P10, the callout is simply the backplane. Also, there are no
246 // clock targets in the device tree. So at the moment there is no
247 // guard support for clock targets.
248 __calloutBackplane(io_sd, iv_priority);
Zane Shelley96d54862021-09-17 11:16:12 -0500249
250 // Add the callout FFDC to the service data.
Zane Shelley1eff9452021-11-03 13:59:54 -0500251 // TODO: Add the target and guard type if guard is ever supported.
Zane Shelley96d54862021-09-17 11:16:12 -0500252 nlohmann::json ffdc;
253 ffdc["Callout Type"] = "Clock Callout";
254 ffdc["Clock Type"] = iv_clockType.getString();
Zane Shelley96d54862021-09-17 11:16:12 -0500255 ffdc["Priority"] = iv_priority.getRegistryString();
Zane Shelley96d54862021-09-17 11:16:12 -0500256 io_sd.addCalloutFFDC(ffdc);
Zane Shelley84721d92021-09-08 13:30:27 -0500257}
258
259//------------------------------------------------------------------------------
260
Zane Shelley0b8368c2021-03-18 17:33:41 -0500261} // namespace analyzer
262
263using namespace analyzer;
264
265TEST(Resolution, TestSet1)
266{
267 // Create a few resolutions
268 auto c1 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500269 proc_str, callout::Priority::HIGH, false);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500270
271 auto c2 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500272 omi_str, callout::Priority::MED_A, true);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500273
274 auto c3 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500275 core_str, callout::Priority::MED, true);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500276
277 auto c4 = std::make_shared<ProcedureCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500278 callout::Procedure::NEXTLVL, callout::Priority::LOW);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500279
Zane Shelley84721d92021-09-08 13:30:27 -0500280 auto c5 = std::make_shared<ClockCalloutResolution>(
281 callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::LOW, false);
282
283 // l1 = (c1, c2, c5)
Zane Shelley723fa232021-08-09 12:02:06 -0500284 auto l1 = std::make_shared<ResolutionList>();
285 l1->push(c1);
286 l1->push(c2);
Zane Shelley84721d92021-09-08 13:30:27 -0500287 l1->push(c5);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500288
Zane Shelley84721d92021-09-08 13:30:27 -0500289 // l2 = (c4, c3, c1, c2, c5)
Zane Shelley723fa232021-08-09 12:02:06 -0500290 auto l2 = std::make_shared<ResolutionList>();
291 l2->push(c4);
292 l2->push(c3);
293 l2->push(l1);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500294
295 // Get some ServiceData objects
296 libhei::Chip chip{chip_str, 0xdeadbeef};
297 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelleyca496192021-08-09 12:05:52 -0500298 ServiceData sd1{sig, true};
299 ServiceData sd2{sig, false};
Zane Shelley0b8368c2021-03-18 17:33:41 -0500300
301 // Resolve
Zane Shelley723fa232021-08-09 12:02:06 -0500302 l1->resolve(sd1);
303 l2->resolve(sd2);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500304
305 // Start verifying
306 nlohmann::json j{};
307 std::string s{};
308
Zane Shelleyc85716c2021-08-17 10:54:06 -0500309 j = sd1.getCalloutList();
Zane Shelley0b8368c2021-03-18 17:33:41 -0500310 s = R"([
311 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500312 "Deconfigured": false,
313 "Guarded": false,
Zane Shelley0b8368c2021-03-18 17:33:41 -0500314 "LocationCode": "/proc0",
315 "Priority": "H"
316 },
317 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500318 "Deconfigured": false,
319 "Guarded": false,
Zane Shelley84721d92021-09-08 13:30:27 -0500320 "LocationCode": "P0",
321 "Priority": "L"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500322 }
323])";
Zane Shelley96d54862021-09-17 11:16:12 -0500324 EXPECT_EQ(s, j.dump(4));
Zane Shelley0b8368c2021-03-18 17:33:41 -0500325
Zane Shelleyc85716c2021-08-17 10:54:06 -0500326 j = sd2.getCalloutList();
Zane Shelley0b8368c2021-03-18 17:33:41 -0500327 s = R"([
328 {
329 "Priority": "L",
330 "Procedure": "NEXTLVL"
331 },
332 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500333 "Deconfigured": false,
334 "Guarded": true,
Zane Shelley0b8368c2021-03-18 17:33:41 -0500335 "LocationCode": "/proc0",
Zane Shelley0b8368c2021-03-18 17:33:41 -0500336 "Priority": "H"
337 },
338 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500339 "Deconfigured": false,
340 "Guarded": false,
Zane Shelley84721d92021-09-08 13:30:27 -0500341 "LocationCode": "P0",
342 "Priority": "L"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500343 }
344])";
Zane Shelley96d54862021-09-17 11:16:12 -0500345 EXPECT_EQ(s, j.dump(4));
346}
347
348TEST(Resolution, HardwareCallout)
349{
350 auto c1 = std::make_shared<HardwareCalloutResolution>(
351 omi_str, callout::Priority::MED_A, true);
352
353 libhei::Chip chip{chip_str, 0xdeadbeef};
354 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
355 ServiceData sd{sig, true};
356
357 c1->resolve(sd);
358
359 nlohmann::json j{};
360 std::string s{};
361
362 // Callout list
363 j = sd.getCalloutList();
364 s = R"([
365 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500366 "Deconfigured": false,
367 "Guarded": true,
Zane Shelley96d54862021-09-17 11:16:12 -0500368 "LocationCode": "/proc0",
369 "Priority": "A"
370 }
371])";
372 EXPECT_EQ(s, j.dump(4));
373
374 // Callout FFDC
375 j = sd.getCalloutFFDC();
376 s = R"([
377 {
378 "Callout Type": "Hardware Callout",
379 "Guard Type": "FATAL",
380 "Priority": "medium_group_A",
381 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0"
382 }
383])";
384 EXPECT_EQ(s, j.dump(4));
385}
386
Zane Shelley5d63cef2021-09-17 18:10:17 -0500387TEST(Resolution, ConnectedCallout)
388{
389 auto c1 = std::make_shared<ConnectedCalloutResolution>(
390 callout::BusType::SMP_BUS, iolink_str, callout::Priority::MED_A, true);
391
392 auto c2 = std::make_shared<ConnectedCalloutResolution>(
393 callout::BusType::OMI_BUS, ocmb_str, callout::Priority::MED_B, true);
394
395 auto c3 = std::make_shared<ConnectedCalloutResolution>(
396 callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_C, true);
397
398 libhei::Chip chip{chip_str, 0xdeadbeef};
399 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
400 ServiceData sd{sig, true};
401
402 nlohmann::json j{};
403 std::string s{};
404
405 c1->resolve(sd);
406 c2->resolve(sd);
407 c3->resolve(sd);
408
409 // Callout list
410 j = sd.getCalloutList();
411 s = R"([
412 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500413 "Deconfigured": false,
414 "Guarded": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500415 "LocationCode": "/proc1",
416 "Priority": "A"
417 },
418 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500419 "Deconfigured": false,
420 "Guarded": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500421 "LocationCode": "/proc0",
422 "Priority": "B"
423 },
424 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500425 "Deconfigured": false,
426 "Guarded": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500427 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
428 "Priority": "C"
429 }
430])";
431 EXPECT_EQ(s, j.dump(4));
432
433 // Callout FFDC
434 j = sd.getCalloutFFDC();
435 s = R"([
436 {
437 "Bus Type": "SMP_BUS",
438 "Callout Type": "Connected Callout",
439 "Guard Type": "FATAL",
440 "Priority": "medium_group_A",
441 "Target": "/proc1/pib/perv24/pauc0/iohs0/smpgroup0"
442 },
443 {
444 "Bus Type": "OMI_BUS",
445 "Callout Type": "Connected Callout",
446 "Guard Type": "FATAL",
447 "Priority": "medium_group_B",
448 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0"
449 },
450 {
451 "Bus Type": "OMI_BUS",
452 "Callout Type": "Connected Callout",
453 "Guard Type": "FATAL",
454 "Priority": "medium_group_C",
455 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
456 }
457])";
458 EXPECT_EQ(s, j.dump(4));
459}
460
Zane Shelley4757a7b2021-09-20 22:23:38 -0500461TEST(Resolution, BusCallout)
462{
463 auto c1 = std::make_shared<HardwareCalloutResolution>(
464 omi_str, callout::Priority::MED_A, true);
465
466 auto c2 = std::make_shared<ConnectedCalloutResolution>(
467 callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_A, true);
468
469 auto c3 = std::make_shared<BusCalloutResolution>(
470 callout::BusType::OMI_BUS, omi_str, callout::Priority::LOW, false);
471
472 libhei::Chip chip{chip_str, 0xdeadbeef};
473 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
474 ServiceData sd{sig, true};
475
476 nlohmann::json j{};
477 std::string s{};
478
479 c1->resolve(sd);
480 c2->resolve(sd);
481 c3->resolve(sd);
482
483 // Callout list
484 j = sd.getCalloutList();
485 s = R"([
486 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500487 "Deconfigured": false,
488 "Guarded": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500489 "LocationCode": "/proc0",
490 "Priority": "A"
491 },
492 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500493 "Deconfigured": false,
494 "Guarded": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500495 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
496 "Priority": "A"
497 },
498 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500499 "Deconfigured": false,
500 "Guarded": false,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500501 "LocationCode": "P0",
502 "Priority": "L"
503 }
504])";
505 EXPECT_EQ(s, j.dump(4));
506
507 // Callout FFDC
508 j = sd.getCalloutFFDC();
509 s = R"([
510 {
511 "Callout Type": "Hardware Callout",
512 "Guard Type": "FATAL",
513 "Priority": "medium_group_A",
514 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0"
515 },
516 {
517 "Bus Type": "OMI_BUS",
518 "Callout Type": "Connected Callout",
519 "Guard Type": "FATAL",
520 "Priority": "medium_group_A",
521 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
522 },
523 {
524 "Bus Type": "OMI_BUS",
525 "Callout Type": "Bus Callout",
526 "Guard Type": "NONE",
527 "Priority": "low",
528 "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
529 "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
530 }
531])";
532 EXPECT_EQ(s, j.dump(4));
533}
534
Zane Shelley96d54862021-09-17 11:16:12 -0500535TEST(Resolution, ClockCallout)
536{
537 auto c1 = std::make_shared<ClockCalloutResolution>(
538 callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::HIGH, false);
539
540 libhei::Chip chip{chip_str, 0xdeadbeef};
541 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
542 ServiceData sd{sig, true};
543
544 c1->resolve(sd);
545
546 nlohmann::json j{};
547 std::string s{};
548
549 // Callout list
550 j = sd.getCalloutList();
551 s = R"([
552 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500553 "Deconfigured": false,
554 "Guarded": false,
Zane Shelley96d54862021-09-17 11:16:12 -0500555 "LocationCode": "P0",
556 "Priority": "H"
557 }
558])";
559 EXPECT_EQ(s, j.dump(4));
560
561 // Callout FFDC
562 j = sd.getCalloutFFDC();
563 s = R"([
564 {
565 "Callout Type": "Clock Callout",
566 "Clock Type": "OSC_REF_CLOCK_1",
Zane Shelley1eff9452021-11-03 13:59:54 -0500567 "Priority": "high"
Zane Shelley96d54862021-09-17 11:16:12 -0500568 }
569])";
570 EXPECT_EQ(s, j.dump(4));
571}
572
573TEST(Resolution, ProcedureCallout)
574{
575 auto c1 = std::make_shared<ProcedureCalloutResolution>(
576 callout::Procedure::NEXTLVL, callout::Priority::LOW);
577
578 libhei::Chip chip{chip_str, 0xdeadbeef};
579 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
580 ServiceData sd{sig, true};
581
582 c1->resolve(sd);
583
584 nlohmann::json j{};
585 std::string s{};
586
587 // Callout list
588 j = sd.getCalloutList();
589 s = R"([
590 {
591 "Priority": "L",
592 "Procedure": "NEXTLVL"
593 }
594])";
595 EXPECT_EQ(s, j.dump(4));
596
597 // Callout FFDC
598 j = sd.getCalloutFFDC();
599 s = R"([
600 {
601 "Callout Type": "Procedure Callout",
602 "Priority": "low",
603 "Procedure": "NEXTLVL"
604 }
605])";
606 EXPECT_EQ(s, j.dump(4));
Zane Shelley0b8368c2021-03-18 17:33:41 -0500607}