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