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 | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 59 | ServiceData sd1{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 60 | libhei::IsolationData{}}; |
| 61 | ServiceData sd2{sig, AnalysisType::TERMINATE_IMMEDIATE, |
| 62 | libhei::IsolationData{}}; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 63 | |
| 64 | // Resolve |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 65 | l1->resolve(sd1); |
| 66 | l2->resolve(sd2); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 67 | |
| 68 | // Start verifying |
| 69 | nlohmann::json j{}; |
| 70 | std::string s{}; |
| 71 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 72 | j = sd1.getCalloutList(); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 73 | s = R"([ |
| 74 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 75 | "Deconfigured": false, |
| 76 | "Guarded": false, |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 77 | "LocationCode": "/proc0", |
| 78 | "Priority": "H" |
| 79 | }, |
| 80 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 81 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 82 | "EntityPath": [], |
| 83 | "GuardType": "GARD_Unrecoverable", |
| 84 | "Guarded": true, |
| 85 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 86 | "Priority": "A" |
| 87 | }, |
| 88 | { |
| 89 | "Deconfigured": false, |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 90 | "Guarded": false, |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 91 | "LocationCode": "P0", |
| 92 | "Priority": "L" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 93 | } |
| 94 | ])"; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 95 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 96 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 97 | j = sd2.getCalloutList(); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 98 | s = R"([ |
| 99 | { |
| 100 | "Priority": "L", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 101 | "Procedure": "next_level_support" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 102 | }, |
| 103 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 104 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 105 | "EntityPath": [], |
| 106 | "GuardType": "GARD_Predictive", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 107 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 108 | "LocationCode": "/proc0/pib/perv39/eq7/fc1/core1", |
| 109 | "Priority": "M" |
| 110 | }, |
| 111 | { |
| 112 | "Deconfigured": false, |
| 113 | "Guarded": false, |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 114 | "LocationCode": "/proc0", |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 115 | "Priority": "H" |
| 116 | }, |
| 117 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 118 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 119 | "EntityPath": [], |
| 120 | "GuardType": "GARD_Predictive", |
| 121 | "Guarded": true, |
| 122 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 123 | "Priority": "A" |
| 124 | }, |
| 125 | { |
| 126 | "Deconfigured": false, |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 127 | "Guarded": false, |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 128 | "LocationCode": "P0", |
| 129 | "Priority": "L" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 130 | } |
| 131 | ])"; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 132 | EXPECT_EQ(s, j.dump(4)); |
| 133 | } |
| 134 | |
| 135 | TEST(Resolution, HardwareCallout) |
| 136 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 137 | pdbg_targets_init(nullptr); |
| 138 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 139 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 140 | omi_str, callout::Priority::MED_A, true); |
| 141 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 142 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 143 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 144 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 145 | libhei::IsolationData{}}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 146 | |
| 147 | c1->resolve(sd); |
| 148 | |
| 149 | nlohmann::json j{}; |
| 150 | std::string s{}; |
| 151 | |
| 152 | // Callout list |
| 153 | j = sd.getCalloutList(); |
| 154 | s = R"([ |
| 155 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 156 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 157 | "EntityPath": [], |
| 158 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 159 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 160 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 161 | "Priority": "A" |
| 162 | } |
| 163 | ])"; |
| 164 | EXPECT_EQ(s, j.dump(4)); |
| 165 | |
| 166 | // Callout FFDC |
| 167 | j = sd.getCalloutFFDC(); |
| 168 | s = R"([ |
| 169 | { |
| 170 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 171 | "Guard": true, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 172 | "Priority": "medium_group_A", |
| 173 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 174 | } |
| 175 | ])"; |
| 176 | EXPECT_EQ(s, j.dump(4)); |
| 177 | } |
| 178 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 179 | TEST(Resolution, ConnectedCallout) |
| 180 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 181 | pdbg_targets_init(nullptr); |
| 182 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 183 | auto c1 = std::make_shared<ConnectedCalloutResolution>( |
| 184 | callout::BusType::SMP_BUS, iolink_str, callout::Priority::MED_A, true); |
| 185 | |
| 186 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 187 | callout::BusType::OMI_BUS, ocmb_str, callout::Priority::MED_B, true); |
| 188 | |
| 189 | auto c3 = std::make_shared<ConnectedCalloutResolution>( |
| 190 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_C, true); |
| 191 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 192 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 193 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 194 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 195 | libhei::IsolationData{}}; |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 196 | |
| 197 | nlohmann::json j{}; |
| 198 | std::string s{}; |
| 199 | |
| 200 | c1->resolve(sd); |
| 201 | c2->resolve(sd); |
| 202 | c3->resolve(sd); |
| 203 | |
| 204 | // Callout list |
| 205 | j = sd.getCalloutList(); |
| 206 | s = R"([ |
| 207 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 208 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 209 | "EntityPath": [], |
| 210 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 211 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 212 | "LocationCode": "/proc0/pib/perv24/pauc0/iohs0/smpgroup0", |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 213 | "Priority": "A" |
| 214 | }, |
| 215 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 216 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 217 | "EntityPath": [], |
| 218 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 219 | "Guarded": true, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 220 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 221 | "Priority": "B" |
| 222 | }, |
| 223 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 224 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 225 | "EntityPath": [], |
| 226 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 227 | "Guarded": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 228 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 229 | "Priority": "C" |
| 230 | } |
| 231 | ])"; |
| 232 | EXPECT_EQ(s, j.dump(4)); |
| 233 | |
| 234 | // Callout FFDC |
| 235 | j = sd.getCalloutFFDC(); |
| 236 | s = R"([ |
| 237 | { |
| 238 | "Bus Type": "SMP_BUS", |
| 239 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 240 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 241 | "Priority": "medium_group_A", |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 242 | "RX Target": "/proc0/pib/perv24/pauc0/iohs0/smpgroup0", |
| 243 | "TX Target": "/proc0/pib/perv24/pauc0/iohs0/smpgroup0" |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 244 | }, |
| 245 | { |
| 246 | "Bus Type": "OMI_BUS", |
| 247 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 248 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 249 | "Priority": "medium_group_B", |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 250 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 251 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 252 | }, |
| 253 | { |
| 254 | "Bus Type": "OMI_BUS", |
| 255 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 256 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 257 | "Priority": "medium_group_C", |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 258 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 259 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 260 | } |
| 261 | ])"; |
| 262 | EXPECT_EQ(s, j.dump(4)); |
| 263 | } |
| 264 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 265 | TEST(Resolution, BusCallout) |
| 266 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 267 | pdbg_targets_init(nullptr); |
| 268 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 269 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 270 | omi_str, callout::Priority::MED_A, true); |
| 271 | |
| 272 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 273 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_A, true); |
| 274 | |
| 275 | auto c3 = std::make_shared<BusCalloutResolution>( |
| 276 | callout::BusType::OMI_BUS, omi_str, callout::Priority::LOW, false); |
| 277 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 278 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 279 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 280 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 281 | libhei::IsolationData{}}; |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 282 | |
| 283 | nlohmann::json j{}; |
| 284 | std::string s{}; |
| 285 | |
| 286 | c1->resolve(sd); |
| 287 | c2->resolve(sd); |
| 288 | c3->resolve(sd); |
| 289 | |
| 290 | // Callout list |
| 291 | j = sd.getCalloutList(); |
| 292 | s = R"([ |
| 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 | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 298 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 299 | "Priority": "A" |
| 300 | }, |
| 301 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 302 | "Deconfigured": false, |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 303 | "EntityPath": [], |
| 304 | "GuardType": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 305 | "Guarded": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 306 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 307 | "Priority": "A" |
| 308 | }, |
| 309 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 310 | "Deconfigured": false, |
| 311 | "Guarded": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 312 | "LocationCode": "P0", |
| 313 | "Priority": "L" |
| 314 | } |
| 315 | ])"; |
| 316 | EXPECT_EQ(s, j.dump(4)); |
| 317 | |
| 318 | // Callout FFDC |
| 319 | j = sd.getCalloutFFDC(); |
| 320 | s = R"([ |
| 321 | { |
| 322 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 323 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 324 | "Priority": "medium_group_A", |
| 325 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 326 | }, |
| 327 | { |
| 328 | "Bus Type": "OMI_BUS", |
| 329 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 330 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 331 | "Priority": "medium_group_A", |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 332 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 333 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 334 | }, |
| 335 | { |
| 336 | "Bus Type": "OMI_BUS", |
| 337 | "Callout Type": "Bus Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 338 | "Guard": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 339 | "Priority": "low", |
| 340 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 341 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 342 | } |
| 343 | ])"; |
| 344 | EXPECT_EQ(s, j.dump(4)); |
| 345 | } |
| 346 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 347 | TEST(Resolution, ClockCallout) |
| 348 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 349 | pdbg_targets_init(nullptr); |
| 350 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 351 | auto c1 = std::make_shared<ClockCalloutResolution>( |
| 352 | callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::HIGH, false); |
| 353 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 354 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 355 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 356 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 357 | libhei::IsolationData{}}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 358 | |
| 359 | c1->resolve(sd); |
| 360 | |
| 361 | nlohmann::json j{}; |
| 362 | std::string s{}; |
| 363 | |
| 364 | // Callout list |
| 365 | j = sd.getCalloutList(); |
| 366 | s = R"([ |
| 367 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 368 | "Deconfigured": false, |
| 369 | "Guarded": false, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 370 | "LocationCode": "P0", |
| 371 | "Priority": "H" |
| 372 | } |
| 373 | ])"; |
| 374 | EXPECT_EQ(s, j.dump(4)); |
| 375 | |
| 376 | // Callout FFDC |
| 377 | j = sd.getCalloutFFDC(); |
| 378 | s = R"([ |
| 379 | { |
| 380 | "Callout Type": "Clock Callout", |
| 381 | "Clock Type": "OSC_REF_CLOCK_1", |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 382 | "Priority": "high" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 383 | } |
| 384 | ])"; |
| 385 | EXPECT_EQ(s, j.dump(4)); |
| 386 | } |
| 387 | |
| 388 | TEST(Resolution, ProcedureCallout) |
| 389 | { |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 390 | pdbg_targets_init(nullptr); |
| 391 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 392 | auto c1 = std::make_shared<ProcedureCalloutResolution>( |
| 393 | callout::Procedure::NEXTLVL, callout::Priority::LOW); |
| 394 | |
Zane Shelley | cb766a4 | 2022-01-12 17:50:23 -0600 | [diff] [blame] | 395 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 396 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 397 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 398 | libhei::IsolationData{}}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 399 | |
| 400 | c1->resolve(sd); |
| 401 | |
| 402 | nlohmann::json j{}; |
| 403 | std::string s{}; |
| 404 | |
| 405 | // Callout list |
| 406 | j = sd.getCalloutList(); |
| 407 | s = R"([ |
| 408 | { |
| 409 | "Priority": "L", |
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)); |
| 414 | |
| 415 | // Callout FFDC |
| 416 | j = sd.getCalloutFFDC(); |
| 417 | s = R"([ |
| 418 | { |
| 419 | "Callout Type": "Procedure Callout", |
| 420 | "Priority": "low", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 421 | "Procedure": "next_level_support" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 422 | } |
| 423 | ])"; |
| 424 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 425 | } |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 426 | |
| 427 | TEST(Resolution, PartCallout) |
| 428 | { |
| 429 | pdbg_targets_init(nullptr); |
| 430 | |
| 431 | auto c1 = std::make_shared<PartCalloutResolution>(callout::PartType::PNOR, |
| 432 | callout::Priority::MED); |
| 433 | |
| 434 | libhei::Chip chip{util::pdbg::getTrgt(chip_str), 0xdeadbeef}; |
| 435 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 62adf5c | 2022-01-18 21:06:50 -0600 | [diff] [blame] | 436 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, |
| 437 | libhei::IsolationData{}}; |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 438 | |
| 439 | c1->resolve(sd); |
| 440 | |
| 441 | nlohmann::json j{}; |
| 442 | std::string s{}; |
| 443 | |
| 444 | // Callout list |
| 445 | j = sd.getCalloutList(); |
| 446 | s = R"([ |
| 447 | { |
| 448 | "Deconfigured": false, |
| 449 | "Guarded": false, |
| 450 | "LocationCode": "/bmc0", |
| 451 | "Priority": "M" |
| 452 | } |
| 453 | ])"; |
| 454 | EXPECT_EQ(s, j.dump(4)); |
| 455 | |
| 456 | // Callout FFDC |
| 457 | j = sd.getCalloutFFDC(); |
| 458 | s = R"([ |
| 459 | { |
| 460 | "Callout Type": "Part Callout", |
| 461 | "Part Type": "PNOR", |
| 462 | "Priority": "medium" |
| 463 | } |
| 464 | ])"; |
| 465 | EXPECT_EQ(s, j.dump(4)); |
| 466 | } |