test: Initialize slot in SdBusMock
In the default constructor for SdBusMock the slot was initialized and
we override it in this test case which can lead to memory errors.
Change-Id: I522ee63505d98861a1d45abd01144d1eef7aa727
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/test/post_reporter_test.cpp b/test/post_reporter_test.cpp
index ef0d0d5..170e90f 100644
--- a/test/post_reporter_test.cpp
+++ b/test/post_reporter_test.cpp
@@ -40,10 +40,15 @@
TEST_F(PostReporterTest, AddsObjectWithExpectedName)
{
+ auto slotcb = [](sd_bus*, sd_bus_slot** slot, auto&&...) {
+ *slot = reinterpret_cast<sd_bus_slot*>(0xdefa);
+ return 0;
+ };
+
EXPECT_CALL(bus_mock,
sd_bus_add_object_vtable(IsNull(), _, StrEq(snoopObject),
StrEq(snoopDbus), _, _))
- .WillOnce(Return(0));
+ .WillOnce(slotcb);
PostReporter testReporter(bus, snoopObject, true);
}