plugin for LPC timeout callouts
Change-Id: I39fed3c1ba5a16283c33c5072479f24c9c69a208
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/test/meson.build b/test/meson.build
index 45c5749..b34dda2 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -38,6 +38,7 @@
'bin_stream_test',
'ffdc_file_test',
'resolution_test',
+ 'test-lpc-timeout',
'test-pll-unlock',
]
@@ -56,11 +57,15 @@
'../util/temporary_file.cpp',
)
+sim_src = files(
+ 'pdbg-sim-only.cpp',
+)
+
foreach t : tests
test(t,
executable(t.underscorify(),
[ files(t + '.cpp'), pdbg_test_dtb,
- analyzer_src, util_src ],
+ analyzer_src, util_src, sim_src ],
dependencies : [ libhei_dep, libpdbg_dep, gtest_dep ],
cpp_args : test_arg,
include_directories : incdir),
diff --git a/test/pdbg-sim-only.cpp b/test/pdbg-sim-only.cpp
new file mode 100644
index 0000000..efeee51
--- /dev/null
+++ b/test/pdbg-sim-only.cpp
@@ -0,0 +1,36 @@
+//------------------------------------------------------------------------------
+// IMPORTANT:
+// This file will ONLY be built in CI test and should be used for any functions
+// that require addition support to simulate in CI test. Any functions that will
+// work out-of-the-box in CI test with use of the fake device tree should be put
+// in `pdbg.cpp`.
+//------------------------------------------------------------------------------
+
+#include <assert.h>
+
+#include <util/pdbg.hpp>
+#include <util/trace.hpp>
+
+//------------------------------------------------------------------------------
+
+// Using this to fake the value returned from the simulation-only version of
+// util::pdbg::queryLpcTimeout().
+bool g_lpcTimeout = false;
+
+namespace util
+{
+namespace pdbg
+{
+
+// This is the simulated version of this function.
+bool queryLpcTimeout(pdbg_target* target)
+{
+ // Must be a processor target.
+ assert(TYPE_PROC == getTrgtType(target));
+
+ // Instead of the SBE chip-op, use the faked value.
+ return g_lpcTimeout;
+}
+
+} // namespace pdbg
+} // namespace util
diff --git a/test/test-lpc-timeout.cpp b/test/test-lpc-timeout.cpp
new file mode 100644
index 0000000..89d2336
--- /dev/null
+++ b/test/test-lpc-timeout.cpp
@@ -0,0 +1,121 @@
+#include <stdio.h>
+
+#include <analyzer/plugins/plugin.hpp>
+#include <analyzer/util.hpp>
+#include <util/pdbg.hpp>
+#include <util/trace.hpp>
+
+#include "gtest/gtest.h"
+
+//------------------------------------------------------------------------------
+
+using namespace analyzer;
+
+extern bool g_lpcTimeout;
+
+// Test #1: - no LPC timeout
+TEST(LpcTimeout, TestSet1)
+{
+ pdbg_targets_init(nullptr);
+
+ g_lpcTimeout = false; // no timeout
+
+ libhei::Chip chip{util::pdbg::getTrgt("/proc0"), P10_20};
+
+ auto plugin = PluginMap::getSingleton().get(chip.getType(), "lpc_timeout");
+
+ ServiceData sd{libhei::Signature{}, AnalysisType::SYSTEM_CHECKSTOP,
+ libhei::IsolationData{}};
+
+ plugin(0, chip, sd);
+
+ nlohmann::json j{};
+ std::string s{};
+
+ // Callout list
+ j = sd.getCalloutList();
+ s = R"([
+ {
+ "Priority": "H",
+ "Procedure": "next_level_support"
+ }
+])";
+ EXPECT_EQ(s, j.dump(4));
+
+ // Callout FFDC
+ j = sd.getCalloutFFDC();
+ s = R"([
+ {
+ "Callout Type": "Procedure Callout",
+ "Priority": "high",
+ "Procedure": "next_level_support"
+ }
+])";
+ EXPECT_EQ(s, j.dump(4));
+}
+
+// Test #2: - LPC timeout
+TEST(LpcTimeout, TestSet2)
+{
+ pdbg_targets_init(nullptr);
+
+ g_lpcTimeout = true; // force timeout
+
+ libhei::Chip chip{util::pdbg::getTrgt("/proc0"), P10_20};
+
+ auto plugin = PluginMap::getSingleton().get(chip.getType(), "lpc_timeout");
+
+ ServiceData sd{libhei::Signature{}, AnalysisType::SYSTEM_CHECKSTOP,
+ libhei::IsolationData{}};
+
+ plugin(0, chip, sd);
+
+ nlohmann::json j{};
+ std::string s{};
+
+ // Callout list
+ j = sd.getCalloutList();
+ s = R"([
+ {
+ "Deconfigured": false,
+ "Guarded": false,
+ "LocationCode": "/bmc0",
+ "Priority": "M"
+ },
+ {
+ "Deconfigured": false,
+ "Guarded": false,
+ "LocationCode": "P0",
+ "Priority": "M"
+ },
+ {
+ "Deconfigured": false,
+ "Guarded": false,
+ "LocationCode": "/proc0",
+ "Priority": "M"
+ }
+])";
+ EXPECT_EQ(s, j.dump(4));
+
+ // Callout FFDC
+ j = sd.getCalloutFFDC();
+ s = R"([
+ {
+ "Callout Type": "Part Callout",
+ "Part Type": "PNOR",
+ "Priority": "medium"
+ },
+ {
+ "Callout Type": "Clock Callout",
+ "Clock Type": "OSC_REF_CLOCK_0",
+ "Priority": "medium"
+ },
+ {
+ "Callout Type": "Hardware Callout",
+ "Guard": false,
+ "Priority": "medium",
+ "Target": "/proc0"
+ }
+])";
+ EXPECT_EQ(s, j.dump(4));
+}