Refined guard type in HardwareCalloutResolution
A resolution guard type needs to be evaluated during the resolve()
function and not when the resolution is created.
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Ia597ed93567b27c2cd9423f6fb0f7e75158fc315
diff --git a/analyzer/resolution.cpp b/analyzer/resolution.cpp
index 14842ad..9ad7502 100644
--- a/analyzer/resolution.cpp
+++ b/analyzer/resolution.cpp
@@ -43,7 +43,13 @@
}
else
{
- io_sd.addGuard(std::make_shared<Guard>(entityPath, iv_guard));
+ Guard::Type guard = Guard::NONE;
+ if (iv_guard)
+ {
+ guard = io_sd.queryCheckstop() ? Guard::FATAL : Guard::NON_FATAL;
+ }
+
+ io_sd.addGuard(std::make_shared<Guard>(entityPath, guard));
}
}
diff --git a/analyzer/resolution.hpp b/analyzer/resolution.hpp
index 32aee24..62afd76 100644
--- a/analyzer/resolution.hpp
+++ b/analyzer/resolution.hpp
@@ -33,11 +33,10 @@
* @param i_path The devtree path of a guardable unit relative to a
* chip. An empty string refers to the chip itself.
* @param i_priority The callout priority.
- * @param i_guard The guard type for this callout.
+ * @param i_guard True, if guard is required. False, otherwise.
*/
HardwareCalloutResolution(const std::string& i_path,
- Callout::Priority i_priority,
- Guard::Type i_guard) :
+ Callout::Priority i_priority, bool i_guard) :
iv_path(i_path),
iv_priority(i_priority), iv_guard(i_guard)
{}
@@ -50,8 +49,8 @@
/** The callout priority. */
const Callout::Priority iv_priority;
- /** The guard type for this callout. */
- const Guard::Type iv_guard;
+ /** True, if guard is required. False, otherwise. */
+ const bool iv_guard;
public:
void resolve(ServiceData& io_sd) const override;
diff --git a/test/resolution_test.cpp b/test/resolution_test.cpp
index f05997f..e8b3f71 100644
--- a/test/resolution_test.cpp
+++ b/test/resolution_test.cpp
@@ -21,15 +21,21 @@
auto sig = io_sd.getRootCause();
std::string fru{(const char*)sig.getChip().getChip()};
- std::string guard{fru};
+ std::string path{fru};
if (!iv_path.empty())
{
- guard += "/" + iv_path;
+ path += "/" + iv_path;
}
io_sd.addCallout(std::make_shared<HardwareCallout>(fru, iv_priority));
- io_sd.addGuard(std::make_shared<Guard>(guard, iv_guard));
+ Guard::Type guard = Guard::NONE;
+ if (iv_guard)
+ {
+ guard = io_sd.queryCheckstop() ? Guard::FATAL : Guard::NON_FATAL;
+ }
+
+ io_sd.addGuard(std::make_shared<Guard>(path, guard));
}
} // namespace analyzer
@@ -40,13 +46,13 @@
{
// Create a few resolutions
auto c1 = std::make_shared<HardwareCalloutResolution>(
- proc_str, Callout::Priority::HIGH, Guard::NONE);
+ proc_str, Callout::Priority::HIGH, false);
auto c2 = std::make_shared<HardwareCalloutResolution>(
- omi_str, Callout::Priority::MED_A, Guard::FATAL);
+ omi_str, Callout::Priority::MED_A, true);
auto c3 = std::make_shared<HardwareCalloutResolution>(
- core_str, Callout::Priority::MED, Guard::NON_FATAL);
+ core_str, Callout::Priority::MED, true);
auto c4 = std::make_shared<ProcedureCalloutResolution>(
ProcedureCallout::NEXTLVL, Callout::Priority::LOW);
@@ -135,7 +141,7 @@
},
{
"Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
- "Type": "FATAL"
+ "Type": "NON_FATAL"
}
])";
ASSERT_EQ(s, j.dump(4));