Browse Source

[3251] Additional unit test for the case when there are no interfaces.

Marcin Siodelski 11 years ago
parent
commit
77059f8a6b
1 changed files with 18 additions and 0 deletions
  1. 18 0
      src/lib/dhcp/tests/iface_mgr_unittest.cc

+ 18 - 0
src/lib/dhcp/tests/iface_mgr_unittest.cc

@@ -1645,6 +1645,24 @@ TEST_F(IfaceMgrTest, openSockets6IfaceInactive) {
 
 }
 
+// That that the openSockets6 function does not throw if there are no interfaces
+// detected. This function is expected to return false.
+TEST_F(IfaceMgrTest, openSockets6NoIfaces) {
+    NakedIfaceMgr ifacemgr;
+    // Remove existing interfaces.
+    ifacemgr.getIfacesLst().clear();
+
+    boost::shared_ptr<PktFilter6Stub> filter(new PktFilter6Stub());
+    ASSERT_TRUE(filter);
+    ASSERT_NO_THROW(ifacemgr.setPacketFilter(filter));
+
+    // This value indicates if at least one socket opens. There are no
+    // interfaces, so it should be set to false.
+    bool socket_open;
+    ASSERT_NO_THROW(socket_open = ifacemgr.openSockets6(DHCP6_SERVER_PORT));
+    EXPECT_FALSE(socket_open);
+}
+
 // Test the Iface structure itself
 TEST_F(IfaceMgrTest, iface) {
     boost::scoped_ptr<Iface> iface;