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 | { |
| 28 | // clear all the interfaces first |
| 29 | interfaces.clear(); |
William A. Kennington III | 2e09d27 | 2022-10-14 17:15:00 -0700 | [diff] [blame] | 30 | auto interfaceStrList = system::getInterfaces(); |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 31 | for (auto& interface : interfaceStrList) |
| 32 | { |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 33 | // normal ethernet interface |
William A. Kennington III | a520a39 | 2022-08-08 12:17:34 -0700 | [diff] [blame] | 34 | config::Parser config(config::pathForIntfConf(confDir, interface)); |
William A. Kennington III | dd9ef81 | 2022-10-05 02:08:02 -0700 | [diff] [blame] | 35 | auto intf = std::make_unique<MockEthernetInterface>( |
William A. Kennington III | d298f93 | 2022-10-17 14:31:38 -0700 | [diff] [blame] | 36 | bus, *this, getInterfaceInfo(interface), objectPath, config); |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 37 | intf->createIPAddressObjects(); |
| 38 | intf->createStaticNeighborObjects(); |
William A. Kennington III | a520a39 | 2022-08-08 12:17:34 -0700 | [diff] [blame] | 39 | intf->loadNameServers(config); |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 40 | this->interfaces.emplace( |
| 41 | std::make_pair(std::move(interface), std::move(intf))); |
| 42 | } |
| 43 | } |
William A. Kennington III | 4717d93 | 2021-10-08 18:28:23 -0700 | [diff] [blame] | 44 | |
William A. Kennington III | 56ecc78 | 2021-10-07 18:44:50 -0700 | [diff] [blame] | 45 | MOCK_METHOD(void, reloadConfigs, (), (override)); |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | } // namespace network |
| 49 | } // namespace phosphor |