Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 1 | #pragma once |
William A. Kennington III | 9ecb90e | 2022-10-14 03:12:43 -0700 | [diff] [blame] | 2 | #include "config_parser.hpp" |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 3 | #include "mock_ethernet_interface.hpp" |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 4 | #include "network_manager.hpp" |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 5 | #include "system_queries.hpp" |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 6 | |
| 7 | #include <gmock/gmock.h> |
| 8 | |
| 9 | namespace phosphor |
| 10 | { |
| 11 | namespace network |
| 12 | { |
| 13 | |
Manojkiran Eda | 1b5ec9c | 2020-06-13 15:29:28 +0530 | [diff] [blame] | 14 | void initializeTimers(); |
| 15 | void refreshObjects(); |
| 16 | |
William A. Kennington III | dd9ef81 | 2022-10-05 02:08:02 -0700 | [diff] [blame] | 17 | class MockManager : public Manager |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 18 | { |
| 19 | public: |
Patrick Williams | c38b071 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 20 | MockManager(sdbusplus::bus_t& bus, const char* path, |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 21 | const std::string& dir) : |
William A. Kennington III | dd9ef81 | 2022-10-05 02:08:02 -0700 | [diff] [blame] | 22 | Manager(bus, path, dir) |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 23 | { |
| 24 | } |
| 25 | |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 26 | void createInterfaces() override |
| 27 | { |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 28 | interfaces.clear(); |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 29 | for (auto& interface : system::getInterfaces()) |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 30 | { |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 31 | config::Parser config( |
| 32 | config::pathForIntfConf(confDir, *interface.name)); |
William A. Kennington III | dd9ef81 | 2022-10-05 02:08:02 -0700 | [diff] [blame] | 33 | auto intf = std::make_unique<MockEthernetInterface>( |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 34 | bus, *this, interface, objectPath, config); |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 35 | intf->createIPAddressObjects(); |
| 36 | intf->createStaticNeighborObjects(); |
William A. Kennington III | a520a39 | 2022-08-08 12:17:34 -0700 | [diff] [blame] | 37 | intf->loadNameServers(config); |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 38 | this->interfaces.emplace( |
William A. Kennington III | fd862be | 2022-10-09 18:40:55 -0700 | [diff] [blame] | 39 | std::make_pair(std::move(*interface.name), std::move(intf))); |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 40 | } |
| 41 | } |
William A. Kennington III | 4717d93 | 2021-10-08 18:28:23 -0700 | [diff] [blame] | 42 | |
William A. Kennington III | 56ecc78 | 2021-10-07 18:44:50 -0700 | [diff] [blame] | 43 | MOCK_METHOD(void, reloadConfigs, (), (override)); |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | } // namespace network |
| 47 | } // namespace phosphor |