Zane Shelley | d195b71 | 2022-01-26 13:26:34 -0600 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | |
| 3 | #include <analyzer/plugins/plugin.hpp> |
| 4 | #include <hei_util.hpp> |
| 5 | #include <util/pdbg.hpp> |
| 6 | #include <util/trace.hpp> |
| 7 | |
| 8 | #include "gtest/gtest.h" |
| 9 | |
| 10 | using namespace analyzer; |
| 11 | |
| 12 | static const auto nodeId = |
| 13 | static_cast<libhei::NodeId_t>(libhei::hash<libhei::NodeId_t>("TOD_ERROR")); |
| 14 | |
| 15 | TEST(TodStepCheckFault, TestSet1) |
| 16 | { |
| 17 | pdbg_targets_init(nullptr); |
| 18 | |
| 19 | libhei::Chip chip1{util::pdbg::getTrgt("/proc1"), P10_20}; |
| 20 | |
| 21 | // TOD_ERROR(0)[16] |
| 22 | libhei::Signature sig{chip1, nodeId, 0, 16, libhei::ATTN_TYPE_CHECKSTOP}; |
| 23 | |
| 24 | auto plugin = |
| 25 | PluginMap::getSingleton().get(chip1.getType(), "tod_step_check_fault"); |
| 26 | |
| 27 | libhei::IsolationData isoData{}; |
| 28 | isoData.addSignature(sig); |
| 29 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, isoData}; |
| 30 | |
| 31 | // Call the plugin. |
| 32 | plugin(1, chip1, sd); |
| 33 | |
| 34 | nlohmann::json j{}; |
| 35 | std::string s{}; |
| 36 | |
| 37 | // Callout list |
| 38 | j = sd.getCalloutList(); |
| 39 | s = R"([ |
| 40 | { |
| 41 | "Deconfigured": false, |
| 42 | "Guarded": false, |
| 43 | "LocationCode": "P0", |
| 44 | "Priority": "M" |
| 45 | }, |
| 46 | { |
| 47 | "Deconfigured": false, |
| 48 | "Guarded": false, |
| 49 | "LocationCode": "/proc1", |
| 50 | "Priority": "M" |
| 51 | } |
| 52 | ])"; |
| 53 | EXPECT_EQ(s, j.dump(4)); |
| 54 | |
| 55 | // Callout FFDC |
| 56 | j = sd.getCalloutFFDC(); |
| 57 | s = R"([ |
| 58 | { |
| 59 | "Callout Type": "Clock Callout", |
| 60 | "Clock Type": "TOD_CLOCK", |
| 61 | "Priority": "medium" |
| 62 | }, |
| 63 | { |
| 64 | "Callout Type": "Hardware Callout", |
| 65 | "Guard": false, |
| 66 | "Priority": "medium", |
| 67 | "Target": "/proc1" |
| 68 | } |
| 69 | ])"; |
| 70 | EXPECT_EQ(s, j.dump(4)); |
| 71 | } |