Create a DBus notification for each LogEntry
For each log entry, a new FilePath DBus object will be created where
the FilePath.path value is the location of the JSON LogEntry file.
Tested:
Tested with unit tests and locally on a machine.
Signed-off-by: Kasun Athukorala <kasunath@google.com>
Change-Id: I5999826f7b4447bfca88b83c487d7c03a1c84a08
diff --git a/test/external_storer_file_test.cpp b/test/external_storer_file_test.cpp
index fc550ee..f2718aa 100644
--- a/test/external_storer_file_test.cpp
+++ b/test/external_storer_file_test.cpp
@@ -1,5 +1,8 @@
#include "rde/external_storer_file.hpp"
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/test/sdbus_mock.hpp>
+
#include <string_view>
#include <gmock/gmock-matchers.h>
@@ -15,6 +18,7 @@
using ::testing::DoAll;
using ::testing::Return;
using ::testing::SaveArg;
+using ::testing::StrEq;
class MockFileWriter : public FileHandlerInterface
{
@@ -30,14 +34,26 @@
{
public:
ExternalStorerFileTest() :
+ bus(sdbusplus::get_mocked_new(&sdbusMock)),
mockFileWriter(std::make_unique<MockFileWriter>())
{
mockFileWriterPtr = dynamic_cast<MockFileWriter*>(mockFileWriter.get());
+
+ EXPECT_CALL(
+ sdbusMock,
+ sd_bus_add_object_manager(
+ nullptr, _,
+ StrEq(
+ "/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER")))
+ .WillOnce(Return(0));
+
exStorer = std::make_unique<ExternalStorerFileInterface>(
- rootPath, std::move(mockFileWriter));
+ bus, rootPath, std::move(mockFileWriter));
}
protected:
+ sdbusplus::SdBusMock sdbusMock;
+ sdbusplus::bus::bus bus;
std::unique_ptr<FileHandlerInterface> mockFileWriter;
std::unique_ptr<ExternalStorerFileInterface> exStorer;
MockFileWriter* mockFileWriterPtr;
@@ -147,12 +163,29 @@
"@odata.type": "#LogEntry.v1_13_0.LogEntry"
}
)";
+
nlohmann::json logEntryOut;
EXPECT_CALL(*mockFileWriterPtr, createFile(_, _))
.WillOnce(DoAll(SaveArg<1>(&logEntryOut), Return(true)));
+
+ constexpr const char* dbusPath =
+ "/xyz/openbmc_project/external_storer/bios_bmc_smm_error_logger/CPER/entry0";
+ constexpr const char* dbusInterface = "xyz.openbmc_project.Common.FilePath";
+
+ EXPECT_CALL(sdbusMock, sd_bus_add_object_vtable(nullptr, _, StrEq(dbusPath),
+ StrEq(dbusInterface), _, _))
+ .WillOnce(Return(0));
+ EXPECT_CALL(sdbusMock,
+ sd_bus_emit_interfaces_added_strv(nullptr, StrEq(dbusPath), _))
+ .WillOnce(Return(0));
+
EXPECT_THAT(exStorer->publishJson(jsonLogEntry), true);
EXPECT_NE(logEntryOut["Id"], nullptr);
EXPECT_EQ(logEntryOut["@odata.id"], nullptr);
+
+ EXPECT_CALL(sdbusMock, sd_bus_emit_interfaces_removed_strv(
+ nullptr, StrEq(dbusPath), _))
+ .WillOnce(Return(0));
}
TEST_F(ExternalStorerFileTest, OtherSchemaNoOdataIdTest)