blob: af26771469151d8331c79fcdcbad7a1cc5e6d747 [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
William A. Kennington IIIdd9ef812022-10-05 02:08:02 -070016class MockManager : public Manager
Ratan Gupta35297172018-11-28 18:40:16 +053017{
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) :
William A. Kennington IIIdd9ef812022-10-05 02:08:02 -070021 Manager(bus, path, dir)
Ratan Gupta35297172018-11-28 18:40:16 +053022 {
23 }
24
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053025 void createInterfaces() override
26 {
27 // clear all the interfaces first
28 interfaces.clear();
William A. Kennington III96444792022-10-05 15:16:22 -070029 auto interfaceStrList = getSystemInterfaces();
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053030 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));
William A. Kennington IIIdd9ef812022-10-05 02:08:02 -070036 auto intf = std::make_unique<MockEthernetInterface>(
37 bus, objPath.string(), config, *this, true);
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053038 intf->createIPAddressObjects();
39 intf->createStaticNeighborObjects();
William A. Kennington IIIa520a392022-08-08 12:17:34 -070040 intf->loadNameServers(config);
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053041 this->interfaces.emplace(
42 std::make_pair(std::move(interface), std::move(intf)));
43 }
44 }
William A. Kennington III4717d932021-10-08 18:28:23 -070045
William A. Kennington III56ecc782021-10-07 18:44:50 -070046 MOCK_METHOD(void, reloadConfigs, (), (override));
Ratan Gupta35297172018-11-28 18:40:16 +053047};
48
49} // namespace network
50} // namespace phosphor