blob: 4063bcbc1a163e6393e6b3665c80ad4a41ae1e90 [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 Shelley5d63cef2021-09-17 18:10:17 -05005#include <util/trace.hpp>
6
7#include <regex>
Zane Shelley0b8368c2021-03-18 17:33:41 -05008
9#include "gtest/gtest.h"
10
11// Chip string
12constexpr auto chip_str = "/proc0";
13
14// Unit paths
Zane Shelley5d63cef2021-09-17 18:10:17 -050015constexpr auto proc_str = "";
16constexpr auto iolink_str = "pib/perv24/pauc0/iohs0/smpgroup0";
17constexpr auto omi_str = "pib/perv12/mc0/mi0/mcc0/omi0";
18constexpr auto ocmb_str = "pib/perv12/mc0/mi0/mcc0/omi0/ocmb0";
19constexpr auto core_str = "pib/perv39/eq7/fc1/core1";
Zane Shelley0b8368c2021-03-18 17:33:41 -050020
21// Local implementation of this function.
22namespace analyzer
23{
24
Zane Shelley84721d92021-09-08 13:30:27 -050025//------------------------------------------------------------------------------
26
Zane Shelley96d54862021-09-17 11:16:12 -050027// Helper function to get the root cause chip target path from the service data.
28std::string __getRootCauseChipPath(const ServiceData& i_sd)
29{
30 return std::string{(const char*)i_sd.getRootCause().getChip().getChip()};
31}
32
33//------------------------------------------------------------------------------
34
35// Helper function to get a unit target path from the given unit path, which is
36// a devtree path relative the the containing chip. An empty string indicates
37// the chip target path should be returned.
38std::string __getUnitPath(const std::string& i_chipPath,
39 const std::string& i_unitPath)
40{
41 auto path = i_chipPath; // default, if i_unitPath is empty
42
43 if (!i_unitPath.empty())
44 {
45 path += "/" + i_unitPath;
46 }
47
48 return path;
49}
50
51//------------------------------------------------------------------------------
52
Zane Shelley5d63cef2021-09-17 18:10:17 -050053// Helper function to get the connected target Path on the other side of the
54// given bus.
55std::tuple<std::string, std::string>
56 __getConnectedPath(const std::string& i_rxPath,
57 const callout::BusType& i_busType)
58{
59 std::string txUnitPath{};
60 std::string txChipPath{};
61
62 // Need to get the target type from the RX path.
63 const std::regex re{"(/proc0)(.*)/([a-z]+)([0-9]+)"};
64 std::smatch match;
65 std::regex_match(i_rxPath, match, re);
66 assert(5 == match.size());
67 std::string rxType = match[3].str();
68
69 if (callout::BusType::SMP_BUS == i_busType && "smpgroup" == rxType)
70 {
71 // Use the RX unit path on a different processor.
72 txUnitPath = "/proc1" + match[2].str() + "/" + rxType + match[4].str();
73 txChipPath = "/proc1";
74 }
75 else if (callout::BusType::OMI_BUS == i_busType && "omi" == rxType)
76 {
77 // Append the OCMB to the RX path.
78 txUnitPath = i_rxPath + "/ocmb0";
79 txChipPath = txUnitPath;
80 }
81 else if (callout::BusType::OMI_BUS == i_busType && "ocmb" == rxType)
82 {
83 // Strip the OCMB off of the RX path.
84 txUnitPath = match[1].str() + match[2].str();
85 txChipPath = "/proc0";
86 }
87 else
88 {
89 // This would be a code bug.
90 throw std::logic_error("Unsupported config: i_rxTarget=" + i_rxPath +
91 " i_busType=" + i_busType.getString());
92 }
93
94 assert(!txUnitPath.empty()); // just in case we missed something above
95
96 return std::make_tuple(txUnitPath, txChipPath);
97}
98
99//------------------------------------------------------------------------------
100
Zane Shelley9a738f72021-11-03 20:45:30 -0500101void __calloutTarget(ServiceData& io_sd, const std::string& i_locCode,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600102 const callout::Priority& i_priority, bool i_guard,
103 const std::string& i_guardPath)
Zane Shelley9a738f72021-11-03 20:45:30 -0500104{
105 nlohmann::json callout;
106 callout["LocationCode"] = i_locCode;
107 callout["Priority"] = i_priority.getUserDataString();
108 callout["Deconfigured"] = false;
Zane Shelleybf3326f2021-11-12 13:41:39 -0600109 callout["Guarded"] = false; // default
110
111 // Check if guard info should be added.
112 if (i_guard)
113 {
114 auto guardType = io_sd.queryGuardPolicy();
115
116 if (!(callout::GuardType::NONE == guardType))
117 {
118 callout["Guarded"] = true;
119 callout["Guard Path"] = i_guardPath;
120 callout["Guard Type"] = guardType.getString();
121 }
122 }
123
Zane Shelley9a738f72021-11-03 20:45:30 -0500124 io_sd.addCallout(callout);
125}
126
127//------------------------------------------------------------------------------
128
Zane Shelley1eff9452021-11-03 13:59:54 -0500129void __calloutBackplane(ServiceData& io_sd, const callout::Priority& i_priority)
130{
131 // TODO: There isn't a device tree object for this. So will need to hardcode
132 // the location code for now. In the future, we will need a mechanism
133 // to make this data driven.
134
135 nlohmann::json callout;
136 callout["LocationCode"] = "P0";
137 callout["Priority"] = i_priority.getUserDataString();
138 callout["Deconfigured"] = false;
139 callout["Guarded"] = false;
140 io_sd.addCallout(callout);
141}
142
143//------------------------------------------------------------------------------
144
Zane Shelley0b8368c2021-03-18 17:33:41 -0500145void HardwareCalloutResolution::resolve(ServiceData& io_sd) const
146{
Zane Shelley96d54862021-09-17 11:16:12 -0500147 // Get the location code and entity path for this target.
148 auto locCode = __getRootCauseChipPath(io_sd);
149 auto entityPath = __getUnitPath(locCode, iv_unitPath);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500150
Zane Shelleyc85716c2021-08-17 10:54:06 -0500151 // Add the actual callout to the service data.
Zane Shelleybf3326f2021-11-12 13:41:39 -0600152 __calloutTarget(io_sd, locCode, iv_priority, iv_guard, entityPath);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500153
Zane Shelley96d54862021-09-17 11:16:12 -0500154 // Add the callout FFDC to the service data.
155 nlohmann::json ffdc;
156 ffdc["Callout Type"] = "Hardware Callout";
157 ffdc["Target"] = entityPath;
158 ffdc["Priority"] = iv_priority.getRegistryString();
Zane Shelleya00426f2021-11-04 10:50:50 -0500159 ffdc["Guard"] = iv_guard;
Zane Shelley96d54862021-09-17 11:16:12 -0500160 io_sd.addCalloutFFDC(ffdc);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500161}
162
Zane Shelleyc85716c2021-08-17 10:54:06 -0500163//------------------------------------------------------------------------------
164
Zane Shelley5d63cef2021-09-17 18:10:17 -0500165void ConnectedCalloutResolution::resolve(ServiceData& io_sd) const
166{
167 // Get the chip target path from the root cause signature.
168 auto chipPath = __getRootCauseChipPath(io_sd);
169
170 // Get the endpoint target path for the receiving side of the bus.
171 auto rxPath = __getUnitPath(chipPath, iv_unitPath);
172
173 // Get the endpoint target path for the transfer side of the bus.
174 auto txPath = __getConnectedPath(rxPath, iv_busType);
175
176 // Callout the TX endpoint.
Zane Shelleybf3326f2021-11-12 13:41:39 -0600177 __calloutTarget(io_sd, std::get<1>(txPath), iv_priority, iv_guard,
178 std::get<0>(txPath));
Zane Shelley5d63cef2021-09-17 18:10:17 -0500179
Zane Shelley5d63cef2021-09-17 18:10:17 -0500180 // Add the callout FFDC to the service data.
181 nlohmann::json ffdc;
182 ffdc["Callout Type"] = "Connected Callout";
183 ffdc["Bus Type"] = iv_busType.getString();
184 ffdc["Target"] = std::get<0>(txPath);
185 ffdc["Priority"] = iv_priority.getRegistryString();
Zane Shelleya00426f2021-11-04 10:50:50 -0500186 ffdc["Guard"] = iv_guard;
Zane Shelley5d63cef2021-09-17 18:10:17 -0500187 io_sd.addCalloutFFDC(ffdc);
188}
189
190//------------------------------------------------------------------------------
191
Zane Shelley4757a7b2021-09-20 22:23:38 -0500192void BusCalloutResolution::resolve(ServiceData& io_sd) const
193{
194 // Get the chip target path from the root cause signature.
195 auto chipPath = __getRootCauseChipPath(io_sd);
196
197 // Get the endpoint target path for the receiving side of the bus.
198 auto rxPath = __getUnitPath(chipPath, iv_unitPath);
199
200 // Get the endpoint target path for the transfer side of the bus.
201 auto txPath = __getConnectedPath(rxPath, iv_busType);
202
203 // Callout the RX endpoint.
Zane Shelleybf3326f2021-11-12 13:41:39 -0600204 __calloutTarget(io_sd, chipPath, iv_priority, iv_guard, rxPath);
Zane Shelley4757a7b2021-09-20 22:23:38 -0500205
206 // Callout the TX endpoint.
Zane Shelleybf3326f2021-11-12 13:41:39 -0600207 __calloutTarget(io_sd, std::get<1>(txPath), iv_priority, iv_guard,
208 std::get<0>(txPath));
Zane Shelley4757a7b2021-09-20 22:23:38 -0500209
210 // Callout everything else in between.
211 // TODO: For P10 (OMI bus and XBUS), the callout is simply the backplane.
Zane Shelley1eff9452021-11-03 13:59:54 -0500212 __calloutBackplane(io_sd, iv_priority);
Zane Shelley4757a7b2021-09-20 22:23:38 -0500213
Zane Shelley4757a7b2021-09-20 22:23:38 -0500214 // Add the callout FFDC to the service data.
215 nlohmann::json ffdc;
216 ffdc["Callout Type"] = "Bus Callout";
217 ffdc["Bus Type"] = iv_busType.getString();
218 ffdc["RX Target"] = rxPath;
219 ffdc["TX Target"] = std::get<0>(txPath);
220 ffdc["Priority"] = iv_priority.getRegistryString();
Zane Shelleya00426f2021-11-04 10:50:50 -0500221 ffdc["Guard"] = iv_guard;
Zane Shelley4757a7b2021-09-20 22:23:38 -0500222 io_sd.addCalloutFFDC(ffdc);
223}
224
225//------------------------------------------------------------------------------
226
Zane Shelleyc85716c2021-08-17 10:54:06 -0500227void ProcedureCalloutResolution::resolve(ServiceData& io_sd) const
228{
229 // Add the actual callout to the service data.
230 nlohmann::json callout;
231 callout["Procedure"] = iv_procedure.getString();
232 callout["Priority"] = iv_priority.getUserDataString();
233 io_sd.addCallout(callout);
Zane Shelley96d54862021-09-17 11:16:12 -0500234
235 // Add the callout FFDC to the service data.
236 nlohmann::json ffdc;
237 ffdc["Callout Type"] = "Procedure Callout";
238 ffdc["Procedure"] = iv_procedure.getString();
239 ffdc["Priority"] = iv_priority.getRegistryString();
240 io_sd.addCalloutFFDC(ffdc);
Zane Shelleyc85716c2021-08-17 10:54:06 -0500241}
242
Zane Shelley84721d92021-09-08 13:30:27 -0500243//------------------------------------------------------------------------------
244
245void ClockCalloutResolution::resolve(ServiceData& io_sd) const
246{
Zane Shelley1eff9452021-11-03 13:59:54 -0500247 // Callout the clock target.
248 // TODO: For P10, the callout is simply the backplane. Also, there are no
249 // clock targets in the device tree. So at the moment there is no
250 // guard support for clock targets.
251 __calloutBackplane(io_sd, iv_priority);
Zane Shelley96d54862021-09-17 11:16:12 -0500252
253 // Add the callout FFDC to the service data.
Zane Shelley1eff9452021-11-03 13:59:54 -0500254 // TODO: Add the target and guard type if guard is ever supported.
Zane Shelley96d54862021-09-17 11:16:12 -0500255 nlohmann::json ffdc;
256 ffdc["Callout Type"] = "Clock Callout";
257 ffdc["Clock Type"] = iv_clockType.getString();
Zane Shelley96d54862021-09-17 11:16:12 -0500258 ffdc["Priority"] = iv_priority.getRegistryString();
Zane Shelley96d54862021-09-17 11:16:12 -0500259 io_sd.addCalloutFFDC(ffdc);
Zane Shelley84721d92021-09-08 13:30:27 -0500260}
261
262//------------------------------------------------------------------------------
263
Zane Shelley0b8368c2021-03-18 17:33:41 -0500264} // namespace analyzer
265
266using namespace analyzer;
267
268TEST(Resolution, TestSet1)
269{
270 // Create a few resolutions
271 auto c1 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500272 proc_str, callout::Priority::HIGH, false);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500273
274 auto c2 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500275 omi_str, callout::Priority::MED_A, true);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500276
277 auto c3 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500278 core_str, callout::Priority::MED, true);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500279
280 auto c4 = std::make_shared<ProcedureCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500281 callout::Procedure::NEXTLVL, callout::Priority::LOW);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500282
Zane Shelley84721d92021-09-08 13:30:27 -0500283 auto c5 = std::make_shared<ClockCalloutResolution>(
284 callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::LOW, false);
285
286 // l1 = (c1, c2, c5)
Zane Shelley723fa232021-08-09 12:02:06 -0500287 auto l1 = std::make_shared<ResolutionList>();
288 l1->push(c1);
289 l1->push(c2);
Zane Shelley84721d92021-09-08 13:30:27 -0500290 l1->push(c5);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500291
Zane Shelley84721d92021-09-08 13:30:27 -0500292 // l2 = (c4, c3, c1, c2, c5)
Zane Shelley723fa232021-08-09 12:02:06 -0500293 auto l2 = std::make_shared<ResolutionList>();
294 l2->push(c4);
295 l2->push(c3);
296 l2->push(l1);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500297
298 // Get some ServiceData objects
299 libhei::Chip chip{chip_str, 0xdeadbeef};
300 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley82be3ab2021-12-07 10:36:08 -0600301 ServiceData sd1{sig, AnalysisType::SYSTEM_CHECKSTOP};
302 ServiceData sd2{sig, AnalysisType::TERMINATE_IMMEDIATE};
Zane Shelley0b8368c2021-03-18 17:33:41 -0500303
304 // Resolve
Zane Shelley723fa232021-08-09 12:02:06 -0500305 l1->resolve(sd1);
306 l2->resolve(sd2);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500307
308 // Start verifying
309 nlohmann::json j{};
310 std::string s{};
311
Zane Shelleyc85716c2021-08-17 10:54:06 -0500312 j = sd1.getCalloutList();
Zane Shelley0b8368c2021-03-18 17:33:41 -0500313 s = R"([
314 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500315 "Deconfigured": false,
316 "Guarded": false,
Zane Shelley0b8368c2021-03-18 17:33:41 -0500317 "LocationCode": "/proc0",
318 "Priority": "H"
319 },
320 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500321 "Deconfigured": false,
322 "Guarded": false,
Zane Shelley84721d92021-09-08 13:30:27 -0500323 "LocationCode": "P0",
324 "Priority": "L"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500325 }
326])";
Zane Shelley96d54862021-09-17 11:16:12 -0500327 EXPECT_EQ(s, j.dump(4));
Zane Shelley0b8368c2021-03-18 17:33:41 -0500328
Zane Shelleyc85716c2021-08-17 10:54:06 -0500329 j = sd2.getCalloutList();
Zane Shelley0b8368c2021-03-18 17:33:41 -0500330 s = R"([
331 {
332 "Priority": "L",
Zane Shelley86ccc452021-11-16 13:10:52 -0600333 "Procedure": "next_level_support"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500334 },
335 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500336 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600337 "Guard Path": "/proc0/pib/perv39/eq7/fc1/core1",
338 "Guard Type": "GARD_Predictive",
Zane Shelley9a738f72021-11-03 20:45:30 -0500339 "Guarded": true,
Zane Shelley0b8368c2021-03-18 17:33:41 -0500340 "LocationCode": "/proc0",
Zane Shelley0b8368c2021-03-18 17:33:41 -0500341 "Priority": "H"
342 },
343 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500344 "Deconfigured": false,
345 "Guarded": false,
Zane Shelley84721d92021-09-08 13:30:27 -0500346 "LocationCode": "P0",
347 "Priority": "L"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500348 }
349])";
Zane Shelley96d54862021-09-17 11:16:12 -0500350 EXPECT_EQ(s, j.dump(4));
351}
352
353TEST(Resolution, HardwareCallout)
354{
355 auto c1 = std::make_shared<HardwareCalloutResolution>(
356 omi_str, callout::Priority::MED_A, true);
357
358 libhei::Chip chip{chip_str, 0xdeadbeef};
359 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley82be3ab2021-12-07 10:36:08 -0600360 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP};
Zane Shelley96d54862021-09-17 11:16:12 -0500361
362 c1->resolve(sd);
363
364 nlohmann::json j{};
365 std::string s{};
366
367 // Callout list
368 j = sd.getCalloutList();
369 s = R"([
370 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500371 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600372 "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
373 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500374 "Guarded": true,
Zane Shelley96d54862021-09-17 11:16:12 -0500375 "LocationCode": "/proc0",
376 "Priority": "A"
377 }
378])";
379 EXPECT_EQ(s, j.dump(4));
380
381 // Callout FFDC
382 j = sd.getCalloutFFDC();
383 s = R"([
384 {
385 "Callout Type": "Hardware Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500386 "Guard": true,
Zane Shelley96d54862021-09-17 11:16:12 -0500387 "Priority": "medium_group_A",
388 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0"
389 }
390])";
391 EXPECT_EQ(s, j.dump(4));
392}
393
Zane Shelley5d63cef2021-09-17 18:10:17 -0500394TEST(Resolution, ConnectedCallout)
395{
396 auto c1 = std::make_shared<ConnectedCalloutResolution>(
397 callout::BusType::SMP_BUS, iolink_str, callout::Priority::MED_A, true);
398
399 auto c2 = std::make_shared<ConnectedCalloutResolution>(
400 callout::BusType::OMI_BUS, ocmb_str, callout::Priority::MED_B, true);
401
402 auto c3 = std::make_shared<ConnectedCalloutResolution>(
403 callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_C, true);
404
405 libhei::Chip chip{chip_str, 0xdeadbeef};
406 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley82be3ab2021-12-07 10:36:08 -0600407 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP};
Zane Shelley5d63cef2021-09-17 18:10:17 -0500408
409 nlohmann::json j{};
410 std::string s{};
411
412 c1->resolve(sd);
413 c2->resolve(sd);
414 c3->resolve(sd);
415
416 // Callout list
417 j = sd.getCalloutList();
418 s = R"([
419 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500420 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600421 "Guard Path": "/proc1/pib/perv24/pauc0/iohs0/smpgroup0",
422 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500423 "Guarded": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500424 "LocationCode": "/proc1",
425 "Priority": "A"
426 },
427 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500428 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600429 "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
430 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500431 "Guarded": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500432 "LocationCode": "/proc0",
433 "Priority": "B"
434 },
435 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500436 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600437 "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
438 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500439 "Guarded": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500440 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
441 "Priority": "C"
442 }
443])";
444 EXPECT_EQ(s, j.dump(4));
445
446 // Callout FFDC
447 j = sd.getCalloutFFDC();
448 s = R"([
449 {
450 "Bus Type": "SMP_BUS",
451 "Callout Type": "Connected Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500452 "Guard": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500453 "Priority": "medium_group_A",
454 "Target": "/proc1/pib/perv24/pauc0/iohs0/smpgroup0"
455 },
456 {
457 "Bus Type": "OMI_BUS",
458 "Callout Type": "Connected Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500459 "Guard": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500460 "Priority": "medium_group_B",
461 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0"
462 },
463 {
464 "Bus Type": "OMI_BUS",
465 "Callout Type": "Connected Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500466 "Guard": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500467 "Priority": "medium_group_C",
468 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
469 }
470])";
471 EXPECT_EQ(s, j.dump(4));
472}
473
Zane Shelley4757a7b2021-09-20 22:23:38 -0500474TEST(Resolution, BusCallout)
475{
476 auto c1 = std::make_shared<HardwareCalloutResolution>(
477 omi_str, callout::Priority::MED_A, true);
478
479 auto c2 = std::make_shared<ConnectedCalloutResolution>(
480 callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_A, true);
481
482 auto c3 = std::make_shared<BusCalloutResolution>(
483 callout::BusType::OMI_BUS, omi_str, callout::Priority::LOW, false);
484
485 libhei::Chip chip{chip_str, 0xdeadbeef};
486 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley82be3ab2021-12-07 10:36:08 -0600487 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP};
Zane Shelley4757a7b2021-09-20 22:23:38 -0500488
489 nlohmann::json j{};
490 std::string s{};
491
492 c1->resolve(sd);
493 c2->resolve(sd);
494 c3->resolve(sd);
495
496 // Callout list
497 j = sd.getCalloutList();
498 s = R"([
499 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500500 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600501 "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
502 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500503 "Guarded": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500504 "LocationCode": "/proc0",
505 "Priority": "A"
506 },
507 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500508 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600509 "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
510 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500511 "Guarded": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500512 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
513 "Priority": "A"
514 },
515 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500516 "Deconfigured": false,
517 "Guarded": false,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500518 "LocationCode": "P0",
519 "Priority": "L"
520 }
521])";
522 EXPECT_EQ(s, j.dump(4));
523
524 // Callout FFDC
525 j = sd.getCalloutFFDC();
526 s = R"([
527 {
528 "Callout Type": "Hardware Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500529 "Guard": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500530 "Priority": "medium_group_A",
531 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0"
532 },
533 {
534 "Bus Type": "OMI_BUS",
535 "Callout Type": "Connected Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500536 "Guard": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500537 "Priority": "medium_group_A",
538 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
539 },
540 {
541 "Bus Type": "OMI_BUS",
542 "Callout Type": "Bus Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500543 "Guard": false,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500544 "Priority": "low",
545 "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
546 "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
547 }
548])";
549 EXPECT_EQ(s, j.dump(4));
550}
551
Zane Shelley96d54862021-09-17 11:16:12 -0500552TEST(Resolution, ClockCallout)
553{
554 auto c1 = std::make_shared<ClockCalloutResolution>(
555 callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::HIGH, false);
556
557 libhei::Chip chip{chip_str, 0xdeadbeef};
558 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley82be3ab2021-12-07 10:36:08 -0600559 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP};
Zane Shelley96d54862021-09-17 11:16:12 -0500560
561 c1->resolve(sd);
562
563 nlohmann::json j{};
564 std::string s{};
565
566 // Callout list
567 j = sd.getCalloutList();
568 s = R"([
569 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500570 "Deconfigured": false,
571 "Guarded": false,
Zane Shelley96d54862021-09-17 11:16:12 -0500572 "LocationCode": "P0",
573 "Priority": "H"
574 }
575])";
576 EXPECT_EQ(s, j.dump(4));
577
578 // Callout FFDC
579 j = sd.getCalloutFFDC();
580 s = R"([
581 {
582 "Callout Type": "Clock Callout",
583 "Clock Type": "OSC_REF_CLOCK_1",
Zane Shelley1eff9452021-11-03 13:59:54 -0500584 "Priority": "high"
Zane Shelley96d54862021-09-17 11:16:12 -0500585 }
586])";
587 EXPECT_EQ(s, j.dump(4));
588}
589
590TEST(Resolution, ProcedureCallout)
591{
592 auto c1 = std::make_shared<ProcedureCalloutResolution>(
593 callout::Procedure::NEXTLVL, callout::Priority::LOW);
594
595 libhei::Chip chip{chip_str, 0xdeadbeef};
596 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
Zane Shelley82be3ab2021-12-07 10:36:08 -0600597 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP};
Zane Shelley96d54862021-09-17 11:16:12 -0500598
599 c1->resolve(sd);
600
601 nlohmann::json j{};
602 std::string s{};
603
604 // Callout list
605 j = sd.getCalloutList();
606 s = R"([
607 {
608 "Priority": "L",
Zane Shelley86ccc452021-11-16 13:10:52 -0600609 "Procedure": "next_level_support"
Zane Shelley96d54862021-09-17 11:16:12 -0500610 }
611])";
612 EXPECT_EQ(s, j.dump(4));
613
614 // Callout FFDC
615 j = sd.getCalloutFFDC();
616 s = R"([
617 {
618 "Callout Type": "Procedure Callout",
619 "Priority": "low",
Zane Shelley86ccc452021-11-16 13:10:52 -0600620 "Procedure": "next_level_support"
Zane Shelley96d54862021-09-17 11:16:12 -0500621 }
622])";
623 EXPECT_EQ(s, j.dump(4));
Zane Shelley0b8368c2021-03-18 17:33:41 -0500624}