core: ignore non-Ethernet AF_LINK addresses when enumerating NICs.
Also modernize the code with some C++11 features.
Change-Id: Ibd29b39c37fdce8f87f917ab0cf48750e631e76c
diff --git a/tests/daemon/face/tcp.cpp b/tests/daemon/face/tcp.cpp
index a391edc..99c2d5b 100644
--- a/tests/daemon/face/tcp.cpp
+++ b/tests/daemon/face/tcp.cpp
@@ -60,22 +60,16 @@
TcpFactory factory;
BOOST_REQUIRE_EQUAL(factory.getChannels().empty(), true);
- std::vector<shared_ptr<const Channel> > expectedChannels;
+ std::vector<shared_ptr<const Channel>> expectedChannels;
expectedChannels.push_back(factory.createChannel("127.0.0.1", "20070"));
expectedChannels.push_back(factory.createChannel("127.0.0.1", "20071"));
expectedChannels.push_back(factory.createChannel("::1", "20071"));
- std::list<shared_ptr<const Channel> > channels = factory.getChannels();
- for (std::list<shared_ptr<const Channel> >::const_iterator i = channels.begin();
- i != channels.end(); ++i)
- {
- std::vector<shared_ptr<const Channel> >::iterator pos =
- std::find(expectedChannels.begin(), expectedChannels.end(), *i);
-
- BOOST_REQUIRE(pos != expectedChannels.end());
- expectedChannels.erase(pos);
- }
-
+ for (const auto& ch : factory.getChannels()) {
+ auto pos = std::find(expectedChannels.begin(), expectedChannels.end(), ch);
+ BOOST_REQUIRE(pos != expectedChannels.end());
+ expectedChannels.erase(pos);
+ }
BOOST_CHECK_EQUAL(expectedChannels.size(), 0);
}
@@ -115,7 +109,6 @@
factory.createFace(FaceUri("tcp4://127.0.0.1/path"),
bind(&FaceCreateFixture::ignore, this),
bind(&FaceCreateFixture::checkError, this, _1, "Invalid URI"));
-
}
class EndToEndFixture : protected BaseFixture
@@ -254,7 +247,7 @@
std::vector<Interest> face2_receivedInterests;
std::vector<Data> face2_receivedDatas;
- std::list< shared_ptr<Face> > faces;
+ std::list<shared_ptr<Face>> faces;
};
BOOST_FIXTURE_TEST_CASE(EndToEnd4, EndToEndFixture)
@@ -493,8 +486,6 @@
}
-
-
class SimpleEndToEndFixture : protected BaseFixture
{
public:
@@ -580,23 +571,17 @@
{
// tests with non-local Face
std::string someIpv4Address;
- std::list< shared_ptr<NetworkInterfaceInfo> > ifs = listNetworkInterfaces();
- for (std::list< shared_ptr<NetworkInterfaceInfo> >::const_iterator i = ifs.begin();
- i != ifs.end();
- ++i)
- {
- if (!(*i)->isLoopback() && (*i)->isUp() && !(*i)->ipv4Addresses.empty())
- {
- someIpv4Address = (*i)->ipv4Addresses[0].to_string();
- break;
- }
+ for (const auto& netif : listNetworkInterfaces()) {
+ if (!netif.isLoopback() && netif.isUp() && !netif.ipv4Addresses.empty()) {
+ someIpv4Address = netif.ipv4Addresses[0].to_string();
+ break;
}
- if (someIpv4Address.empty())
- {
- BOOST_TEST_MESSAGE("Test with non-local Face cannot be run "
- "(no non-local interface with IPv4 address available)");
- return;
- }
+ }
+ if (someIpv4Address.empty()) {
+ BOOST_TEST_MESSAGE("Test with non-local Face cannot be run "
+ "(no non-local interface with IPv4 address available)");
+ return;
+ }
TcpFactory factory;
@@ -605,7 +590,6 @@
bind(&SimpleEndToEndFixture::onConnectFailed, this, _1));
BOOST_REQUIRE_EQUAL(channel->isListening(), true);
-
DummyStreamSender<boost::asio::ip::tcp, Dataset> sender;
sender.start(Resolver<boost::asio::ip::tcp>::syncResolve(someIpv4Address, "20070"));