Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 3 | #include <analyzer/analyzer_main.hpp> |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 4 | #include <analyzer/resolution.hpp> |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 5 | #include <util/pdbg.hpp> |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 6 | #include <util/trace.hpp> |
| 7 | |
| 8 | #include <regex> |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 9 | |
| 10 | #include "gtest/gtest.h" |
| 11 | |
| 12 | // Chip string |
| 13 | constexpr auto chip_str = "/proc0"; |
| 14 | |
| 15 | // Unit paths |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 16 | constexpr auto proc_str = ""; |
| 17 | constexpr auto iolink_str = "pib/perv24/pauc0/iohs0/smpgroup0"; |
| 18 | constexpr auto omi_str = "pib/perv12/mc0/mi0/mcc0/omi0"; |
| 19 | constexpr auto ocmb_str = "pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"; |
| 20 | constexpr auto core_str = "pib/perv39/eq7/fc1/core1"; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 21 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 22 | using namespace analyzer; |
| 23 | |
| 24 | TEST(Resolution, TestSet1) |
| 25 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 26 | pdbg_targets_init(nullptr); |
| 27 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 28 | // Create a few resolutions |
| 29 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 30 | proc_str, callout::Priority::HIGH, false); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 31 | |
| 32 | auto c2 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 33 | omi_str, callout::Priority::MED_A, true); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 34 | |
| 35 | auto c3 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 36 | core_str, callout::Priority::MED, true); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 37 | |
| 38 | auto c4 = std::make_shared<ProcedureCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 39 | callout::Procedure::NEXTLVL, callout::Priority::LOW); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 40 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 41 | auto c5 = std::make_shared<ClockCalloutResolution>( |
| 42 | callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::LOW, false); |
| 43 | |
| 44 | // l1 = (c1, c2, c5) |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 45 | auto l1 = std::make_shared<ResolutionList>(); |
| 46 | l1->push(c1); |
| 47 | l1->push(c2); |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 48 | l1->push(c5); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 49 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 50 | // l2 = (c4, c3, c1, c2, c5) |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 51 | auto l2 = std::make_shared<ResolutionList>(); |
| 52 | l2->push(c4); |
| 53 | l2->push(c3); |
| 54 | l2->push(l1); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 55 | |
| 56 | // Get some ServiceData objects |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 57 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 58 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 59 | ServiceData sd1{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
| 60 | ServiceData sd2{sig, AnalysisType::TERMINATE_IMMEDIATE}; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 61 | |
| 62 | // Resolve |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 63 | l1->resolve(sd1); |
| 64 | l2->resolve(sd2); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 65 | |
| 66 | // Start verifying |
| 67 | nlohmann::json j{}; |
| 68 | std::string s{}; |
| 69 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 70 | j = sd1.getCalloutList(); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 71 | s = R"([ |
| 72 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 73 | "Deconfigured": false, |
| 74 | "Guarded": false, |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 75 | "LocationCode": "/proc0", |
| 76 | "Priority": "H" |
| 77 | }, |
| 78 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 79 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 80 | "EntityPath": [], |
| 81 | "GuardType": "GARD_Unrecoverable", |
| 82 | "Guarded": true, |
| 83 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 84 | "Priority": "A" |
| 85 | }, |
| 86 | { |
| 87 | "Deconfigured": false, |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 88 | "Guarded": false, |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 89 | "LocationCode": "P0", |
| 90 | "Priority": "L" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 91 | } |
| 92 | ])"; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 93 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 94 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 95 | j = sd2.getCalloutList(); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 96 | s = R"([ |
| 97 | { |
| 98 | "Priority": "L", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 99 | "Procedure": "next_level_support" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 100 | }, |
| 101 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 102 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 103 | "EntityPath": [], |
| 104 | "GuardType": "GARD_Predictive", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 105 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 106 | "LocationCode": "/proc0/pib/perv39/eq7/fc1/core1", |
| 107 | "Priority": "M" |
| 108 | }, |
| 109 | { |
| 110 | "Deconfigured": false, |
| 111 | "Guarded": false, |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 112 | "LocationCode": "/proc0", |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 113 | "Priority": "H" |
| 114 | }, |
| 115 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 116 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 117 | "EntityPath": [], |
| 118 | "GuardType": "GARD_Predictive", |
| 119 | "Guarded": true, |
| 120 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 121 | "Priority": "A" |
| 122 | }, |
| 123 | { |
| 124 | "Deconfigured": false, |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 125 | "Guarded": false, |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 126 | "LocationCode": "P0", |
| 127 | "Priority": "L" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 128 | } |
| 129 | ])"; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 130 | EXPECT_EQ(s, j.dump(4)); |
| 131 | } |
| 132 | |
| 133 | TEST(Resolution, HardwareCallout) |
| 134 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 135 | pdbg_targets_init(nullptr); |
| 136 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 137 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 138 | omi_str, callout::Priority::MED_A, true); |
| 139 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 140 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 141 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 142 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 143 | |
| 144 | c1->resolve(sd); |
| 145 | |
| 146 | nlohmann::json j{}; |
| 147 | std::string s{}; |
| 148 | |
| 149 | // Callout list |
| 150 | j = sd.getCalloutList(); |
| 151 | s = R"([ |
| 152 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 153 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 154 | "EntityPath": [], |
| 155 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 156 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 157 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 158 | "Priority": "A" |
| 159 | } |
| 160 | ])"; |
| 161 | EXPECT_EQ(s, j.dump(4)); |
| 162 | |
| 163 | // Callout FFDC |
| 164 | j = sd.getCalloutFFDC(); |
| 165 | s = R"([ |
| 166 | { |
| 167 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 168 | "Guard": true, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 169 | "Priority": "medium_group_A", |
| 170 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 171 | } |
| 172 | ])"; |
| 173 | EXPECT_EQ(s, j.dump(4)); |
| 174 | } |
| 175 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 176 | TEST(Resolution, ConnectedCallout) |
| 177 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 178 | pdbg_targets_init(nullptr); |
| 179 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 180 | auto c1 = std::make_shared<ConnectedCalloutResolution>( |
| 181 | callout::BusType::SMP_BUS, iolink_str, callout::Priority::MED_A, true); |
| 182 | |
| 183 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 184 | callout::BusType::OMI_BUS, ocmb_str, callout::Priority::MED_B, true); |
| 185 | |
| 186 | auto c3 = std::make_shared<ConnectedCalloutResolution>( |
| 187 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_C, true); |
| 188 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 189 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 190 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 191 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 192 | |
| 193 | nlohmann::json j{}; |
| 194 | std::string s{}; |
| 195 | |
| 196 | c1->resolve(sd); |
| 197 | c2->resolve(sd); |
| 198 | c3->resolve(sd); |
| 199 | |
| 200 | // Callout list |
| 201 | j = sd.getCalloutList(); |
| 202 | s = R"([ |
| 203 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 204 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 205 | "EntityPath": [], |
| 206 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 207 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 208 | "LocationCode": "/proc0/pib/perv24/pauc0/iohs0/smpgroup0", |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 209 | "Priority": "A" |
| 210 | }, |
| 211 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 212 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 213 | "EntityPath": [], |
| 214 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 215 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 216 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 217 | "Priority": "B" |
| 218 | }, |
| 219 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 220 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 221 | "EntityPath": [], |
| 222 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 223 | "Guarded": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 224 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 225 | "Priority": "C" |
| 226 | } |
| 227 | ])"; |
| 228 | EXPECT_EQ(s, j.dump(4)); |
| 229 | |
| 230 | // Callout FFDC |
| 231 | j = sd.getCalloutFFDC(); |
| 232 | s = R"([ |
| 233 | { |
| 234 | "Bus Type": "SMP_BUS", |
| 235 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 236 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 237 | "Priority": "medium_group_A", |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 238 | "Target": "/proc0/pib/perv24/pauc0/iohs0/smpgroup0" |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 239 | }, |
| 240 | { |
| 241 | "Bus Type": "OMI_BUS", |
| 242 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 243 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 244 | "Priority": "medium_group_B", |
| 245 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 246 | }, |
| 247 | { |
| 248 | "Bus Type": "OMI_BUS", |
| 249 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 250 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 251 | "Priority": "medium_group_C", |
| 252 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 253 | } |
| 254 | ])"; |
| 255 | EXPECT_EQ(s, j.dump(4)); |
| 256 | } |
| 257 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 258 | TEST(Resolution, BusCallout) |
| 259 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 260 | pdbg_targets_init(nullptr); |
| 261 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 262 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 263 | omi_str, callout::Priority::MED_A, true); |
| 264 | |
| 265 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 266 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_A, true); |
| 267 | |
| 268 | auto c3 = std::make_shared<BusCalloutResolution>( |
| 269 | callout::BusType::OMI_BUS, omi_str, callout::Priority::LOW, false); |
| 270 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 271 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 272 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 273 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 274 | |
| 275 | nlohmann::json j{}; |
| 276 | std::string s{}; |
| 277 | |
| 278 | c1->resolve(sd); |
| 279 | c2->resolve(sd); |
| 280 | c3->resolve(sd); |
| 281 | |
| 282 | // Callout list |
| 283 | j = sd.getCalloutList(); |
| 284 | s = R"([ |
| 285 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 286 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 287 | "EntityPath": [], |
| 288 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 289 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 290 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 291 | "Priority": "A" |
| 292 | }, |
| 293 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 294 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 295 | "EntityPath": [], |
| 296 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 297 | "Guarded": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 298 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 299 | "Priority": "A" |
| 300 | }, |
| 301 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 302 | "Deconfigured": false, |
| 303 | "Guarded": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 304 | "LocationCode": "P0", |
| 305 | "Priority": "L" |
| 306 | } |
| 307 | ])"; |
| 308 | EXPECT_EQ(s, j.dump(4)); |
| 309 | |
| 310 | // Callout FFDC |
| 311 | j = sd.getCalloutFFDC(); |
| 312 | s = R"([ |
| 313 | { |
| 314 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 315 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 316 | "Priority": "medium_group_A", |
| 317 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 318 | }, |
| 319 | { |
| 320 | "Bus Type": "OMI_BUS", |
| 321 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 322 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 323 | "Priority": "medium_group_A", |
| 324 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 325 | }, |
| 326 | { |
| 327 | "Bus Type": "OMI_BUS", |
| 328 | "Callout Type": "Bus Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 329 | "Guard": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 330 | "Priority": "low", |
| 331 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 332 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 333 | } |
| 334 | ])"; |
| 335 | EXPECT_EQ(s, j.dump(4)); |
| 336 | } |
| 337 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 338 | TEST(Resolution, ClockCallout) |
| 339 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 340 | pdbg_targets_init(nullptr); |
| 341 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 342 | auto c1 = std::make_shared<ClockCalloutResolution>( |
| 343 | callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::HIGH, false); |
| 344 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 345 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 346 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 347 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 348 | |
| 349 | c1->resolve(sd); |
| 350 | |
| 351 | nlohmann::json j{}; |
| 352 | std::string s{}; |
| 353 | |
| 354 | // Callout list |
| 355 | j = sd.getCalloutList(); |
| 356 | s = R"([ |
| 357 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 358 | "Deconfigured": false, |
| 359 | "Guarded": false, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 360 | "LocationCode": "P0", |
| 361 | "Priority": "H" |
| 362 | } |
| 363 | ])"; |
| 364 | EXPECT_EQ(s, j.dump(4)); |
| 365 | |
| 366 | // Callout FFDC |
| 367 | j = sd.getCalloutFFDC(); |
| 368 | s = R"([ |
| 369 | { |
| 370 | "Callout Type": "Clock Callout", |
| 371 | "Clock Type": "OSC_REF_CLOCK_1", |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 372 | "Priority": "high" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 373 | } |
| 374 | ])"; |
| 375 | EXPECT_EQ(s, j.dump(4)); |
| 376 | } |
| 377 | |
| 378 | TEST(Resolution, ProcedureCallout) |
| 379 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 380 | pdbg_targets_init(nullptr); |
| 381 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 382 | auto c1 = std::make_shared<ProcedureCalloutResolution>( |
| 383 | callout::Procedure::NEXTLVL, callout::Priority::LOW); |
| 384 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 385 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 386 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 387 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 388 | |
| 389 | c1->resolve(sd); |
| 390 | |
| 391 | nlohmann::json j{}; |
| 392 | std::string s{}; |
| 393 | |
| 394 | // Callout list |
| 395 | j = sd.getCalloutList(); |
| 396 | s = R"([ |
| 397 | { |
| 398 | "Priority": "L", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 399 | "Procedure": "next_level_support" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 400 | } |
| 401 | ])"; |
| 402 | EXPECT_EQ(s, j.dump(4)); |
| 403 | |
| 404 | // Callout FFDC |
| 405 | j = sd.getCalloutFFDC(); |
| 406 | s = R"([ |
| 407 | { |
| 408 | "Callout Type": "Procedure Callout", |
| 409 | "Priority": "low", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 410 | "Procedure": "next_level_support" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 411 | } |
| 412 | ])"; |
| 413 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 414 | } |