Andrew Geissler | 7f83837 | 2019-02-27 10:14:31 -0600 | [diff] [blame] | 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 |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 19 | InterfacesAdded createInterfacesAdded(const std::string& interface, |
| 20 | const std::string& property) |
Andrew Geissler | 7f83837 | 2019-02-27 10:14:31 -0600 | [diff] [blame] | 21 | { |
| 22 | std::vector<Association> associations = { |
| 23 | {"inventory", "error", |
| 24 | "/xyz/openbmc_project/inventory/system/chassis"}}; |
Patrick Williams | 2bb2d6b | 2020-05-13 17:59:02 -0500 | [diff] [blame] | 25 | std::variant<std::vector<Association>> sdbVecAssoc = {associations}; |
| 26 | std::vector<std::pair<std::string, std::variant<std::vector<Association>>>> |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 27 | vecMethToAssoc = {{property, sdbVecAssoc}}; |
| 28 | InterfacesAdded intfAdded = {{interface, vecMethToAssoc}}; |
Andrew Geissler | 7f83837 | 2019-02-27 10:14:31 -0600 | [diff] [blame] | 29 | return intfAdded; |
| 30 | } |
| 31 | |
| 32 | // Verify good path of interfaces added function |
| 33 | TEST_F(TestInterfacesAdded, InterfacesAddedGoodPath) |
| 34 | { |
Matt Spinler | e0b0e3a | 2019-04-08 10:39:23 -0500 | [diff] [blame] | 35 | auto interfaceMap = createDefaultInterfaceMap(); |
Matt Spinler | e2359fb | 2019-04-05 14:11:33 -0500 | [diff] [blame] | 36 | AssociationMaps assocMaps; |
| 37 | |
John Wang | d0cf942 | 2019-09-17 16:01:34 +0800 | [diff] [blame] | 38 | auto intfAdded = |
| 39 | createInterfacesAdded(assocDefsInterface, assocDefsProperty); |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 40 | |
| 41 | processInterfaceAdded(interfaceMap, DEFAULT_SOURCE_PATH, intfAdded, |
Matt Spinler | e2359fb | 2019-04-05 14:11:33 -0500 | [diff] [blame] | 42 | DEFAULT_DBUS_SVC, assocMaps, *server); |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 43 | |
| 44 | // Interface map will get the following: |
Matt Spinler | e0b0e3a | 2019-04-08 10:39:23 -0500 | [diff] [blame] | 45 | // /logging/entry/1 /logging/entry /logging/ / system/chassis |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 46 | // dump_InterfaceMapType(interfaceMap); |
Matt Spinler | e0b0e3a | 2019-04-08 10:39:23 -0500 | [diff] [blame] | 47 | EXPECT_EQ(interfaceMap.size(), 5); |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 48 | |
| 49 | // New association ower created so ensure it now contains a single entry |
| 50 | // dump_AssociationOwnersType(assocOwners); |
Matt Spinler | e2359fb | 2019-04-05 14:11:33 -0500 | [diff] [blame] | 51 | EXPECT_EQ(assocMaps.owners.size(), 1); |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 52 | |
| 53 | // Ensure the 2 association interfaces were created |
| 54 | // dump_AssociationInterfaces(assocInterfaces); |
Matt Spinler | e2359fb | 2019-04-05 14:11:33 -0500 | [diff] [blame] | 55 | EXPECT_EQ(assocMaps.ifaces.size(), 2); |
Matt Spinler | e0b0e3a | 2019-04-08 10:39:23 -0500 | [diff] [blame] | 56 | |
| 57 | // No pending associations |
| 58 | EXPECT_EQ(assocMaps.pending.size(), 0); |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 59 | } |