boot-block: create d-bus block object on callout

If the QuiesceOnHwError is set and a callout is present in the Entry
then create the new block object and the
xyz.openbmc_project.Logging.ErrorBlocksTransition interface.

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I9aea289ab7cc8dc7649820ff54edc8c04ecb3ef5
diff --git a/test/elog_quiesce_test.cpp b/test/elog_quiesce_test.cpp
index a29dc3e..3eb2a3d 100644
--- a/test/elog_quiesce_test.cpp
+++ b/test/elog_quiesce_test.cpp
@@ -78,6 +78,70 @@
     EXPECT_EQ(manager.isCalloutPresent(elog), true);
 }
 
+// Test that no blocking errors are created when no callout
+TEST_F(TestQuiesceOnError, testNoBlockingErrorsCreated)
+{
+    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};
+
+    manager.checkQuiesceOnError(elog);
+    EXPECT_EQ(manager.getBlockingErrSize(), 0);
+}
+
+// Test that a blocking error is created on entry with callout
+TEST_F(TestQuiesceOnError, testBlockingErrorsCreated)
+{
+    uint32_t id = 100;
+    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{};
+
+    // Ensure D-Bus object created for this blocking error
+    // First allow any number of sd_bus_emit_object_added calls
+    EXPECT_CALL(sdbusMock, sd_bus_emit_object_added(testing::_, testing::_))
+        .Times(testing::AnyNumber());
+    // Second verify the new block100 object is created once
+    EXPECT_CALL(sdbusMock,
+                sd_bus_emit_object_added(
+                    testing::_, testing::HasSubstr(
+                                    "/xyz/openbmc_project/logging/block100")))
+        .Times(1);
+
+    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};
+
+    manager.checkQuiesceOnError(elog);
+    // Created error with callout so expect a blocking error now
+    EXPECT_EQ(manager.getBlockingErrSize(), 1);
+}
+
 } // namespace test
 } // namespace logging
 } // namespace phosphor