From 13fd8722e616dd424cd585187fb0ef65f6316023 Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Mon, 15 May 2017 12:44:01 -0400 Subject: Add testcases for property watches Signed-off-by: Brad Bishop Change-Id: I9e9266901414c71a34d9686f2a45bc4764602d53 --- src/test/.gitignore | 3 + src/test/Makefile.am | 43 ++ src/test/propertywatchgentest.cpp | 91 ++++ src/test/propertywatchtest.cpp | 225 ++++++++ src/test/propertywatchtest.hpp | 628 +++++++++++++++++++++++ src/test/templates/propertywatchgentest.mako.hpp | 17 + src/test/yaml/propertywatchgentest/watchone.yaml | 61 +++ src/test/yaml/propertywatchgentest/watchtwo.yaml | 45 ++ 8 files changed, 1113 insertions(+) create mode 100644 src/test/propertywatchgentest.cpp create mode 100644 src/test/propertywatchtest.cpp create mode 100644 src/test/propertywatchtest.hpp create mode 100644 src/test/templates/propertywatchgentest.mako.hpp create mode 100644 src/test/yaml/propertywatchgentest/watchone.yaml create mode 100644 src/test/yaml/propertywatchgentest/watchtwo.yaml (limited to 'src/test') diff --git a/src/test/.gitignore b/src/test/.gitignore index e1da423..c3c7a0c 100644 --- a/src/test/.gitignore +++ b/src/test/.gitignore @@ -4,3 +4,6 @@ /pathgentest.hpp /propertygentest /propertygentest.hpp +/propertywatchtest +/propertywatchgentest.hpp +/propertywatchgentest diff --git a/src/test/Makefile.am b/src/test/Makefile.am index 330bf3e..fe66203 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -7,6 +7,7 @@ gtest_ldadd = -lgtest -lgtest_main -lgmock $(PTHREAD_LIBS) TEMPLATESEARCH+=${srcdir}/templates check_PROGRAMS = +noinst_PROGRAMS = BUILT_SOURCES = CLEANFILES = @@ -61,3 +62,45 @@ propertygentest.hpp: $(PROPERTY_TEST_GEN_DEPS) -d yaml/propertygentest \ -o $(builddir)/$@ \ generate-cpp + +check_PROGRAMS += propertywatchgentest +propertywatchgentest_SOURCES = \ + propertywatchgentest.cpp +propertywatchgentest_CXXFLAGS = \ + $(gtest_cflags) +propertywatchgentest_LDFLAGS = \ + $(OESDK_TESTCASE_FLAGS) +propertywatchgentest_LDADD = \ + ${gtest_ldadd} + +BUILT_SOURCES += propertywatchgentest.hpp +CLEANFILES += propertywatchgentest.hpp + +PROPERTY_WATCH_TEST_GEN_DEPS = \ + templates/propertywatchgentest.mako.hpp \ + yaml/propertywatchgentest + +propertywatchgentest.hpp: $(PROPERTY_WATCH_TEST_GEN_DEPS) + $(AM_V_GEN) $(PYTHON) $(PDMGEN) \ + -t propertywatchgentest.mako.hpp \ + -p "${TEMPLATESEARCH}" \ + -d yaml/propertywatchgentest \ + -o $(builddir)/$@ \ + generate-cpp + +# propertywatchtest is intentionally omitted from +# check_PROGRAMS until a bug that manifests with +# with GCC7 can be resolved. + +noinst_PROGRAMS += propertywatchtest +propertywatchtest_SOURCES = \ + propertywatchtest.cpp +propertywatchtest_CXXFLAGS = \ + $(gtest_cflags) \ + ${SDBUSPLUS_CFLAGS} +propertywatchtest_LDFLAGS = \ + $(OESDK_TESTCASE_FLAGS) +propertywatchtest_LDADD = \ + ${gtest_ldadd} \ + ${SDBUSPLUS_LIBS} \ + $(builddir)/../propertywatch.o diff --git a/src/test/propertywatchgentest.cpp b/src/test/propertywatchgentest.cpp new file mode 100644 index 0000000..afd9dbc --- /dev/null +++ b/src/test/propertywatchgentest.cpp @@ -0,0 +1,91 @@ +#include +#include +#include +#include "data_types.hpp" + +using namespace std::string_literals; +using namespace phosphor::dbus::monitoring; + +using Index = std::map, size_t>; + +#include "propertywatchgentest.hpp" + +auto expectedStorageCount = 16; + +const std::array 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, 4> expectedWatches = +{ + { + std::tuple{"std::string"s, 0}, + std::tuple{"uint32_t"s, 1}, + std::tuple{"int32_t"s, 2}, + std::tuple{"std::string"s, 3}, + } +}; + +TEST(PropertyWatchGenTest, storageCount) +{ + ASSERT_EQ(expectedStorageCount, storageCount); +} + +TEST(PropertyWatchGenTest, IndiciesSameSize) +{ + ASSERT_EQ(sizeof(expectedIndicies), sizeof(indicies)); +} + +TEST(PropertyWatchGenTest, WatchesSameSize) +{ + ASSERT_EQ(sizeof(expectedWatches), sizeof(watches)); +} + +TEST(PropertyWatchGenTest, WatchesSameContent) +{ + size_t i; + for (i = 0; i < expectedWatches.size(); ++i) + { + ASSERT_EQ(watches[i], + expectedWatches[i]); + } +} + +TEST(PropertyWatchGenTest, IndiciesSameContent) +{ + size_t i; + for (i = 0; i < expectedIndicies.size(); ++i) + { + ASSERT_EQ(indicies[i], + expectedIndicies[i]); + } +} diff --git a/src/test/propertywatchtest.cpp b/src/test/propertywatchtest.cpp new file mode 100644 index 0000000..b92dbec --- /dev/null +++ b/src/test/propertywatchtest.cpp @@ -0,0 +1,225 @@ +#include +#include "propertywatchimpl.hpp" +#include "propertywatchtest.hpp" + +using namespace std::string_literals; +using namespace phosphor::dbus::monitoring; + +const std::array 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 interfaces = +{ + "xyz.openbmc_project.Iface1"s, + "xyz.openbmc_project.Iface2"s, +}; + +const std::array properties = +{ + "Value1"s, + "Value2"s, +}; + +const std::string meta; + +std::array storage = { }; + +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]} + }, + }, +}; + +template struct ExpectedValues {}; +template <> struct ExpectedValues +{ + static auto& get(size_t i) + { + static const std::array values = + { + {0, 1, 2, 3, 4, 5, 6, 7}, + }; + return values[i]; + } +}; + +template <> struct ExpectedValues +{ + static auto& get(size_t i) + { + static const std::array values = + { + {88, 77, 66, 55, 44, 33, 22, 11}, + }; + return values[i]; + } +}; + +template <> struct ExpectedValues +{ + static auto& get(size_t i) + { + static const std::array values = + { + {0xffffffff, 1, 3, 0, 5, 7, 9, 0xffffffff}, + }; + return values[i]; + } +}; + +template <> struct ExpectedValues +{ + static auto& get(size_t i) + { + static const std::array values = + { + {0xffffffffffffffff, 3, 7, 12234, 0, 3, 9, 0xffffffff}, + }; + return values[i]; + } +}; + +template <> struct ExpectedValues +{ + static auto& get(size_t i) + { + static const std::array values = + { + {""s, "foo"s, "bar"s, "baz"s, "hello"s, "string", "\x2\x3", "\\"}, + }; + return values[i]; + } +}; + +template +void testStart() +{ + using ::testing::Return; + using ::testing::_; + + MockDBusInterface dbus; + MockDBusInterface::instance(dbus); + + const std::vector expectedMapperInterfaces; + PropertyWatchOfType watch(watchIndex); + + auto ndx = static_cast(0); + for (const auto& o : convert(watchIndex)) + { + const auto& path = o.first.get(); + const auto& interfaces = o.second; + std::vector mapperResponse; + 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, + 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(); + const auto& properties = i.second; + EXPECT_CALL( + 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"), + _)); + + PropertiesChanged serviceResponse; + for (const auto& p : properties) + { + serviceResponse[p] = ExpectedValues::get(ndx); + ++ndx; + } + Expect::getProperties(dbus, path, interface) + .WillOnce(Return(serviceResponse)); + } + } + + watch.start(); + + ndx = 0; + for (auto s : storage) + { + ASSERT_EQ(s.empty(), false); + ASSERT_EQ(any_ns::any_cast(s), ExpectedValues::get(ndx)); + ++ndx; + } + + // Make sure start logic only runs the first time. + watch.start(); +} + +TEST(PropertyWatchTest, TestStart) +{ + testStart(); + testStart(); + testStart(); + testStart(); + testStart(); +} + +MockDBusInterface* MockDBusInterface::ptr = nullptr; diff --git a/src/test/propertywatchtest.hpp b/src/test/propertywatchtest.hpp new file mode 100644 index 0000000..f965096 --- /dev/null +++ b/src/test/propertywatchtest.hpp @@ -0,0 +1,628 @@ +#pragma once +#include +#include +#include + +#include "data_types.hpp" +#include "sdbusplus/bus/match.hpp" + +namespace phosphor +{ +namespace dbus +{ +namespace monitoring +{ + +/** @class CallMethodAndRead + * @brief GMock template member forwarding helper. + * + * The code under test calls callMethodAndRead, which is a templated, + * free function. Enable this under GMock by forwarding calls to it + * to functions that can be mocked. + * + * @tparam DBusInterfaceType - The mock object type. + * @tparam Ret - The return type of the method being called. + * @tparam Args - The argument types of the method being called. + * + * Specialize to implement new forwards. + */ +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_assert(true, "Missing CallMethodAndRead definition."); + return Ret(); + } +}; + +/** @brief CallMethodAndRead specialization for + * xyz.openbmc_project.ObjectMapper.GetObject. */ +template +struct CallMethodAndRead < + DBusInterfaceType, + GetObject, + const MapperPath&, + const std::vector& > +{ + 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& interfaces) + { + return dbus.mapperGetObject( + busName, + path, + interface, + method, + objectPath, + interfaces); + } +}; + +/** @brief CallMethodAndRead specialization for + * org.freedesktop.DBus.Properties.GetAll(uint64_t). */ +template +struct CallMethodAndRead < + DBusInterfaceType, + PropertiesChanged, + const std::string& > +{ + static PropertiesChanged 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); + } +}; + +/** @brief CallMethodAndRead specialization for + * org.freedesktop.DBus.Properties.GetAll(uint32_t). */ +template +struct CallMethodAndRead < + DBusInterfaceType, + PropertiesChanged, + const std::string& > +{ + static PropertiesChanged 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); + } +}; + +/** @brief CallMethodAndRead specialization for + * org.freedesktop.DBus.Properties.GetAll(uint16_t). */ +template +struct CallMethodAndRead < + DBusInterfaceType, + PropertiesChanged, + const std::string& > +{ + static PropertiesChanged 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); + } +}; + +/** @brief CallMethodAndRead specialization for + * org.freedesktop.DBus.Properties.GetAll(uint8_t). */ +template +struct CallMethodAndRead < + DBusInterfaceType, + PropertiesChanged, + const std::string& > +{ + static PropertiesChanged 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); + } +}; + +/** @brief CallMethodAndRead specialization for + * org.freedesktop.DBus.Properties.GetAll(int64_t). */ +template +struct CallMethodAndRead < + DBusInterfaceType, + PropertiesChanged, + const std::string& > +{ + static PropertiesChanged 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); + } +}; + +/** @brief CallMethodAndRead specialization for + * org.freedesktop.DBus.Properties.GetAll(int32_t). */ +template +struct CallMethodAndRead < + DBusInterfaceType, + PropertiesChanged, + const std::string& > +{ + static PropertiesChanged 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); + } +}; + +/** @brief CallMethodAndRead specialization for + * org.freedesktop.DBus.Properties.GetAll(int16_t). */ +template +struct CallMethodAndRead < + DBusInterfaceType, + PropertiesChanged, + const std::string& > +{ + static PropertiesChanged 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); + } +}; + +/** @brief CallMethodAndRead specialization for + * org.freedesktop.DBus.Properties.GetAll(int8_t). */ +template +struct CallMethodAndRead < + DBusInterfaceType, + PropertiesChanged, + const std::string& > +{ + static PropertiesChanged 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); + } +}; + +/** @brief CallMethodAndRead specialization for + * org.freedesktop.DBus.Properties.GetAll(std::string). */ +template +struct CallMethodAndRead < + DBusInterfaceType, + PropertiesChanged, + const std::string& > +{ + static PropertiesChanged 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); + } +}; + +/** @class MockDBusInterface + * @brief DBus access delegate implementation for the property watch test + * suite. + */ +struct MockDBusInterface +{ + MOCK_METHOD6( + mapperGetObject, + GetObject( + const std::string&, + const std::string&, + const std::string&, + const std::string&, + const MapperPath&, + const std::vector&)); + + MOCK_METHOD5( + getPropertiesU64, + PropertiesChanged( + const std::string&, + const std::string&, + const std::string&, + const std::string&, + const std::string&)); + + MOCK_METHOD5( + getPropertiesU32, + PropertiesChanged( + const std::string&, + const std::string&, + const std::string&, + const std::string&, + const std::string&)); + + MOCK_METHOD5( + getPropertiesU16, + PropertiesChanged( + const std::string&, + const std::string&, + const std::string&, + const std::string&, + const std::string&)); + + MOCK_METHOD5( + getPropertiesU8, + PropertiesChanged( + const std::string&, + const std::string&, + const std::string&, + const std::string&, + const std::string&)); + + MOCK_METHOD5( + getPropertiesS64, + PropertiesChanged( + const std::string&, + const std::string&, + const std::string&, + const std::string&, + const std::string&)); + + MOCK_METHOD5( + getPropertiesS32, + PropertiesChanged( + const std::string&, + const std::string&, + const std::string&, + const std::string&, + const std::string&)); + + MOCK_METHOD5( + getPropertiesS16, + PropertiesChanged( + const std::string&, + const std::string&, + const std::string&, + const std::string&, + const std::string&)); + + MOCK_METHOD5( + getPropertiesS8, + PropertiesChanged( + const std::string&, + const std::string&, + const std::string&, + const std::string&, + const std::string&)); + + MOCK_METHOD5( + getPropertiesString, + PropertiesChanged( + 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() + { + return *ptr; + } + static void instance(MockDBusInterface& p) + { + ptr = &p; + } + + /** @brief GMock member template/free function forward. */ + template + static auto callMethodAndRead( + const std::string& busName, + const std::string& path, + const std::string& interface, + const std::string& method, + Args&& ... args) + { + return CallMethodAndRead ::op( + instance(), + busName, + path, + interface, + method, + std::forward(args)...); + } + + /** @brief GMock free function forward. */ + static auto addMatch( + const std::string& match, + const sdbusplus::bus::match::match::callback_t& callback) + { + instance().fwdAddMatch(match, callback); + } +}; + +/** @class Expect + * @brief Enable use of EXPECT_CALL from a C++ template. + */ +template struct Expect {}; + +template <> +struct Expect +{ + template + static auto& getProperties( + MockObjType&& mockObj, + const std::string& path, + const std::string& interface) + { + return EXPECT_CALL( + std::forward(mockObj), + getPropertiesU64( + ::testing::_, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + interface)); + } +}; + +template <> +struct Expect +{ + template + static auto& getProperties( + MockObjType&& mockObj, + const std::string& path, + const std::string& interface) + { + return EXPECT_CALL( + std::forward(mockObj), + getPropertiesU32( + ::testing::_, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + interface)); + } +}; + +template <> +struct Expect +{ + template + static auto& getProperties( + MockObjType&& mockObj, + const std::string& path, + const std::string& interface) + { + return EXPECT_CALL( + std::forward(mockObj), + getPropertiesU16( + ::testing::_, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + interface)); + } +}; + +template <> +struct Expect +{ + template + static auto& getProperties( + MockObjType&& mockObj, + const std::string& path, + const std::string& interface) + { + return EXPECT_CALL( + std::forward(mockObj), + getPropertiesU8( + ::testing::_, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + interface)); + } +}; + +template <> +struct Expect +{ + template + static auto& getProperties( + MockObjType&& mockObj, + const std::string& path, + const std::string& interface) + { + return EXPECT_CALL( + std::forward(mockObj), + getPropertiesS64( + ::testing::_, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + interface)); + } +}; + +template <> +struct Expect +{ + template + static auto& getProperties( + MockObjType&& mockObj, + const std::string& path, + const std::string& interface) + { + return EXPECT_CALL( + std::forward(mockObj), + getPropertiesS32( + ::testing::_, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + interface)); + } +}; + +template <> +struct Expect +{ + template + static auto& getProperties( + MockObjType&& mockObj, + const std::string& path, + const std::string& interface) + { + return EXPECT_CALL( + std::forward(mockObj), + getPropertiesS16( + ::testing::_, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + interface)); + } +}; + +template <> +struct Expect +{ + template + static auto& getProperties( + MockObjType&& mockObj, + const std::string& path, + const std::string& interface) + { + return EXPECT_CALL( + std::forward(mockObj), + getPropertiesS8( + ::testing::_, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + interface)); + } +}; + +template <> +struct Expect +{ + template + static auto& getProperties( + MockObjType&& mockObj, + const std::string& path, + const std::string& interface) + { + return EXPECT_CALL( + std::forward(mockObj), + getPropertiesString( + ::testing::_, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + interface)); + } +}; + +} // namespace monitoring +} // namespace dbus +} // namespace phosphor diff --git a/src/test/templates/propertywatchgentest.mako.hpp b/src/test/templates/propertywatchgentest.mako.hpp new file mode 100644 index 0000000..ac4dbee --- /dev/null +++ b/src/test/templates/propertywatchgentest.mako.hpp @@ -0,0 +1,17 @@ +auto storageCount = ${len(instances)}; + +const std::array indicies = {{ +% for g in instancegroups: + { + % for i in g.members: + {Index::key_type{${i[0]}, ${i[2]}, ${i[3]}}, ${i[5]}}, + % endfor + }, +% endfor +}}; + +const std::array, ${len(watches)}> watches = {{ +% for w in watches: + std::tuple{"${w.datatype}", ${w.instances}}, +% endfor +}}; diff --git a/src/test/yaml/propertywatchgentest/watchone.yaml b/src/test/yaml/propertywatchgentest/watchone.yaml new file mode 100644 index 0000000..bea2b09 --- /dev/null +++ b/src/test/yaml/propertywatchgentest/watchone.yaml @@ -0,0 +1,61 @@ +- name: test path group 1 + class: group + group: path + members: + - meta: path + path: /xyz/openbmc_project/testing/inst1 + - meta: path + path: /xyz/openbmc_project/testing/inst2 + - meta: path + path: /xyz/openbmc_project/testing/inst3 + - meta: path + path: /xyz/openbmc_project/testing/inst4 + +- name: test path group 2 + class: group + group: path + members: + - meta: path + path: /xyz/openbmc_project/testing/inst3 + - meta: path + path: /xyz/openbmc_project/testing/inst4 + - meta: path + path: /xyz/openbmc_project/testing/inst5 + - meta: path + path: /xyz/openbmc_project/testing/inst6 + +- name: test property group 1 + class: group + group: property + type: string + members: + - interface: xyz.openbmc_project.Sensor.Iface1 + meta: property + property: Value + - interface: xyz.openbmc_project.Sensor.Iface2 + meta: property + property: Value + +- name: test property group 2 + class: group + group: property + type: uint32 + members: + - interface: xyz.openbmc_project.Sensor.Iface3 + meta: property + property: Value1 + - interface: xyz.openbmc_project.Sensor.Iface3 + meta: property + property: Value2 + +- name: test property watch 1 + class: watch + watch: property + paths: test path group 1 + properties: test property group 1 + +- name: test property watch 2 + class: watch + watch: property + paths: test path group 2 + properties: test property group 2 diff --git a/src/test/yaml/propertywatchgentest/watchtwo.yaml b/src/test/yaml/propertywatchgentest/watchtwo.yaml new file mode 100644 index 0000000..0f5ebdc --- /dev/null +++ b/src/test/yaml/propertywatchgentest/watchtwo.yaml @@ -0,0 +1,45 @@ +- name: test path group 1 + class: group + group: path + members: + - meta: path + path: /xyz/openbmc_project/testing/inst4 + +- name: test path group 3 + class: group + group: path + members: + - meta: path + path: /xyz/openbmc_project/testing/inst4 + - meta: path + path: /xyz/openbmc_project/testing/inst6 + +- name: test property group 1 + class: group + group: property + type: int32 + members: + - interface: xyz.openbmc_project.Sensor.Iface1 + meta: property + property: Value + +- name: test property group 3 + class: group + group: property + type: string + members: + - interface: xyz.openbmc_project.Sensor.Iface3 + meta: property + property: Value2 + +- name: test property watch 1 + class: watch + watch: property + paths: test path group 1 + properties: test property group 1 + +- name: test property watch 3 + class: watch + watch: property + paths: test path group 3 + properties: test property group 3 -- cgit v1.2.1