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 | |
William A. Kennington III | dd9ef81 | 2022-10-05 02:08:02 -0700 | [diff] [blame] | 16 | class MockManager : public Manager |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 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) : |
William A. Kennington III | dd9ef81 | 2022-10-05 02:08:02 -0700 | [diff] [blame] | 21 | Manager(bus, path, dir) |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 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(); |
William A. Kennington III | 9644479 | 2022-10-05 15:16:22 -0700 | [diff] [blame] | 29 | auto interfaceStrList = getSystemInterfaces(); |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 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)); |
William A. Kennington III | dd9ef81 | 2022-10-05 02:08:02 -0700 | [diff] [blame] | 36 | auto intf = std::make_unique<MockEthernetInterface>( |
| 37 | bus, objPath.string(), config, *this, true); |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 38 | intf->createIPAddressObjects(); |
| 39 | intf->createStaticNeighborObjects(); |
William A. Kennington III | a520a39 | 2022-08-08 12:17:34 -0700 | [diff] [blame] | 40 | intf->loadNameServers(config); |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 41 | this->interfaces.emplace( |
| 42 | std::make_pair(std::move(interface), std::move(intf))); |
| 43 | } |
| 44 | } |
William A. Kennington III | 4717d93 | 2021-10-08 18:28:23 -0700 | [diff] [blame] | 45 | |
William A. Kennington III | 56ecc78 | 2021-10-07 18:44:50 -0700 | [diff] [blame] | 46 | MOCK_METHOD(void, reloadConfigs, (), (override)); |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | } // namespace network |
| 50 | } // namespace phosphor |