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 |
Brad Bishop | 2352088 | 2022-05-26 21:39:53 -0400 | [diff] [blame] | 12 | {}; |
Andrew Geissler | 7f83837 | 2019-02-27 10:14:31 -0600 | [diff] [blame] | 13 | sdbusplus::asio::object_server* |
| 14 | TestInterfacesAdded::AsioServerClassTest::server = nullptr; |
| 15 | |
| 16 | // This is the data structure that comes in via the InterfacesAdded |
| 17 | // signal |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 18 | InterfacesAdded createInterfacesAdded(const std::string& interface, |
| 19 | const std::string& property) |
Andrew Geissler | 7f83837 | 2019-02-27 10:14:31 -0600 | [diff] [blame] | 20 | { |
| 21 | std::vector<Association> associations = { |
| 22 | {"inventory", "error", |
| 23 | "/xyz/openbmc_project/inventory/system/chassis"}}; |
Patrick Williams | 2bb2d6b | 2020-05-13 17:59:02 -0500 | [diff] [blame] | 24 | std::variant<std::vector<Association>> sdbVecAssoc = {associations}; |
| 25 | std::vector<std::pair<std::string, std::variant<std::vector<Association>>>> |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 26 | vecMethToAssoc = {{property, sdbVecAssoc}}; |
| 27 | InterfacesAdded intfAdded = {{interface, vecMethToAssoc}}; |
Andrew Geissler | 7f83837 | 2019-02-27 10:14:31 -0600 | [diff] [blame] | 28 | return intfAdded; |
| 29 | } |
| 30 | |
| 31 | // Verify good path of interfaces added function |
| 32 | TEST_F(TestInterfacesAdded, InterfacesAddedGoodPath) |
| 33 | { |
Matt Spinler | e0b0e3a | 2019-04-08 10:39:23 -0500 | [diff] [blame] | 34 | auto interfaceMap = createDefaultInterfaceMap(); |
Matt Spinler | e2359fb | 2019-04-05 14:11:33 -0500 | [diff] [blame] | 35 | AssociationMaps assocMaps; |
| 36 | |
Patrick Williams | 9052ebd | 2024-08-16 15:22:16 -0400 | [diff] [blame^] | 37 | auto intfAdded = |
| 38 | createInterfacesAdded(assocDefsInterface, assocDefsProperty); |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 39 | |
Kallas, Pawel | 5b4357d | 2022-10-12 15:36:37 +0200 | [diff] [blame] | 40 | boost::asio::io_context io; |
| 41 | |
| 42 | processInterfaceAdded(io, interfaceMap, defaultSourcePath, intfAdded, |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 43 | defaultDbusSvc, assocMaps, *server); |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 44 | |
Kallas, Pawel | 5b4357d | 2022-10-12 15:36:37 +0200 | [diff] [blame] | 45 | io.run(); |
| 46 | |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 47 | // Interface map will get the following: |
Matt Spinler | e0b0e3a | 2019-04-08 10:39:23 -0500 | [diff] [blame] | 48 | // /logging/entry/1 /logging/entry /logging/ / system/chassis |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 49 | // dumpInterfaceMapType(interfaceMap); |
Matt Spinler | e0b0e3a | 2019-04-08 10:39:23 -0500 | [diff] [blame] | 50 | EXPECT_EQ(interfaceMap.size(), 5); |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 51 | |
| 52 | // New association ower created so ensure it now contains a single entry |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 53 | // dumpAssociationOwnersType(assocOwners); |
Matt Spinler | e2359fb | 2019-04-05 14:11:33 -0500 | [diff] [blame] | 54 | EXPECT_EQ(assocMaps.owners.size(), 1); |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 55 | |
| 56 | // Ensure the 2 association interfaces were created |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 57 | // dumpAssociationInterfaces(assocInterfaces); |
Matt Spinler | e2359fb | 2019-04-05 14:11:33 -0500 | [diff] [blame] | 58 | EXPECT_EQ(assocMaps.ifaces.size(), 2); |
Matt Spinler | e0b0e3a | 2019-04-08 10:39:23 -0500 | [diff] [blame] | 59 | |
| 60 | // No pending associations |
| 61 | EXPECT_EQ(assocMaps.pending.size(), 0); |
Matt Spinler | 8f876a5 | 2019-04-15 13:22:50 -0500 | [diff] [blame] | 62 | } |