1 #include "src/processing.hpp" 2 #include "src/test/util/asio_server_class.hpp" 3 #include "src/test/util/association_objects.hpp" 4 #include "src/test/util/debug_output.hpp" 5 6 #include <sdbusplus/asio/connection.hpp> 7 #include <sdbusplus/asio/object_server.hpp> 8 9 #include <gtest/gtest.h> 10 11 class TestInterfacesAdded : public AsioServerClassTest 12 { 13 }; 14 sdbusplus::asio::object_server* 15 TestInterfacesAdded::AsioServerClassTest::server = nullptr; 16 17 // This is the data structure that comes in via the InterfacesAdded 18 // signal 19 InterfacesAdded createInterfacesAdded() 20 { 21 std::vector<Association> associations = { 22 {"inventory", "error", 23 "/xyz/openbmc_project/inventory/system/chassis"}}; 24 sdbusplus::message::variant<std::vector<Association>> sdbVecAssoc = { 25 associations}; 26 std::vector<std::pair< 27 std::string, sdbusplus::message::variant<std::vector<Association>>>> 28 vecMethToAssoc = {{"associations", sdbVecAssoc}}; 29 InterfacesAdded intfAdded = {{ASSOCIATIONS_INTERFACE, vecMethToAssoc}}; 30 return intfAdded; 31 } 32 33 // Verify good path of interfaces added function 34 TEST_F(TestInterfacesAdded, InterfacesAddedGoodPath) 35 { 36 interface_map_type interfaceMap; 37 AssociationOwnersType assocOwners; 38 AssociationInterfaces assocInterfaces; 39 auto intfAdded = createInterfacesAdded(); 40 41 processInterfaceAdded(interfaceMap, DEFAULT_SOURCE_PATH, intfAdded, 42 DEFAULT_DBUS_SVC, assocOwners, assocInterfaces, 43 *server); 44 45 // Interface map will get the following: 46 // /logging/entry/1 /logging/entry /logging/ / 47 // dump_InterfaceMapType(interfaceMap); 48 EXPECT_EQ(interfaceMap.size(), 4); 49 50 // New association ower created so ensure it now contains a single entry 51 // dump_AssociationOwnersType(assocOwners); 52 EXPECT_EQ(assocOwners.size(), 1); 53 54 // Ensure the 2 association interfaces were created 55 // dump_AssociationInterfaces(assocInterfaces); 56 EXPECT_EQ(assocInterfaces.size(), 2); 57 } 58