| #include "src/processing.hpp" |
| #include "src/test/util/asio_server_class.hpp" |
| #include "src/test/util/association_objects.hpp" |
| #include "src/test/util/debug_output.hpp" |
| |
| #include <sdbusplus/asio/connection.hpp> |
| #include <sdbusplus/asio/object_server.hpp> |
| |
| #include <gtest/gtest.h> |
| |
| class TestInterfacesAdded : public AsioServerClassTest |
| {}; |
| sdbusplus::asio::object_server* |
| TestInterfacesAdded::AsioServerClassTest::server = nullptr; |
| |
| // This is the data structure that comes in via the InterfacesAdded |
| // signal |
| InterfacesAdded createInterfacesAdded(const std::string& interface, |
| const std::string& property) |
| { |
| std::vector<Association> associations = { |
| {"inventory", "error", |
| "/xyz/openbmc_project/inventory/system/chassis"}}; |
| std::variant<std::vector<Association>> sdbVecAssoc = {associations}; |
| std::vector<std::pair<std::string, std::variant<std::vector<Association>>>> |
| vecMethToAssoc = {{property, sdbVecAssoc}}; |
| InterfacesAdded intfAdded = {{interface, vecMethToAssoc}}; |
| return intfAdded; |
| } |
| |
| // Verify good path of interfaces added function |
| TEST_F(TestInterfacesAdded, InterfacesAddedGoodPath) |
| { |
| auto interfaceMap = createDefaultInterfaceMap(); |
| AssociationMaps assocMaps; |
| |
| auto intfAdded = |
| createInterfacesAdded(assocDefsInterface, assocDefsProperty); |
| |
| processInterfaceAdded(interfaceMap, defaultSourcePath, intfAdded, |
| defaultDbusSvc, assocMaps, *server); |
| |
| // Interface map will get the following: |
| // /logging/entry/1 /logging/entry /logging/ / system/chassis |
| // dumpInterfaceMapType(interfaceMap); |
| EXPECT_EQ(interfaceMap.size(), 5); |
| |
| // New association ower created so ensure it now contains a single entry |
| // dumpAssociationOwnersType(assocOwners); |
| EXPECT_EQ(assocMaps.owners.size(), 1); |
| |
| // Ensure the 2 association interfaces were created |
| // dumpAssociationInterfaces(assocInterfaces); |
| EXPECT_EQ(assocMaps.ifaces.size(), 2); |
| |
| // No pending associations |
| EXPECT_EQ(assocMaps.pending.size(), 0); |
| } |