diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-03-29 10:34:05 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-03-29 10:34:46 -0400 |
commit | d1eac88d18ae7dd11033dba87b6aebb220da9064 (patch) | |
tree | 9744e38138ff853c53868d847f86e9ad58e9ac66 /src/test | |
parent | 1abcb06bedadfbd40b4ec6f7e5f6a95021df3c96 (diff) | |
download | phosphor-dbus-monitor-d1eac88d18ae7dd11033dba87b6aebb220da9064.tar.gz phosphor-dbus-monitor-d1eac88d18ae7dd11033dba87b6aebb220da9064.zip |
Enable clang-format
Fix up errors and enable clang-format during CI builds.
Change-Id: I4176b81f8b85a287af9354165e09ff66aeb9fb29
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/callbackgentest.cpp | 18 | ||||
-rw-r--r-- | src/test/callbackgroupgentest.cpp | 14 | ||||
-rw-r--r-- | src/test/conditiongentest.cpp | 20 | ||||
-rw-r--r-- | src/test/pathgentest.cpp | 95 | ||||
-rw-r--r-- | src/test/propertygentest.cpp | 65 | ||||
-rw-r--r-- | src/test/propertywatchgentest.cpp | 80 | ||||
-rw-r--r-- | src/test/propertywatchtest.cpp | 134 | ||||
-rw-r--r-- | src/test/propertywatchtest.hpp | 637 |
8 files changed, 389 insertions, 674 deletions
diff --git a/src/test/callbackgentest.cpp b/src/test/callbackgentest.cpp index 77fe60a..cda665d 100644 --- a/src/test/callbackgentest.cpp +++ b/src/test/callbackgentest.cpp @@ -9,15 +9,12 @@ using Index = std::map<std::tuple<size_t, size_t, size_t>, size_t>; #include "callbackgentest.hpp" -const std::array<std::tuple<std::string, size_t>, 4> expectedCallbacks = -{ - { - std::tuple<std::string, size_t>{"int32_t", 0}, - std::tuple<std::string, size_t>{"int32_t", 0}, - std::tuple<std::string, size_t>{"std::string", 1}, - std::tuple<std::string, size_t>{"std::string", 2}, - } -}; +const std::array<std::tuple<std::string, size_t>, 4> expectedCallbacks = {{ + std::tuple<std::string, size_t>{"int32_t", 0}, + std::tuple<std::string, size_t>{"int32_t", 0}, + std::tuple<std::string, size_t>{"std::string", 1}, + std::tuple<std::string, size_t>{"std::string", 2}, +}}; TEST(CallbackGenTest, CallbacksSameSize) { @@ -29,7 +26,6 @@ TEST(CallbackGenTest, CallbacksSameContent) size_t i; for (i = 0; i < expectedCallbacks.size(); ++i) { - ASSERT_EQ(callbacks[i], - expectedCallbacks[i]); + ASSERT_EQ(callbacks[i], expectedCallbacks[i]); } } diff --git a/src/test/callbackgroupgentest.cpp b/src/test/callbackgroupgentest.cpp index 3112295..fe760ec 100644 --- a/src/test/callbackgroupgentest.cpp +++ b/src/test/callbackgroupgentest.cpp @@ -8,12 +8,11 @@ using namespace phosphor::dbus::monitoring; #include "callbackgroupgentest.hpp" const std::array<std::vector<size_t>, 4> expectedGroups = {{ - {0, 1, 2, 3}, - {0, 1, 4}, - {2, 6, 7}, - {7}, - } -}; + {0, 1, 2, 3}, + {0, 1, 4}, + {2, 6, 7}, + {7}, +}}; TEST(CallbackGroupGenTest, GroupsSameSize) { @@ -25,7 +24,6 @@ TEST(CallbackGroupGenTest, GroupsSameContent) size_t i; for (i = 0; i < expectedGroups.size(); ++i) { - ASSERT_EQ(groups[i], - expectedGroups[i]); + ASSERT_EQ(groups[i], expectedGroups[i]); } } diff --git a/src/test/conditiongentest.cpp b/src/test/conditiongentest.cpp index 76ea608..d0df215 100644 --- a/src/test/conditiongentest.cpp +++ b/src/test/conditiongentest.cpp @@ -7,16 +7,12 @@ using namespace phosphor::dbus::monitoring; #include "conditiongentest.hpp" -const std::array<std::vector<size_t>, 2> expectedGroups = -{ - { - {0}, - {1}, - } -}; +const std::array<std::vector<size_t>, 2> expectedGroups = {{ + {0}, + {1}, +}}; -const std::array<size_t, 4> expectedCallbacks = -{ +const std::array<size_t, 4> expectedCallbacks = { 0, 0, 1, @@ -38,8 +34,7 @@ TEST(ConditionGenTest, GroupsSameContent) size_t i; for (i = 0; i < expectedGroups.size(); ++i) { - ASSERT_EQ(groups[i], - expectedGroups[i]); + ASSERT_EQ(groups[i], expectedGroups[i]); } } @@ -48,7 +43,6 @@ TEST(ConditionGenTest, CallbacksSameContent) size_t i; for (i = 0; i < expectedCallbacks.size(); ++i) { - ASSERT_EQ(callbacks[i], - expectedCallbacks[i]); + ASSERT_EQ(callbacks[i], expectedCallbacks[i]); } } diff --git a/src/test/pathgentest.cpp b/src/test/pathgentest.cpp index d13c82e..1f75153 100644 --- a/src/test/pathgentest.cpp +++ b/src/test/pathgentest.cpp @@ -9,15 +9,13 @@ using PathMeta = TupleOfRefs<const std::string, const std::string>; #include "pathgentest.hpp" -const std::array<std::string, 3> expectedMeta = -{ +const std::array<std::string, 3> expectedMeta = { "PATH1"s, "PATH3"s, "PATH2"s, }; -const std::array<std::string, 6> expectedPaths = -{ +const std::array<std::string, 6> expectedPaths = { "/xyz/openbmc_project/testing/inst1"s, "/xyz/openbmc_project/testing/inst2"s, "/xyz/openbmc_project/testing/inst3"s, @@ -26,55 +24,49 @@ const std::array<std::string, 6> expectedPaths = "/xyz/openbmc_project/testing/inst6"s, }; -const std::array<PathMeta, 14> expectedPathMeta = -{ +const std::array<PathMeta, 14> expectedPathMeta = {{ + PathMeta{paths[0], meta[0]}, + PathMeta{paths[1], meta[0]}, + PathMeta{paths[2], meta[0]}, + PathMeta{paths[3], meta[0]}, + PathMeta{paths[0], meta[1]}, + PathMeta{paths[1], meta[1]}, + PathMeta{paths[2], meta[1]}, + PathMeta{paths[3], meta[1]}, + PathMeta{paths[4], meta[0]}, + PathMeta{paths[5], meta[0]}, + PathMeta{paths[3], meta[2]}, + PathMeta{paths[2], meta[2]}, + PathMeta{paths[1], meta[2]}, + PathMeta{paths[0], meta[2]}, +}}; + +const std::array<RefVector<const std::string>, 4> expectedGroups = {{ { - PathMeta{ paths[0], meta[0] }, - PathMeta{ paths[1], meta[0] }, - PathMeta{ paths[2], meta[0] }, - PathMeta{ paths[3], meta[0] }, - PathMeta{ paths[0], meta[1] }, - PathMeta{ paths[1], meta[1] }, - PathMeta{ paths[2], meta[1] }, - PathMeta{ paths[3], meta[1] }, - PathMeta{ paths[4], meta[0] }, - PathMeta{ paths[5], meta[0] }, - PathMeta{ paths[3], meta[2] }, - PathMeta{ paths[2], meta[2] }, - PathMeta{ paths[1], meta[2] }, - PathMeta{ paths[0], meta[2] }, - } -}; - -const std::array<RefVector<const std::string>, 4> expectedGroups = -{ + paths[0], + paths[1], + paths[2], + paths[3], + }, { - { - paths[0], - paths[1], - paths[2], - paths[3], - }, - { - paths[0], - paths[1], - paths[2], - paths[3], - }, - { - paths[0], - paths[1], - paths[4], - paths[5], - }, - { - paths[3], - paths[2], - paths[1], - paths[0], - }, - } -}; + paths[0], + paths[1], + paths[2], + paths[3], + }, + { + paths[0], + paths[1], + paths[4], + paths[5], + }, + { + paths[3], + paths[2], + paths[1], + paths[0], + }, +}}; TEST(PathGenTest, MetaSameSize) { @@ -138,7 +130,6 @@ TEST(PathGenTest, GroupsSameContent) for (j = 0; j < groups[i].size(); ++j) { ASSERT_EQ(groups[i][j].get(), expectedGroups[i][j].get()); - } } } diff --git a/src/test/propertygentest.cpp b/src/test/propertygentest.cpp index e5c95c2..d17f6a1 100644 --- a/src/test/propertygentest.cpp +++ b/src/test/propertygentest.cpp @@ -7,62 +7,52 @@ using namespace std::string_literals; using namespace phosphor::dbus::monitoring; using Property = - TupleOfRefs < - const std::string, - const std::string, - const std::string >; + TupleOfRefs<const std::string, const std::string, const std::string>; using GroupOfProperties = std::vector<Property>; #include "propertygentest.hpp" -const std::array<std::string, 3> expectedMeta = -{ +const std::array<std::string, 3> expectedMeta = { "PROPERTY1"s, "PROPERTY2"s, "PROPERTY3"s, }; -const std::array<std::string, 4> expectedInterfaces = -{ +const std::array<std::string, 4> expectedInterfaces = { "xyz.openbmc_project.Test.Iface3"s, "xyz.openbmc_project.Test.Iface2"s, "xyz.openbmc_project.Test.Iface6"s, "xyz.openbmc_project.Test.Iface1"s, }; -const std::array<std::string, 4> expectedProperties = -{ +const std::array<std::string, 4> expectedProperties = { "Foo"s, "Value"s, "Bar"s, "Baz"s, }; -const std::array<GroupOfProperties, 4> expectedGroups = -{ +const std::array<GroupOfProperties, 4> expectedGroups = {{ { - { - Property{ interfaces[0], properties[0], meta[0] }, - Property{ interfaces[1], properties[1], meta[1] }, - }, - { - Property{ interfaces[0], properties[2], meta[0] }, - Property{ interfaces[1], properties[0], meta[1] }, - }, - { - Property{ interfaces[2], properties[0], meta[0] }, - Property{ interfaces[3], properties[1], meta[1] }, - }, - { - Property{ interfaces[0], properties[2], meta[0] }, - Property{ interfaces[1], properties[1], meta[1] }, - Property{ interfaces[2], properties[3], meta[2] }, - }, - } -}; + Property{interfaces[0], properties[0], meta[0]}, + Property{interfaces[1], properties[1], meta[1]}, + }, + { + Property{interfaces[0], properties[2], meta[0]}, + Property{interfaces[1], properties[0], meta[1]}, + }, + { + Property{interfaces[2], properties[0], meta[0]}, + Property{interfaces[3], properties[1], meta[1]}, + }, + { + Property{interfaces[0], properties[2], meta[0]}, + Property{interfaces[1], properties[1], meta[1]}, + Property{interfaces[2], properties[3], meta[2]}, + }, +}}; -const std::array<std::string, 4> expectedTypes = -{ +const std::array<std::string, 4> expectedTypes = { "uint32_t"s, "int32_t"s, "std::string"s, @@ -99,8 +89,7 @@ TEST(PropertyGenTest, MetaSameContent) size_t i; for (i = 0; i < expectedMeta.size(); ++i) { - ASSERT_EQ(meta[i], - expectedMeta[i]); + ASSERT_EQ(meta[i], expectedMeta[i]); } } @@ -109,8 +98,7 @@ TEST(PropertyGenTest, IfacesSameContent) size_t i; for (i = 0; i < expectedInterfaces.size(); ++i) { - ASSERT_EQ(interfaces[i], - expectedInterfaces[i]); + ASSERT_EQ(interfaces[i], expectedInterfaces[i]); } } @@ -135,7 +123,8 @@ TEST(PropertyGenTest, GroupsSameContent) const auto& actualIface = std::get<0>(groups[i][j]).get(); ASSERT_EQ(expectedIface, actualIface); - const auto& expectedProperty = std::get<1>(expectedGroups[i][j]).get(); + const auto& expectedProperty = + std::get<1>(expectedGroups[i][j]).get(); const auto& actualProperty = std::get<1>(groups[i][j]).get(); ASSERT_EQ(expectedProperty, actualProperty); diff --git a/src/test/propertywatchgentest.cpp b/src/test/propertywatchgentest.cpp index 5973f92..2e446a4 100644 --- a/src/test/propertywatchgentest.cpp +++ b/src/test/propertywatchgentest.cpp @@ -12,48 +12,42 @@ using Index = std::map<std::tuple<size_t, size_t, size_t>, size_t>; auto expectedStorageCount = 16; -const std::array<Index, 4> expectedIndicies = -{ +const std::array<Index, 4> expectedIndicies = {{ { - { - {Index::key_type{0, 0, 0}, 0}, - {Index::key_type{0, 1, 0}, 1}, - {Index::key_type{1, 0, 0}, 2}, - {Index::key_type{1, 1, 0}, 3}, - {Index::key_type{2, 0, 0}, 4}, - {Index::key_type{2, 1, 0}, 5}, - {Index::key_type{3, 0, 0}, 6}, - {Index::key_type{3, 1, 0}, 7}, - }, - { - {Index::key_type{2, 2, 1}, 8}, - {Index::key_type{2, 2, 2}, 9}, - {Index::key_type{3, 2, 1}, 10}, - {Index::key_type{3, 2, 2}, 11}, - {Index::key_type{4, 2, 1}, 12}, - {Index::key_type{4, 2, 2}, 13}, - {Index::key_type{5, 2, 1}, 14}, - {Index::key_type{5, 2, 2}, 15}, - }, - { - {Index::key_type{3, 0, 0}, 6}, - }, - { - {Index::key_type{3, 2, 2}, 11}, - {Index::key_type{5, 2, 2}, 15}, - }, - } -}; - -const std::array<std::tuple<std::string, size_t>, 4> expectedWatches = -{ + {Index::key_type{0, 0, 0}, 0}, + {Index::key_type{0, 1, 0}, 1}, + {Index::key_type{1, 0, 0}, 2}, + {Index::key_type{1, 1, 0}, 3}, + {Index::key_type{2, 0, 0}, 4}, + {Index::key_type{2, 1, 0}, 5}, + {Index::key_type{3, 0, 0}, 6}, + {Index::key_type{3, 1, 0}, 7}, + }, { - std::tuple<std::string, size_t>{"std::string"s, 0}, - std::tuple<std::string, size_t>{"uint32_t"s, 1}, - std::tuple<std::string, size_t>{"int32_t"s, 2}, - std::tuple<std::string, size_t>{"std::string"s, 3}, - } -}; + {Index::key_type{2, 2, 1}, 8}, + {Index::key_type{2, 2, 2}, 9}, + {Index::key_type{3, 2, 1}, 10}, + {Index::key_type{3, 2, 2}, 11}, + {Index::key_type{4, 2, 1}, 12}, + {Index::key_type{4, 2, 2}, 13}, + {Index::key_type{5, 2, 1}, 14}, + {Index::key_type{5, 2, 2}, 15}, + }, + { + {Index::key_type{3, 0, 0}, 6}, + }, + { + {Index::key_type{3, 2, 2}, 11}, + {Index::key_type{5, 2, 2}, 15}, + }, +}}; + +const std::array<std::tuple<std::string, size_t>, 4> expectedWatches = {{ + std::tuple<std::string, size_t>{"std::string"s, 0}, + std::tuple<std::string, size_t>{"uint32_t"s, 1}, + std::tuple<std::string, size_t>{"int32_t"s, 2}, + std::tuple<std::string, size_t>{"std::string"s, 3}, +}}; TEST(PropertyWatchGenTest, storageCount) { @@ -75,8 +69,7 @@ TEST(PropertyWatchGenTest, WatchesSameContent) size_t i; for (i = 0; i < expectedWatches.size(); ++i) { - ASSERT_EQ(watches[i], - expectedWatches[i]); + ASSERT_EQ(watches[i], expectedWatches[i]); } } @@ -85,7 +78,6 @@ TEST(PropertyWatchGenTest, IndiciesSameContent) size_t i; for (i = 0; i < expectedIndicies.size(); ++i) { - ASSERT_EQ(indices[i], - expectedIndicies[i]); + ASSERT_EQ(indices[i], expectedIndicies[i]); } } diff --git a/src/test/propertywatchtest.cpp b/src/test/propertywatchtest.cpp index c97e8d3..6576bfd 100644 --- a/src/test/propertywatchtest.cpp +++ b/src/test/propertywatchtest.cpp @@ -5,75 +5,56 @@ using namespace std::string_literals; using namespace phosphor::dbus::monitoring; -const std::array<std::string, 4> paths = -{ +const std::array<std::string, 4> paths = { "/xyz/openbmc_project/testing/inst1"s, "/xyz/openbmc_project/testing/inst2"s, "/xyz/openbmc_project/testing/inst3"s, "/xyz/openbmc_project/testing/inst4"s, }; -const std::array<std::string, 2> interfaces = -{ +const std::array<std::string, 2> interfaces = { "xyz.openbmc_project.Iface1"s, "xyz.openbmc_project.Iface2"s, }; -const std::array<std::string, 2> properties = -{ +const std::array<std::string, 2> properties = { "Value1"s, "Value2"s, }; const std::string meta; -std::array<std::tuple<any_ns::any, any_ns::any>, 8> storage = { }; +std::array<std::tuple<any_ns::any, any_ns::any>, 8> storage = {}; -const PropertyIndex watchIndex = -{ +const PropertyIndex watchIndex = { { - { - PropertyIndex::key_type{paths[0], interfaces[0], properties[0]}, - PropertyIndex::mapped_type{meta, meta, storage[0]} - }, - { - PropertyIndex::key_type{paths[0], interfaces[1], properties[1]}, - PropertyIndex::mapped_type{meta, meta, storage[1]} - }, - { - PropertyIndex::key_type{paths[1], interfaces[0], properties[0]}, - PropertyIndex::mapped_type{meta, meta, storage[2]} - }, - { - PropertyIndex::key_type{paths[1], interfaces[1], properties[1]}, - PropertyIndex::mapped_type{meta, meta, storage[3]} - }, - { - PropertyIndex::key_type{paths[2], interfaces[0], properties[0]}, - PropertyIndex::mapped_type{meta, meta, storage[4]} - }, - { - PropertyIndex::key_type{paths[2], interfaces[1], properties[1]}, - PropertyIndex::mapped_type{meta, meta, storage[5]} - }, - { - PropertyIndex::key_type{paths[3], interfaces[0], properties[0]}, - PropertyIndex::mapped_type{meta, meta, storage[6]} - }, - { - PropertyIndex::key_type{paths[3], interfaces[1], properties[1]}, - PropertyIndex::mapped_type{meta, meta, storage[7]} - }, + {PropertyIndex::key_type{paths[0], interfaces[0], properties[0]}, + PropertyIndex::mapped_type{meta, meta, storage[0]}}, + {PropertyIndex::key_type{paths[0], interfaces[1], properties[1]}, + PropertyIndex::mapped_type{meta, meta, storage[1]}}, + {PropertyIndex::key_type{paths[1], interfaces[0], properties[0]}, + PropertyIndex::mapped_type{meta, meta, storage[2]}}, + {PropertyIndex::key_type{paths[1], interfaces[1], properties[1]}, + PropertyIndex::mapped_type{meta, meta, storage[3]}}, + {PropertyIndex::key_type{paths[2], interfaces[0], properties[0]}, + PropertyIndex::mapped_type{meta, meta, storage[4]}}, + {PropertyIndex::key_type{paths[2], interfaces[1], properties[1]}, + PropertyIndex::mapped_type{meta, meta, storage[5]}}, + {PropertyIndex::key_type{paths[3], interfaces[0], properties[0]}, + PropertyIndex::mapped_type{meta, meta, storage[6]}}, + {PropertyIndex::key_type{paths[3], interfaces[1], properties[1]}, + PropertyIndex::mapped_type{meta, meta, storage[7]}}, }, }; -template <typename T> struct ExpectedValues {}; +template <typename T> struct ExpectedValues +{ +}; template <> struct ExpectedValues<uint8_t> { static auto& get(size_t i) { - static const std::array<uint8_t, 8> values = - { + static const std::array<uint8_t, 8> values = { {0, 1, 2, 3, 4, 5, 6, 7}, }; return values[i]; @@ -84,8 +65,7 @@ template <> struct ExpectedValues<uint16_t> { static auto& get(size_t i) { - static const std::array<uint16_t, 8> values = - { + static const std::array<uint16_t, 8> values = { {88, 77, 66, 55, 44, 33, 22, 11}, }; return values[i]; @@ -96,8 +76,7 @@ template <> struct ExpectedValues<uint32_t> { static auto& get(size_t i) { - static const std::array<uint32_t, 8> values = - { + static const std::array<uint32_t, 8> values = { {0xffffffff, 1, 3, 0, 5, 7, 9, 0xffffffff}, }; return values[i]; @@ -108,8 +87,7 @@ template <> struct ExpectedValues<uint64_t> { static auto& get(size_t i) { - static const std::array<uint64_t, 8> values = - { + static const std::array<uint64_t, 8> values = { {0xffffffffffffffff, 3, 7, 12234, 0, 3, 9, 0xffffffff}, }; return values[i]; @@ -120,16 +98,14 @@ template <> struct ExpectedValues<std::string> { static auto& get(size_t i) { - static const std::array<std::string, 8> values = - { + static const std::array<std::string, 8> values = { {""s, "foo"s, "bar"s, "baz"s, "hello"s, "string", "\x2\x3", "\\"}, }; return values[i]; } }; -template <typename T> -void testStart() +template <typename T> void testStart() { using ::testing::Return; using ::testing::_; @@ -146,34 +122,22 @@ void testStart() const auto& path = o.first.get(); const auto& interfaces = o.second; std::vector<std::string> mapperResponse; - std::transform( - interfaces.begin(), - interfaces.end(), - std::back_inserter(mapperResponse), - // *INDENT-OFF* - [](const auto & item) - { - return item.first; - }); + std::transform(interfaces.begin(), interfaces.end(), + std::back_inserter(mapperResponse), + // *INDENT-OFF* + [](const auto& item) { return item.first; }); // *INDENT-ON* + EXPECT_CALL(dbus, mapperGetObject(MAPPER_BUSNAME, MAPPER_PATH, + MAPPER_INTERFACE, "GetObject", path, + expectedMapperInterfaces)) + .WillOnce(Return(GetObject({{"", mapperResponse}}))); EXPECT_CALL( - dbus, - mapperGetObject( - MAPPER_BUSNAME, - MAPPER_PATH, - MAPPER_INTERFACE, - "GetObject", - path, - expectedMapperInterfaces)) - .WillOnce(Return(GetObject({{"", mapperResponse}}))); - EXPECT_CALL( - dbus, - fwdAddMatch( - sdbusplus::bus::match::rules::member("InterfacesAdded") + - sdbusplus::bus::match::rules::path(path) + - sdbusplus::bus::match::rules::interface( - "org.freedesktop.DBus.ObjectManager"), - _)); + dbus, fwdAddMatch( + sdbusplus::bus::match::rules::member("InterfacesAdded") + + sdbusplus::bus::match::rules::path(path) + + sdbusplus::bus::match::rules::interface( + "org.freedesktop.DBus.ObjectManager"), + _)); for (const auto& i : interfaces) { const auto& interface = i.first.get(); @@ -182,10 +146,10 @@ void testStart() dbus, fwdAddMatch( sdbusplus::bus::match::rules::member("PropertiesChanged") + - sdbusplus::bus::match::rules::path(path) + - sdbusplus::bus::match::rules::argN(0, interface) + - sdbusplus::bus::match::rules::interface( - "org.freedesktop.DBus.Properties"), + sdbusplus::bus::match::rules::path(path) + + sdbusplus::bus::match::rules::argN(0, interface) + + sdbusplus::bus::match::rules::interface( + "org.freedesktop.DBus.Properties"), _)); PropertiesChanged<T> serviceResponse; @@ -195,7 +159,7 @@ void testStart() ++ndx; } Expect<T>::getProperties(dbus, path, interface) - .WillOnce(Return(serviceResponse)); + .WillOnce(Return(serviceResponse)); } } diff --git a/src/test/propertywatchtest.hpp b/src/test/propertywatchtest.hpp index f965096..d226f93 100644 --- a/src/test/propertywatchtest.hpp +++ b/src/test/propertywatchtest.hpp @@ -26,19 +26,12 @@ namespace monitoring * * Specialize to implement new forwards. */ -template < - typename DBusInterfaceType, - typename Ret, - typename ...Args > +template <typename DBusInterfaceType, typename Ret, typename... Args> struct CallMethodAndRead { - static Ret op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - Args&& ... args) + static Ret op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, Args&&... args) { static_assert(true, "Missing CallMethodAndRead definition."); return Ret(); @@ -48,253 +41,160 @@ struct CallMethodAndRead /** @brief CallMethodAndRead specialization for * xyz.openbmc_project.ObjectMapper.GetObject. */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - GetObject, - const MapperPath&, - const std::vector<std::string>& > +struct CallMethodAndRead<DBusInterfaceType, GetObject, const MapperPath&, + const std::vector<std::string>&> { - static GetObject op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const MapperPath& objectPath, - const std::vector<std::string>& interfaces) + static GetObject op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const MapperPath& objectPath, + const std::vector<std::string>& interfaces) { - return dbus.mapperGetObject( - busName, - path, - interface, - method, - objectPath, - interfaces); + return dbus.mapperGetObject(busName, path, interface, method, + objectPath, interfaces); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(uint64_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<uint64_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint64_t>, + const std::string&> { - static PropertiesChanged<uint64_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<uint64_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU64( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU64(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(uint32_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<uint32_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint32_t>, + const std::string&> { - static PropertiesChanged<uint32_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<uint32_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU32( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU32(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(uint16_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<uint16_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint16_t>, + const std::string&> { - static PropertiesChanged<uint16_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<uint16_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU16( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU16(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(uint8_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<uint8_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint8_t>, + const std::string&> { - static PropertiesChanged<uint8_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<uint8_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU8( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU8(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(int64_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<int64_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int64_t>, + const std::string&> { - static PropertiesChanged<int64_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<int64_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU64( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU64(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(int32_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<int32_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int32_t>, + const std::string&> { - static PropertiesChanged<int32_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<int32_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU32( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU32(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(int16_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<int16_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int16_t>, + const std::string&> { - static PropertiesChanged<int16_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<int16_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU16( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU16(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(int8_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<int8_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int8_t>, + const std::string&> { - static PropertiesChanged<int8_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<int8_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU8( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU8(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(std::string). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<std::string>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<std::string>, + const std::string&> { - static PropertiesChanged<std::string> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<std::string> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesString( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesString(busName, path, interface, method, + propertiesInterface); } }; @@ -304,102 +204,59 @@ struct CallMethodAndRead < */ struct MockDBusInterface { - MOCK_METHOD6( - mapperGetObject, - GetObject( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const MapperPath&, - const std::vector<std::string>&)); - - MOCK_METHOD5( - getPropertiesU64, - PropertiesChanged<uint64_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesU32, - PropertiesChanged<uint32_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesU16, - PropertiesChanged<uint16_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesU8, - PropertiesChanged<uint8_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesS64, - PropertiesChanged<int64_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesS32, - PropertiesChanged<int32_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesS16, - PropertiesChanged<int16_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesS8, - PropertiesChanged<int8_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesString, - PropertiesChanged<std::string>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD2( - fwdAddMatch, - void( - const std::string&, - const sdbusplus::bus::match::match::callback_t&)); + MOCK_METHOD6(mapperGetObject, + GetObject(const std::string&, const std::string&, + const std::string&, const std::string&, + const MapperPath&, const std::vector<std::string>&)); + + MOCK_METHOD5(getPropertiesU64, + PropertiesChanged<uint64_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesU32, + PropertiesChanged<uint32_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesU16, + PropertiesChanged<uint16_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesU8, + PropertiesChanged<uint8_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesS64, + PropertiesChanged<int64_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesS32, + PropertiesChanged<int32_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesS16, + PropertiesChanged<int16_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesS8, + PropertiesChanged<int8_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesString, + PropertiesChanged<std::string>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD2(fwdAddMatch, + void(const std::string&, + const sdbusplus::bus::match::match::callback_t&)); static MockDBusInterface* ptr; static MockDBusInterface& instance() @@ -412,27 +269,21 @@ struct MockDBusInterface } /** @brief GMock member template/free function forward. */ - template <typename Ret, typename ...Args> - static auto callMethodAndRead( - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - Args&& ... args) + template <typename Ret, typename... Args> + static auto callMethodAndRead(const std::string& busName, + const std::string& path, + const std::string& interface, + const std::string& method, Args&&... args) { - return CallMethodAndRead <MockDBusInterface, Ret, Args... >::op( - instance(), - busName, - path, - interface, - method, - std::forward<Args>(args)...); + return CallMethodAndRead<MockDBusInterface, Ret, Args...>::op( + instance(), busName, path, interface, method, + std::forward<Args>(args)...); } /** @brief GMock free function forward. */ - static auto addMatch( - const std::string& match, - const sdbusplus::bus::match::match::callback_t& callback) + static auto + addMatch(const std::string& match, + const sdbusplus::bus::match::match::callback_t& callback) { instance().fwdAddMatch(match, callback); } @@ -441,185 +292,125 @@ struct MockDBusInterface /** @class Expect * @brief Enable use of EXPECT_CALL from a C++ template. */ -template <typename T> struct Expect {}; +template <typename T> struct Expect +{ +}; -template <> -struct Expect<uint64_t> +template <> struct Expect<uint64_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesU64( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesU64(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<uint32_t> +template <> struct Expect<uint32_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesU32( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesU32(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<uint16_t> +template <> struct Expect<uint16_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesU16( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesU16(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<uint8_t> +template <> struct Expect<uint8_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesU8( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesU8(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<int64_t> +template <> struct Expect<int64_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesS64( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesS64(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<int32_t> +template <> struct Expect<int32_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesS32( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesS32(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<int16_t> +template <> struct Expect<int16_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesS16( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesS16(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<int8_t> +template <> struct Expect<int8_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesS8( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesS8(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<std::string> +template <> struct Expect<std::string> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesString( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + std::forward<MockObjType>(mockObj), + getPropertiesString(::testing::_, path, + "org.freedesktop.DBus.Properties", "GetAll", + interface)); } }; |