blob: 3c2c3f7ba3ef7923776654c5f3c364ca742dbc80 [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
Patrick Williams27dd6362023-05-10 07:51:20 -050016constexpr auto proc_str = "";
Caleb Palmer626270a2022-02-21 11:05:08 -060017constexpr auto iolink_str = "pib/perv26/pauc1/iohs0/smpgroup0";
Patrick Williams27dd6362023-05-10 07:51:20 -050018constexpr 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 Shelleyadda0542023-04-06 16:38:02 -050058 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS};
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 = {
Caleb Palmerbc94bde2022-02-18 09:03:37 -060070 callout::SrcSubsystem::PROCESSOR_FRU, callout::Priority::HIGH};
Zane Shelley55e7fec2022-01-28 15:29:44 -060071 EXPECT_EQ(sd1.getSubsys(), subsys);
72
Caleb Palmerbc94bde2022-02-18 09:03:37 -060073 subsys = {callout::SrcSubsystem::PROCESSOR_FRU, callout::Priority::HIGH};
Zane Shelley55e7fec2022-01-28 15:29:44 -060074 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 Shelleyadda0542023-04-06 16:38:02 -0500151 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS};
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 = {
Caleb Palmerbc94bde2022-02-18 09:03:37 -0600159 callout::SrcSubsystem::MEMORY_CTLR, callout::Priority::MED_A};
Zane Shelley55e7fec2022-01-28 15:29:44 -0600160 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 Shelleyadda0542023-04-06 16:38:02 -0500206 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS};
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 = {
Caleb Palmerbc94bde2022-02-18 09:03:37 -0600219 callout::SrcSubsystem::PROCESSOR_BUS, callout::Priority::MED_A};
Zane Shelley55e7fec2022-01-28 15:29:44 -0600220 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,
Caleb Palmer626270a2022-02-21 11:05:08 -0600230 "LocationCode": "/proc1/pib/perv25/pauc0/iohs1/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",
Caleb Palmer626270a2022-02-21 11:05:08 -0600260 "RX Target": "/proc0/pib/perv26/pauc1/iohs0/smpgroup0",
261 "TX Target": "/proc1/pib/perv25/pauc0/iohs1/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 Shelleyadda0542023-04-06 16:38:02 -0500297 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS};
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
Zane Shelleyc08f5ff2025-06-26 16:58:39 -0500304 // Special case: The bus callout will add both ends of the bus to the
305 // callout list at LOW priority with no guarding. Generally, this would be
306 // the last thing to be added to the callout list because of the priority.
307 // However, there was a field defect where a higher priority callout of one
308 // of the endpoint was added to the list (with guard action) after the bus
309 // callout. The priority of the callout was updated to match the higher
310 // priority, but the guard action was not updated. So the following are
311 // added to the callout list in a specific order:
312 // - First, one of the endpoints with MED_A and guard.
313 // - Then, the bus callout with LOW and no guard. This should result in
314 // both endpoints in the list: one at MED_A (guard), the other at LOW (no
315 // guard).
316 // - Finally, the other endpoint with MED_A and guard. This should result
317 // in both endpoints in the list with MED_A priority and guard actions.
Zane Shelley4757a7b2021-09-20 22:23:38 -0500318 c1->resolve(sd);
Zane Shelley4757a7b2021-09-20 22:23:38 -0500319 c3->resolve(sd);
Zane Shelleyc08f5ff2025-06-26 16:58:39 -0500320 c2->resolve(sd);
Zane Shelley4757a7b2021-09-20 22:23:38 -0500321
Zane Shelley55e7fec2022-01-28 15:29:44 -0600322 // Verify the subsystem
323 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
Caleb Palmerbc94bde2022-02-18 09:03:37 -0600324 callout::SrcSubsystem::MEMORY_CTLR, callout::Priority::MED_A};
Zane Shelley55e7fec2022-01-28 15:29:44 -0600325 EXPECT_EQ(sd.getSubsys(), subsys);
326
Zane Shelley4757a7b2021-09-20 22:23:38 -0500327 // Callout list
328 j = sd.getCalloutList();
329 s = R"([
330 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500331 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -0600332 "EntityPath": [],
333 "GuardType": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500334 "Guarded": true,
Zane Shelleycb766a42022-01-12 17:50:23 -0600335 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
Zane Shelley4757a7b2021-09-20 22:23:38 -0500336 "Priority": "A"
337 },
338 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500339 "Deconfigured": false,
Zane Shelleycb766a42022-01-12 17:50:23 -0600340 "EntityPath": [],
341 "GuardType": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500342 "Guarded": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500343 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
344 "Priority": "A"
345 },
346 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500347 "Deconfigured": false,
348 "Guarded": false,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500349 "LocationCode": "P0",
350 "Priority": "L"
351 }
352])";
353 EXPECT_EQ(s, j.dump(4));
354
355 // Callout FFDC
356 j = sd.getCalloutFFDC();
357 s = R"([
358 {
359 "Callout Type": "Hardware Callout",
Zane Shelleya00426f2021-11-04 10:50:50 -0500360 "Guard": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500361 "Priority": "medium_group_A",
362 "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0"
363 },
364 {
365 "Bus Type": "OMI_BUS",
Zane Shelleyc08f5ff2025-06-26 16:58:39 -0500366 "Callout Type": "Bus Callout",
367 "Guard": false,
368 "Priority": "low",
Zane Shelley37acb282022-01-10 16:05:22 -0600369 "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
370 "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
Zane Shelley4757a7b2021-09-20 22:23:38 -0500371 },
372 {
373 "Bus Type": "OMI_BUS",
Zane Shelleyc08f5ff2025-06-26 16:58:39 -0500374 "Callout Type": "Connected Callout",
375 "Guard": true,
376 "Priority": "medium_group_A",
Zane Shelley4757a7b2021-09-20 22:23:38 -0500377 "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
378 "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"
379 }
380])";
381 EXPECT_EQ(s, j.dump(4));
382}
383
Zane Shelley96d54862021-09-17 11:16:12 -0500384TEST(Resolution, ClockCallout)
385{
Zane Shelleycb766a42022-01-12 17:50:23 -0600386 pdbg_targets_init(nullptr);
387
Zane Shelley96d54862021-09-17 11:16:12 -0500388 auto c1 = std::make_shared<ClockCalloutResolution>(
389 callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::HIGH, false);
390
Zane Shelleycb766a42022-01-12 17:50:23 -0600391 libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef};
Zane Shelleyadda0542023-04-06 16:38:02 -0500392 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS};
Zane Shelley62adf5c2022-01-18 21:06:50 -0600393 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP,
394 libhei::IsolationData{}};
Zane Shelley96d54862021-09-17 11:16:12 -0500395
396 c1->resolve(sd);
397
Zane Shelley55e7fec2022-01-28 15:29:44 -0600398 // Verify the subsystem
399 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
400 callout::SrcSubsystem::CEC_CLOCKS, callout::Priority::HIGH};
401 EXPECT_EQ(sd.getSubsys(), subsys);
402
Zane Shelley96d54862021-09-17 11:16:12 -0500403 nlohmann::json j{};
404 std::string s{};
405
406 // Callout list
407 j = sd.getCalloutList();
408 s = R"([
409 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500410 "Deconfigured": false,
411 "Guarded": false,
Zane Shelley96d54862021-09-17 11:16:12 -0500412 "LocationCode": "P0",
413 "Priority": "H"
414 }
415])";
416 EXPECT_EQ(s, j.dump(4));
417
418 // Callout FFDC
419 j = sd.getCalloutFFDC();
420 s = R"([
421 {
422 "Callout Type": "Clock Callout",
423 "Clock Type": "OSC_REF_CLOCK_1",
Zane Shelley1eff9452021-11-03 13:59:54 -0500424 "Priority": "high"
Zane Shelley96d54862021-09-17 11:16:12 -0500425 }
426])";
427 EXPECT_EQ(s, j.dump(4));
428}
429
430TEST(Resolution, ProcedureCallout)
431{
Zane Shelleycb766a42022-01-12 17:50:23 -0600432 pdbg_targets_init(nullptr);
433
Zane Shelley96d54862021-09-17 11:16:12 -0500434 auto c1 = std::make_shared<ProcedureCalloutResolution>(
435 callout::Procedure::NEXTLVL, callout::Priority::LOW);
436
Zane Shelleycb766a42022-01-12 17:50:23 -0600437 libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef};
Zane Shelleyadda0542023-04-06 16:38:02 -0500438 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS};
Zane Shelley62adf5c2022-01-18 21:06:50 -0600439 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP,
440 libhei::IsolationData{}};
Zane Shelley96d54862021-09-17 11:16:12 -0500441
442 c1->resolve(sd);
443
Zane Shelley55e7fec2022-01-28 15:29:44 -0600444 // Verify the subsystem
445 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
446 callout::SrcSubsystem::OTHERS, callout::Priority::LOW};
447 EXPECT_EQ(sd.getSubsys(), subsys);
448
Zane Shelley96d54862021-09-17 11:16:12 -0500449 nlohmann::json j{};
450 std::string s{};
451
452 // Callout list
453 j = sd.getCalloutList();
454 s = R"([
455 {
456 "Priority": "L",
Zane Shelley86ccc452021-11-16 13:10:52 -0600457 "Procedure": "next_level_support"
Zane Shelley96d54862021-09-17 11:16:12 -0500458 }
459])";
460 EXPECT_EQ(s, j.dump(4));
461
462 // Callout FFDC
463 j = sd.getCalloutFFDC();
464 s = R"([
465 {
466 "Callout Type": "Procedure Callout",
467 "Priority": "low",
Zane Shelley86ccc452021-11-16 13:10:52 -0600468 "Procedure": "next_level_support"
Zane Shelley96d54862021-09-17 11:16:12 -0500469 }
470])";
471 EXPECT_EQ(s, j.dump(4));
Zane Shelley0b8368c2021-03-18 17:33:41 -0500472}
Zane Shelleya4134772022-01-10 17:22:44 -0600473
474TEST(Resolution, PartCallout)
475{
476 pdbg_targets_init(nullptr);
477
478 auto c1 = std::make_shared<PartCalloutResolution>(callout::PartType::PNOR,
479 callout::Priority::MED);
480
481 libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef};
Zane Shelleyadda0542023-04-06 16:38:02 -0500482 libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHIP_CS};
Zane Shelley62adf5c2022-01-18 21:06:50 -0600483 ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP,
484 libhei::IsolationData{}};
Zane Shelleya4134772022-01-10 17:22:44 -0600485
486 c1->resolve(sd);
487
Zane Shelley55e7fec2022-01-28 15:29:44 -0600488 // Verify the subsystem
489 std::pair<callout::SrcSubsystem, callout::Priority> subsys = {
490 callout::SrcSubsystem::CEC_HARDWARE, callout::Priority::MED};
491 EXPECT_EQ(sd.getSubsys(), subsys);
492
Zane Shelleya4134772022-01-10 17:22:44 -0600493 nlohmann::json j{};
494 std::string s{};
495
496 // Callout list
497 j = sd.getCalloutList();
498 s = R"([
499 {
500 "Deconfigured": false,
501 "Guarded": false,
502 "LocationCode": "/bmc0",
503 "Priority": "M"
504 }
505])";
506 EXPECT_EQ(s, j.dump(4));
507
508 // Callout FFDC
509 j = sd.getCalloutFFDC();
510 s = R"([
511 {
512 "Callout Type": "Part Callout",
513 "Part Type": "PNOR",
514 "Priority": "medium"
515 }
516])";
517 EXPECT_EQ(s, j.dump(4));
518}