system_queries: Migrate system queries into a single place
This provides better separation of the DBus interface and the underlying
system interactions.
Change-Id: I8bf7a44c679ab065f959af19a00c29897c1d5c48
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/mock_network_manager.hpp b/test/mock_network_manager.hpp
index 9286d0c..130e806 100644
--- a/test/mock_network_manager.hpp
+++ b/test/mock_network_manager.hpp
@@ -2,7 +2,7 @@
#include "config_parser.hpp"
#include "mock_ethernet_interface.hpp"
#include "network_manager.hpp"
-#include "util.hpp"
+#include "system_queries.hpp"
#include <gmock/gmock.h>
@@ -27,7 +27,7 @@
{
// clear all the interfaces first
interfaces.clear();
- auto interfaceStrList = getSystemInterfaces();
+ auto interfaceStrList = system::getInterfaces();
for (auto& interface : interfaceStrList)
{
fs::path objPath = objectPath;
diff --git a/test/mock_syscall.cpp b/test/mock_syscall.cpp
index 349a79a..e5f97be 100644
--- a/test/mock_syscall.cpp
+++ b/test/mock_syscall.cpp
@@ -181,9 +181,7 @@
int getifaddrs(ifaddrs** ifap)
{
*ifap = mock_ifaddrs;
- if (mock_ifaddrs == nullptr)
- return -1;
- return (0);
+ return 0;
}
unsigned if_nametoindex(const char* ifname)
diff --git a/test/test_network_manager.cpp b/test/test_network_manager.cpp
index a607bb7..a34a5e7 100644
--- a/test/test_network_manager.cpp
+++ b/test/test_network_manager.cpp
@@ -6,11 +6,8 @@
#include <netinet/in.h>
#include <stdlib.h>
-#include <exception>
-#include <filesystem>
#include <sdbusplus/bus.hpp>
#include <stdplus/gtest/tmp.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
#include <gtest/gtest.h>
@@ -21,7 +18,6 @@
using ::testing::Key;
using ::testing::UnorderedElementsAre;
-namespace fs = std::filesystem;
class TestNetworkManager : public stdplus::gtest::TestWithTmp
{
@@ -43,8 +39,9 @@
// getifaddrs will not return any interface
TEST_F(TestNetworkManager, NoInterface)
{
- using namespace sdbusplus::xyz::openbmc_project::Common::Error;
- EXPECT_THROW(createInterfaces(), InternalFailure);
+ mock_clear();
+ createInterfaces();
+ EXPECT_TRUE(manager.getInterfaces().empty());
}
// getifaddrs returns single interface.
TEST_F(TestNetworkManager, WithSingleInterface)