Add support for TOD clock callouts

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I42726f6d1b036120fcfe217e6dd47be8dd6d927b
diff --git a/test/meson.build b/test/meson.build
index 662274d..c484b2e 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -31,6 +31,8 @@
     command : [ find_program('dtc'), '-I', 'dts', '-O', 'dtb',
                 '-o', '@OUTPUT@', '@INPUT@' ])
 
+pdbg_env = 'PDBG_DTB=' + pdbg_test_dtb.full_path()
+
 # end2end code exerciser for experiment and testing
 subdir('end2end')
 
@@ -70,5 +72,29 @@
                     dependencies : [ libhei_dep, libpdbg_dep, gtest_dep ],
                     cpp_args : test_arg,
                     include_directories : incdir),
-         env : [ 'PDBG_DTB=' + pdbg_test_dtb.full_path() ])
+         env : pdbg_env)
 endforeach
+
+################################################################################
+
+tc = 'test-tod-step-check-fault'
+
+src = [
+  files(
+    tc + '.cpp',
+    '../analyzer/plugins/p10-tod-plugins.cpp',
+    '../analyzer/service_data.cpp',
+    '../util/pdbg.cpp',
+  ),
+  pdbg_test_dtb,
+]
+
+dep = [ libhei_dep, libpdbg_dep, gtest_dep ]
+
+var = [ pdbg_env ]
+
+exe = executable(tc.underscorify(), src, dependencies: dep,
+                 cpp_args: test_arg, include_directories: incdir)
+
+test(tc, exe, env: var)
+
diff --git a/test/test-tod-step-check-fault.cpp b/test/test-tod-step-check-fault.cpp
new file mode 100644
index 0000000..d27b72b
--- /dev/null
+++ b/test/test-tod-step-check-fault.cpp
@@ -0,0 +1,71 @@
+#include <stdio.h>
+
+#include <analyzer/plugins/plugin.hpp>
+#include <hei_util.hpp>
+#include <util/pdbg.hpp>
+#include <util/trace.hpp>
+
+#include "gtest/gtest.h"
+
+using namespace analyzer;
+
+static const auto nodeId =
+    static_cast<libhei::NodeId_t>(libhei::hash<libhei::NodeId_t>("TOD_ERROR"));
+
+TEST(TodStepCheckFault, TestSet1)
+{
+    pdbg_targets_init(nullptr);
+
+    libhei::Chip chip1{util::pdbg::getTrgt("/proc1"), P10_20};
+
+    // TOD_ERROR(0)[16]
+    libhei::Signature sig{chip1, nodeId, 0, 16, libhei::ATTN_TYPE_CHECKSTOP};
+
+    auto plugin =
+        PluginMap::getSingleton().get(chip1.getType(), "tod_step_check_fault");
+
+    libhei::IsolationData isoData{};
+    isoData.addSignature(sig);
+    ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP, isoData};
+
+    // Call the plugin.
+    plugin(1, chip1, sd);
+
+    nlohmann::json j{};
+    std::string s{};
+
+    // Callout list
+    j = sd.getCalloutList();
+    s = R"([
+    {
+        "Deconfigured": false,
+        "Guarded": false,
+        "LocationCode": "P0",
+        "Priority": "M"
+    },
+    {
+        "Deconfigured": false,
+        "Guarded": false,
+        "LocationCode": "/proc1",
+        "Priority": "M"
+    }
+])";
+    EXPECT_EQ(s, j.dump(4));
+
+    // Callout FFDC
+    j = sd.getCalloutFFDC();
+    s = R"([
+    {
+        "Callout Type": "Clock Callout",
+        "Clock Type": "TOD_CLOCK",
+        "Priority": "medium"
+    },
+    {
+        "Callout Type": "Hardware Callout",
+        "Guard": false,
+        "Priority": "medium",
+        "Target": "/proc1"
+    }
+])";
+    EXPECT_EQ(s, j.dump(4));
+}