Skip to content

Commit b181d9d

Browse files
spinlersmccarney
authored andcommitted
Fixes to get unit tests to compile
There are 2 CI failures that started showing up at the same time: 1) sdbusplus recenty had a commit that started checking the return code on sd_bus_add_object_vtable and now 2 tests are getting those fails in CI, so used the mocked bus objects instead. 2) pel_values_test.cpp fails with: Expected equality of these values: "cec_service_network" Which is: 0x563efae570fc std::get<registryNamePos>(*s) Which is: 0x563efae57a64 because it is using EXPECT_EQ to compare to char* values instead of EXPECT_STREQ. I'm not sure what changed that uncovered this. Fix them both at the same time as CI won't pass when doing them separately because of the other error. Signed-off-by: Matt Spinler <[email protected]> Change-Id: I937bd6d6965be5c8aab26f6c539cf30537439e0b
1 parent 0d804ef commit b181d9d

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

test/extensions_test.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "elog_entry.hpp"
22
#include "extensions.hpp"
33

4+
#include <sdbusplus/test/sdbus_mock.hpp>
5+
46
#include <gtest/gtest.h>
57

68
using namespace phosphor::logging;
@@ -63,7 +65,8 @@ REGISTER_EXTENSION_FUNCTION(deleteLog2);
6365

6466
TEST(ExtensionsTest, FunctionCallTest)
6567
{
66-
auto bus = sdbusplus::bus::new_default();
68+
sdbusplus::SdBusMock sdbusMock;
69+
sdbusplus::bus::bus bus = sdbusplus::get_mocked_new(&sdbusMock);
6770
internal::Manager manager(bus, "testpath");
6871

6972
EXPECT_EQ(Extensions::getStartupFunctions().size(), 2);

test/openpower-pels/pel_values_test.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ TEST(PELFieldsTest, TestFindFields)
2424
{
2525
auto s = findByValue(0x5D, subsystemValues);
2626
ASSERT_NE(s, subsystemValues.end());
27-
ASSERT_EQ(0x5D, std::get<fieldValuePos>(*s));
28-
ASSERT_EQ("cec_service_network", std::get<registryNamePos>(*s));
27+
EXPECT_EQ(0x5D, std::get<fieldValuePos>(*s));
28+
EXPECT_STREQ("cec_service_network", std::get<registryNamePos>(*s));
2929

3030
s = findByName("cec_clocks", subsystemValues);
3131
ASSERT_NE(s, subsystemValues.end());
32-
ASSERT_EQ(0x58, std::get<fieldValuePos>(*s));
33-
ASSERT_EQ("cec_clocks", std::get<registryNamePos>(*s));
34-
ASSERT_EQ("CEC Hardware: Clock", std::get<descriptionPos>(*s));
32+
EXPECT_EQ(0x58, std::get<fieldValuePos>(*s));
33+
EXPECT_STREQ("cec_clocks", std::get<registryNamePos>(*s));
34+
EXPECT_STREQ("CEC Hardware: Clock", std::get<descriptionPos>(*s));
3535

3636
s = findByValue(0xFF, subsystemValues);
37-
ASSERT_EQ(s, subsystemValues.end());
37+
EXPECT_EQ(s, subsystemValues.end());
3838

3939
s = findByName("foo", subsystemValues);
40-
ASSERT_EQ(s, subsystemValues.end());
40+
EXPECT_EQ(s, subsystemValues.end());
4141
}

test/serialization_tests.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <experimental/filesystem>
88
#include <sdbusplus/bus.hpp>
9+
#include <sdbusplus/test/sdbus_mock.hpp>
910

1011
#include <gtest/gtest.h>
1112

@@ -19,7 +20,8 @@ namespace test
1920
namespace fs = std::experimental::filesystem;
2021

2122
char tmplt[] = "/tmp/logging_test.XXXXXX";
22-
auto bus = sdbusplus::bus::new_default();
23+
sdbusplus::SdBusMock sdbusMock;
24+
sdbusplus::bus::bus bus = sdbusplus::get_mocked_new(&sdbusMock);
2325
phosphor::logging::internal::Manager manager(bus, OBJ_INTERNAL);
2426

2527
class TestSerialization : public testing::Test

0 commit comments

Comments
 (0)