blob: 741cee950399a04419fc655f01d81438832511ec [file] [log] [blame]
Manojkiran Edaacd6dd52019-10-15 15:00:51 +05301#pragma once
2
Ratan Gupta35297172018-11-28 18:40:16 +05303#include "config.h"
4
Manojkiran Edaacd6dd52019-10-15 15:00:51 +05305#include "mock_ethernet_interface.hpp"
Ratan Gupta35297172018-11-28 18:40:16 +05306#include "network_manager.hpp"
7
8#include <gmock/gmock.h>
9
10namespace phosphor
11{
12namespace network
13{
14
Manojkiran Eda1b5ec9c2020-06-13 15:29:28 +053015void initializeTimers();
16void refreshObjects();
17
Ratan Gupta35297172018-11-28 18:40:16 +053018class MockManager : public phosphor::network::Manager
19{
20 public:
Patrick Williamsc38b0712022-07-22 19:26:54 -050021 MockManager(sdbusplus::bus_t& bus, const char* path,
Ratan Gupta35297172018-11-28 18:40:16 +053022 const std::string& dir) :
23 phosphor::network::Manager(bus, path, dir)
24 {
25 }
26
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053027 void createInterfaces() override
28 {
29 // clear all the interfaces first
30 interfaces.clear();
31 auto interfaceStrList = getInterfaces();
32 for (auto& interface : interfaceStrList)
33 {
34 fs::path objPath = objectPath;
35 // normal ethernet interface
36 objPath /= interface;
37 auto dhcp = getDHCPValue(confDir, interface);
38 auto intf =
39 std::make_shared<phosphor::network::MockEthernetInterface>(
40 bus, objPath.string(), dhcp, *this, true);
41 intf->createIPAddressObjects();
42 intf->createStaticNeighborObjects();
43 intf->loadNameServers();
44 this->interfaces.emplace(
45 std::make_pair(std::move(interface), std::move(intf)));
46 }
47 }
William A. Kennington III4717d932021-10-08 18:28:23 -070048
William A. Kennington III56ecc782021-10-07 18:44:50 -070049 MOCK_METHOD(void, reloadConfigs, (), (override));
Ratan Gupta35297172018-11-28 18:40:16 +053050};
51
52} // namespace network
53} // namespace phosphor