summaryrefslogtreecommitdiff
path: root/server/InterfaceControllerTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'server/InterfaceControllerTest.cpp')
-rw-r--r--server/InterfaceControllerTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/server/InterfaceControllerTest.cpp b/server/InterfaceControllerTest.cpp
index 014d05d1..0cf7cfc1 100644
--- a/server/InterfaceControllerTest.cpp
+++ b/server/InterfaceControllerTest.cpp
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+#include <ifaddrs.h>
+#include <net/if.h>
+#include <sys/types.h>
+
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -172,5 +176,21 @@ TEST_F(StablePrivacyTest, ExistingPropertyWriteFail) {
EXPECT_NE(ok, enableStablePrivacyAddresses(kTestIface));
}
+class GetIfaceListTest : public testing::Test {};
+
+TEST_F(GetIfaceListTest, IfaceExist) {
+ StatusOr<std::map<std::string, uint32_t>> ifaceMap = InterfaceController::getIfaceList();
+ EXPECT_EQ(ok, ifaceMap.status());
+ struct ifaddrs *ifaddr, *ifa;
+ EXPECT_EQ(0, getifaddrs(&ifaddr));
+ for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+ uint32_t ifaceIndex = if_nametoindex(ifa->ifa_name);
+ const auto ifacePair = ifaceMap.value().find(ifa->ifa_name);
+ EXPECT_NE(ifaceMap.value().end(), ifacePair);
+ EXPECT_EQ(ifaceIndex, ifacePair->second);
+ }
+ freeifaddrs(ifaddr);
+}
+
} // namespace net
} // namespace android