diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2019-02-08 14:16:48 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2019-04-05 15:05:32 +0000 |
commit | bb7b592eb7818554f27fc99dbe3fe76cb4a116a5 (patch) | |
tree | b50ecdb0b34953268aab835b7217d21491448125 /src | |
parent | b04f0335379773c87ed0f8cb259ea37cef80981b (diff) | |
download | phosphor-objmgr-bb7b592eb7818554f27fc99dbe3fe76cb4a116a5.tar.gz phosphor-objmgr-bb7b592eb7818554f27fc99dbe3fe76cb4a116a5.zip |
unit-test: Move association create funcs to util
These will be useful in other test suites so move into util directory
Change-Id: Ibea5c417e38210e6e1388cf4492af10a64db9077
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/test/associations.cpp | 47 | ||||
-rw-r--r-- | src/test/util/association_objects.hpp | 47 |
2 files changed, 48 insertions, 46 deletions
diff --git a/src/test/associations.cpp b/src/test/associations.cpp index acfa884..8edb0de 100644 --- a/src/test/associations.cpp +++ b/src/test/associations.cpp @@ -1,6 +1,7 @@ #include "src/associations.hpp" #include "src/test/util/asio_server_class.hpp" +#include "src/test/util/association_objects.hpp" #include <sdbusplus/asio/connection.hpp> #include <sdbusplus/asio/object_server.hpp> @@ -13,52 +14,6 @@ class TestAssociations : public AsioServerClassTest sdbusplus::asio::object_server* TestAssociations::AsioServerClassTest::server = nullptr; -const std::string DEFAULT_SOURCE_PATH = "/logging/entry/1"; -const std::string DEFAULT_DBUS_SVC = "xyz.openbmc_project.New.Interface"; -const std::string DEFAULT_FWD_PATH = {DEFAULT_SOURCE_PATH + "/" + "inventory"}; -const std::string DEFAULT_ENDPOINT = - "/xyz/openbmc_project/inventory/system/chassis"; -const std::string DEFAULT_REV_PATH = {DEFAULT_ENDPOINT + "/" + "error"}; -const std::string EXTRA_ENDPOINT = "/xyz/openbmc_project/differnt/endpoint"; - -// Create a default AssociationOwnersType object -AssociationOwnersType createDefaultOwnerAssociation() -{ - AssociationPaths assocPathMap = {{DEFAULT_FWD_PATH, {DEFAULT_ENDPOINT}}, - {DEFAULT_REV_PATH, {DEFAULT_SOURCE_PATH}}}; - boost::container::flat_map<std::string, AssociationPaths> serviceMap = { - {DEFAULT_DBUS_SVC, assocPathMap}}; - AssociationOwnersType ownerAssoc = {{DEFAULT_SOURCE_PATH, serviceMap}}; - return ownerAssoc; -} - -// Create a default AssociationInterfaces object -AssociationInterfaces - createDefaultInterfaceAssociation(sdbusplus::asio::object_server* server) -{ - AssociationInterfaces interfaceAssoc; - - auto& iface = interfaceAssoc[DEFAULT_FWD_PATH]; - auto& endpoints = std::get<endpointsPos>(iface); - endpoints.push_back(DEFAULT_ENDPOINT); - server->add_interface(DEFAULT_FWD_PATH, DEFAULT_DBUS_SVC); - - auto& iface2 = interfaceAssoc[DEFAULT_REV_PATH]; - auto& endpoints2 = std::get<endpointsPos>(iface2); - endpoints2.push_back(DEFAULT_SOURCE_PATH); - server->add_interface(DEFAULT_REV_PATH, DEFAULT_DBUS_SVC); - - return interfaceAssoc; -} - -// Just add an extra endpoint to the first association -void addEndpointToInterfaceAssociation(AssociationInterfaces& interfaceAssoc) -{ - auto iface = interfaceAssoc[DEFAULT_FWD_PATH]; - auto endpoints = std::get<endpointsPos>(iface); - endpoints.push_back(EXTRA_ENDPOINT); -} - // Verify call when path is not in associated owners TEST_F(TestAssociations, SourcePathNotInAssociations) { diff --git a/src/test/util/association_objects.hpp b/src/test/util/association_objects.hpp new file mode 100644 index 0000000..081f891 --- /dev/null +++ b/src/test/util/association_objects.hpp @@ -0,0 +1,47 @@ +#include "src/associations.hpp" + +const std::string DEFAULT_SOURCE_PATH = "/logging/entry/1"; +const std::string DEFAULT_DBUS_SVC = "xyz.openbmc_project.New.Interface"; +const std::string DEFAULT_FWD_PATH = {DEFAULT_SOURCE_PATH + "/" + "inventory"}; +const std::string DEFAULT_ENDPOINT = + "/xyz/openbmc_project/inventory/system/chassis"; +const std::string DEFAULT_REV_PATH = {DEFAULT_ENDPOINT + "/" + "error"}; +const std::string EXTRA_ENDPOINT = "/xyz/openbmc_project/differnt/endpoint"; + +// Create a default AssociationOwnersType object +AssociationOwnersType createDefaultOwnerAssociation() +{ + AssociationPaths assocPathMap = {{DEFAULT_FWD_PATH, {DEFAULT_ENDPOINT}}, + {DEFAULT_REV_PATH, {DEFAULT_SOURCE_PATH}}}; + boost::container::flat_map<std::string, AssociationPaths> serviceMap = { + {DEFAULT_DBUS_SVC, assocPathMap}}; + AssociationOwnersType ownerAssoc = {{DEFAULT_SOURCE_PATH, serviceMap}}; + return ownerAssoc; +} + +// Create a default AssociationInterfaces object +AssociationInterfaces + createDefaultInterfaceAssociation(sdbusplus::asio::object_server* server) +{ + AssociationInterfaces interfaceAssoc; + + auto& iface = interfaceAssoc[DEFAULT_FWD_PATH]; + auto& endpoints = std::get<endpointsPos>(iface); + endpoints.push_back(DEFAULT_ENDPOINT); + server->add_interface(DEFAULT_FWD_PATH, DEFAULT_DBUS_SVC); + + auto& iface2 = interfaceAssoc[DEFAULT_REV_PATH]; + auto& endpoints2 = std::get<endpointsPos>(iface2); + endpoints2.push_back(DEFAULT_SOURCE_PATH); + server->add_interface(DEFAULT_REV_PATH, DEFAULT_DBUS_SVC); + + return interfaceAssoc; +} + +// Just add an extra endpoint to the first association +void addEndpointToInterfaceAssociation(AssociationInterfaces& interfaceAssoc) +{ + auto iface = interfaceAssoc[DEFAULT_FWD_PATH]; + auto endpoints = std::get<endpointsPos>(iface); + endpoints.push_back(EXTRA_ENDPOINT); +} |