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 | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 238 | "RX Target": "/proc0/pib/perv24/pauc0/iohs0/smpgroup0", |
| 239 | "TX Target": "/proc0/pib/perv24/pauc0/iohs0/smpgroup0" |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 240 | }, |
| 241 | { |
| 242 | "Bus Type": "OMI_BUS", |
| 243 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 244 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 245 | "Priority": "medium_group_B", |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 246 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 247 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 248 | }, |
| 249 | { |
| 250 | "Bus Type": "OMI_BUS", |
| 251 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 252 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 253 | "Priority": "medium_group_C", |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 254 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 255 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 256 | } |
| 257 | ])"; |
| 258 | EXPECT_EQ(s, j.dump(4)); |
| 259 | } |
| 260 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 261 | TEST(Resolution, BusCallout) |
| 262 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 263 | pdbg_targets_init(nullptr); |
| 264 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 265 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 266 | omi_str, callout::Priority::MED_A, true); |
| 267 | |
| 268 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 269 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_A, true); |
| 270 | |
| 271 | auto c3 = std::make_shared<BusCalloutResolution>( |
| 272 | callout::BusType::OMI_BUS, omi_str, callout::Priority::LOW, false); |
| 273 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 274 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 275 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 276 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 277 | |
| 278 | nlohmann::json j{}; |
| 279 | std::string s{}; |
| 280 | |
| 281 | c1->resolve(sd); |
| 282 | c2->resolve(sd); |
| 283 | c3->resolve(sd); |
| 284 | |
| 285 | // Callout list |
| 286 | j = sd.getCalloutList(); |
| 287 | s = R"([ |
| 288 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 289 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 290 | "EntityPath": [], |
| 291 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 292 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 293 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 294 | "Priority": "A" |
| 295 | }, |
| 296 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 297 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 298 | "EntityPath": [], |
| 299 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 300 | "Guarded": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 301 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 302 | "Priority": "A" |
| 303 | }, |
| 304 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 305 | "Deconfigured": false, |
| 306 | "Guarded": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 307 | "LocationCode": "P0", |
| 308 | "Priority": "L" |
| 309 | } |
| 310 | ])"; |
| 311 | EXPECT_EQ(s, j.dump(4)); |
| 312 | |
| 313 | // Callout FFDC |
| 314 | j = sd.getCalloutFFDC(); |
| 315 | s = R"([ |
| 316 | { |
| 317 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 318 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 319 | "Priority": "medium_group_A", |
| 320 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 321 | }, |
| 322 | { |
| 323 | "Bus Type": "OMI_BUS", |
| 324 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 325 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 326 | "Priority": "medium_group_A", |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 327 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 328 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 329 | }, |
| 330 | { |
| 331 | "Bus Type": "OMI_BUS", |
| 332 | "Callout Type": "Bus Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 333 | "Guard": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 334 | "Priority": "low", |
| 335 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 336 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 337 | } |
| 338 | ])"; |
| 339 | EXPECT_EQ(s, j.dump(4)); |
| 340 | } |
| 341 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 342 | TEST(Resolution, ClockCallout) |
| 343 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 344 | pdbg_targets_init(nullptr); |
| 345 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 346 | auto c1 = std::make_shared<ClockCalloutResolution>( |
| 347 | callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::HIGH, false); |
| 348 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 349 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 350 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 351 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 352 | |
| 353 | c1->resolve(sd); |
| 354 | |
| 355 | nlohmann::json j{}; |
| 356 | std::string s{}; |
| 357 | |
| 358 | // Callout list |
| 359 | j = sd.getCalloutList(); |
| 360 | s = R"([ |
| 361 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 362 | "Deconfigured": false, |
| 363 | "Guarded": false, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 364 | "LocationCode": "P0", |
| 365 | "Priority": "H" |
| 366 | } |
| 367 | ])"; |
| 368 | EXPECT_EQ(s, j.dump(4)); |
| 369 | |
| 370 | // Callout FFDC |
| 371 | j = sd.getCalloutFFDC(); |
| 372 | s = R"([ |
| 373 | { |
| 374 | "Callout Type": "Clock Callout", |
| 375 | "Clock Type": "OSC_REF_CLOCK_1", |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 376 | "Priority": "high" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 377 | } |
| 378 | ])"; |
| 379 | EXPECT_EQ(s, j.dump(4)); |
| 380 | } |
| 381 | |
| 382 | TEST(Resolution, ProcedureCallout) |
| 383 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 384 | pdbg_targets_init(nullptr); |
| 385 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 386 | auto c1 = std::make_shared<ProcedureCalloutResolution>( |
| 387 | callout::Procedure::NEXTLVL, callout::Priority::LOW); |
| 388 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 389 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 390 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 391 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 392 | |
| 393 | c1->resolve(sd); |
| 394 | |
| 395 | nlohmann::json j{}; |
| 396 | std::string s{}; |
| 397 | |
| 398 | // Callout list |
| 399 | j = sd.getCalloutList(); |
| 400 | s = R"([ |
| 401 | { |
| 402 | "Priority": "L", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 403 | "Procedure": "next_level_support" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 404 | } |
| 405 | ])"; |
| 406 | EXPECT_EQ(s, j.dump(4)); |
| 407 | |
| 408 | // Callout FFDC |
| 409 | j = sd.getCalloutFFDC(); |
| 410 | s = R"([ |
| 411 | { |
| 412 | "Callout Type": "Procedure Callout", |
| 413 | "Priority": "low", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 414 | "Procedure": "next_level_support" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 415 | } |
| 416 | ])"; |
| 417 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 418 | } |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 419 | |
| 420 | TEST(Resolution, PartCallout) |
| 421 | { |
| 422 | pdbg_targets_init(nullptr); |
| 423 | |
| 424 | auto c1 = std::make_shared<PartCalloutResolution>(callout::PartType::PNOR, |
| 425 | callout::Priority::MED); |
| 426 | |
| 427 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
| 428 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
| 429 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
| 430 | |
| 431 | c1->resolve(sd); |
| 432 | |
| 433 | nlohmann::json j{}; |
| 434 | std::string s{}; |
| 435 | |
| 436 | // Callout list |
| 437 | j = sd.getCalloutList(); |
| 438 | s = R"([ |
| 439 | { |
| 440 | "Deconfigured": false, |
| 441 | "Guarded": false, |
| 442 | "LocationCode": "/bmc0", |
| 443 | "Priority": "M" |
| 444 | } |
| 445 | ])"; |
| 446 | EXPECT_EQ(s, j.dump(4)); |
| 447 | |
| 448 | // Callout FFDC |
| 449 | j = sd.getCalloutFFDC(); |
| 450 | s = R"([ |
| 451 | { |
| 452 | "Callout Type": "Part Callout", |
| 453 | "Part Type": "PNOR", |
| 454 | "Priority": "medium" |
| 455 | } |
| 456 | ])"; |
| 457 | EXPECT_EQ(s, j.dump(4)); |
| 458 | } |