boot-block: look for a callout in the entry

phosphor-logging callouts always start with a CALLOUT_ in the additional
data entry. Look for this to determine if a callout is present in the
log.

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I721e794dc4610a18705e1b0d75e545b14f844402
diff --git a/log_manager.cpp b/log_manager.cpp
index 5be474f..cf2a795 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -268,8 +268,29 @@
     return std::get<bool>(property);
 }
 
+bool Manager::isCalloutPresent(const Entry& entry)
+{
+    for (const auto& c : entry.additionalData())
+    {
+        if (c.find("CALLOUT_") != std::string::npos)
+        {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 void Manager::checkQuiesceOnError(const Entry& entry)
 {
+
+    if (!isCalloutPresent(entry))
+    {
+        return;
+    }
+
+    logging::log<logging::level::INFO>(
+        "QuiesceOnError set and callout present");
     // TODO in later commit in this series
 }
 
diff --git a/log_manager.hpp b/log_manager.hpp
index a57f1ab..b24a7f3 100644
--- a/log_manager.hpp
+++ b/log_manager.hpp
@@ -183,6 +183,14 @@
      */
     void checkQuiesceOnError(const Entry& entry);
 
+    /** @brief Check if inventory callout present in input entry
+     *
+     * @param[in] entry - The error to check for callouts
+     *
+     * @return true if inventory item in associations, false otherwise
+     */
+    bool isCalloutPresent(const Entry& entry);
+
   private:
     /*
      * @fn _commit()
diff --git a/test/Makefile.am b/test/Makefile.am
index ddd42e6..8484d62 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -11,7 +11,8 @@
 	remote_logging_test_config \
 	sdjournal_mock_test \
 	extensions_test \
-	elog_update_ts_test
+	elog_update_ts_test \
+	elog_quiesce_test
 
 test_cppflags = \
 	-Igtest \
@@ -114,6 +115,14 @@
 elog_update_ts_test_LDFLAGS = \
 	$(test_ldflags)
 
+elog_quiesce_test_CPPFLAGS = $(test_cppflags)
+elog_quiesce_test_CXXFLAGS = $(test_cxxflags)
+elog_quiesce_test_SOURCES = elog_quiesce_test.cpp
+elog_quiesce_test_LDADD = $(test_ldadd)
+elog_quiesce_test_LDFLAGS = \
+	$(test_ldflags)
+
+
 # TODO Remove once the test-case failure is resolved openbmc/phosphor-logging#11
 XFAIL_TESTS = elog_errorwrap_test
 
diff --git a/test/elog_quiesce_test.cpp b/test/elog_quiesce_test.cpp
new file mode 100644
index 0000000..a29dc3e
--- /dev/null
+++ b/test/elog_quiesce_test.cpp
@@ -0,0 +1,83 @@
+#include "config.h"
+
+#include "elog_entry.hpp"
+#include "log_manager.hpp"
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/test/sdbus_mock.hpp>
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+namespace phosphor
+{
+namespace logging
+{
+namespace test
+{
+
+class TestQuiesceOnError : public testing::Test
+{
+  public:
+    sdbusplus::SdBusMock sdbusMock;
+    sdbusplus::bus::bus mockedBus = sdbusplus::get_mocked_new(&sdbusMock);
+    phosphor::logging::internal::Manager manager;
+
+    TestQuiesceOnError() : manager(mockedBus, OBJ_INTERNAL)
+    {
+    }
+};
+
+// Test that false is returned when no callout is present in the log
+TEST_F(TestQuiesceOnError, testNoCallout)
+{
+    uint32_t id = 99;
+    uint64_t timestamp{100};
+    std::string message{"test error"};
+    std::string fwLevel{"level42"};
+    std::vector<std::string> testData{"no", "callout"};
+    phosphor::logging::AssociationList associations{};
+
+    Entry elog{mockedBus,
+               std::string(OBJ_ENTRY) + '/' + std::to_string(id),
+               id,
+               timestamp,
+               Entry::Level::Informational,
+               std::move(message),
+               std::move(testData),
+               std::move(associations),
+               fwLevel,
+               manager};
+
+    EXPECT_EQ(manager.isCalloutPresent(elog), false);
+}
+
+// Test that trues is returned when a callout is present in the log
+TEST_F(TestQuiesceOnError, testCallout)
+{
+    uint32_t id = 99;
+    uint64_t timestamp{100};
+    std::string message{"test error"};
+    std::string fwLevel{"level42"};
+    std::vector<std::string> testData{
+        "CALLOUT_INVENTORY_PATH=/xyz/openbmc_project/inventory/system/chassis/"
+        "motherboard/powersupply0/"};
+    phosphor::logging::AssociationList associations{};
+
+    Entry elog{mockedBus,
+               std::string(OBJ_ENTRY) + '/' + std::to_string(id),
+               id,
+               timestamp,
+               Entry::Level::Informational,
+               std::move(message),
+               std::move(testData),
+               std::move(associations),
+               fwLevel,
+               manager};
+
+    EXPECT_EQ(manager.isCalloutPresent(elog), true);
+}
+
+} // namespace test
+} // namespace logging
+} // namespace phosphor