blob: 337af88c478e6430278826f6158188d376b013d3 [file] [log] [blame]
Manojkiran Edaacd6dd52019-10-15 15:00:51 +05301#pragma once
Manojkiran Edaacd6dd52019-10-15 15:00:51 +05302#include "mock_ethernet_interface.hpp"
Ratan Gupta35297172018-11-28 18:40:16 +05303#include "network_manager.hpp"
William A. Kennington III95530ec2022-08-19 01:44:39 -07004#include "util.hpp"
Ratan Gupta35297172018-11-28 18:40:16 +05305
6#include <gmock/gmock.h>
7
8namespace phosphor
9{
10namespace network
11{
12
Manojkiran Eda1b5ec9c2020-06-13 15:29:28 +053013void initializeTimers();
14void refreshObjects();
15
Ratan Gupta35297172018-11-28 18:40:16 +053016class MockManager : public phosphor::network::Manager
17{
18 public:
Patrick Williamsc38b0712022-07-22 19:26:54 -050019 MockManager(sdbusplus::bus_t& bus, const char* path,
Ratan Gupta35297172018-11-28 18:40:16 +053020 const std::string& dir) :
21 phosphor::network::Manager(bus, path, dir)
22 {
23 }
24
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053025 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 IIIa520a392022-08-08 12:17:34 -070035 config::Parser config(config::pathForIntfConf(confDir, interface));
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053036 auto intf =
37 std::make_shared<phosphor::network::MockEthernetInterface>(
William A. Kennington III0caf2212022-08-18 18:15:51 -070038 bus, objPath.string(), config, *this, true);
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053039 intf->createIPAddressObjects();
40 intf->createStaticNeighborObjects();
William A. Kennington IIIa520a392022-08-08 12:17:34 -070041 intf->loadNameServers(config);
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053042 this->interfaces.emplace(
43 std::make_pair(std::move(interface), std::move(intf)));
44 }
45 }
William A. Kennington III4717d932021-10-08 18:28:23 -070046
William A. Kennington III56ecc782021-10-07 18:44:50 -070047 MOCK_METHOD(void, reloadConfigs, (), (override));
Ratan Gupta35297172018-11-28 18:40:16 +053048};
49
50} // namespace network
51} // namespace phosphor