face: handle initially non-running Ethernet interfaces

refs #5096

Change-Id: I27cc913cc2478baa8dfaad08e67bd1b9703c43f4
diff --git a/tests/daemon/face/multicast-ethernet-transport.t.cpp b/tests/daemon/face/multicast-ethernet-transport.t.cpp
index 4e0df3c..84dead4 100644
--- a/tests/daemon/face/multicast-ethernet-transport.t.cpp
+++ b/tests/daemon/face/multicast-ethernet-transport.t.cpp
@@ -63,12 +63,12 @@
 
 BOOST_AUTO_TEST_CASE(NetifStateChange)
 {
-  SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
-  initializeMulticast();
-  BOOST_CHECK_EQUAL(transport->getState(), TransportState::UP);
+  SKIP_IF_NO_RUNNING_ETHERNET_NETIF();
+  auto netif = getRunningNetif();
+  initializeMulticast(netif);
 
-  // simulate 'ip link set IFNAME down'
-  getScheduler().schedule(10_ms, [this] { netif->setState(ndn::net::InterfaceState::DOWN); });
+  // Simulate setting interface administratively down
+  getScheduler().schedule(10_ms, [netif] { netif->setState(ndn::net::InterfaceState::DOWN); });
   transport->afterStateChange.connectSingleShot([this] (auto oldState, auto newState) {
     BOOST_CHECK_EQUAL(oldState, TransportState::UP);
     BOOST_CHECK_EQUAL(newState, TransportState::DOWN);
@@ -77,9 +77,9 @@
   BOOST_CHECK_EQUAL(limitedIo.run(1, 1_s), LimitedIo::EXCEED_OPS);
   BOOST_CHECK_EQUAL(transport->getState(), TransportState::DOWN);
 
-  // simulate 'ip link set IFNAME up'
-  getScheduler().schedule(10_ms, [this] { netif->setState(ndn::net::InterfaceState::NO_CARRIER); });
-  getScheduler().schedule(80_ms, [this] { netif->setState(ndn::net::InterfaceState::RUNNING); });
+  // Simulate setting interface administratively up
+  getScheduler().schedule(10_ms, [netif] { netif->setState(ndn::net::InterfaceState::NO_CARRIER); });
+  getScheduler().schedule(80_ms, [netif] { netif->setState(ndn::net::InterfaceState::RUNNING); });
   transport->afterStateChange.connectSingleShot([this] (auto oldState, auto newState) {
     BOOST_CHECK_EQUAL(oldState, TransportState::DOWN);
     BOOST_CHECK_EQUAL(newState, TransportState::UP);
@@ -93,25 +93,25 @@
 {
   SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
   initializeMulticast();
-  BOOST_CHECK_EQUAL(transport->getMtu(), netif->getMtu());
+  BOOST_CHECK_EQUAL(transport->getMtu(), defaultNetif->getMtu());
 
   // netif changes MTU from initial value to 1024
-  netif->setMtu(1024);
+  defaultNetif->setMtu(1024);
   BOOST_CHECK_EQUAL(transport->getMtu(), 1024);
 
   // netif changes MTU from 1024 to 4000
-  netif->setMtu(4000);
+  defaultNetif->setMtu(4000);
   BOOST_CHECK_EQUAL(transport->getMtu(), 4000);
 
   // netif changes MTU from 4000 to 0
-  netif->setMtu(0);
+  defaultNetif->setMtu(0);
   BOOST_CHECK_EQUAL(transport->getMtu(), 0);
 }
 
 BOOST_AUTO_TEST_CASE(Close)
 {
-  SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
-  initializeMulticast();
+  SKIP_IF_NO_RUNNING_ETHERNET_NETIF();
+  initializeMulticast(getRunningNetif());
 
   transport->afterStateChange.connectSingleShot([] (auto oldState, auto newState) {
     BOOST_CHECK_EQUAL(oldState, TransportState::UP);