// removed code for binding socket twice to the same address/port
// as it caused problems on some platforms (e.g. Mac OS X)
+ // Close sockets here because the following tests will want to
+ // open sockets on the same ports.
ifacemgr->closeSockets();
// Use address that is not assigned to LOOPBACK iface.
ifacemgr->openSocket("non_existing_interface", loAddr, 10548),
BadValue
);
+
+ // Do not call closeSockets() because it is called by IfaceMgr's
+ // virtual destructor.
}
TEST_F(IfaceMgrTest, socketsFromIface) {
EXPECT_GT(socket2, 0);
close(socket2);
+ // Close sockets here because the following tests will want to
+ // open sockets on the same ports.
ifacemgr->closeSockets();
// Use invalid interface name.
ifacemgr->openSocketFromIface("non_existing_interface", PORT1, AF_INET),
BadValue
);
+
+ // Do not call closeSockets() because it is called by IfaceMgr's
+ // virtual destructor.
}
// socket descriptor must be positive integer
EXPECT_GT(socket2, 0);
+ // Close sockets here because the following tests will want to
+ // open sockets on the same ports.
ifacemgr->closeSockets();
// Use non-existing address.
EXPECT_THROW(
ifacemgr->openSocketFromAddress(invalidAddr, PORT1), BadValue
);
+
+ // Do not call closeSockets() because it is called by IfaceMgr's
+ // virtual destructor.
}
TEST_F(IfaceMgrTest, socketsFromRemoteAddress) {
);
EXPECT_GT(socket2, 0);
+ // Close sockets here because the following tests will want to
+ // open sockets on the same ports.
ifacemgr->closeSockets();
// The following test is currently disabled for OSes other than
);
EXPECT_GT(socket3, 0);
#endif
+
+ // Do not call closeSockets() because it is called by IfaceMgr's
+ // virtual destructor.
}
// TODO: disabled due to other naming on various systems
try {
pkt4 = IfaceMgr::instance().receive4(timeout);
} catch (const Exception& e) {
- std::cout << "Failed to receive DHCPv4 packet: "
+ std::cerr << "Failed to receive DHCPv4 packet: "
<< e.what() << std::endl;
}
if (!pkt4) {
try {
pkt6 = IfaceMgr::instance().receive6(timeout);
} catch (const Exception& e) {
- std::cout << "Failed to receive DHCPv6 packet: "
+ std::cerr << "Failed to receive DHCPv6 packet: "
<< e.what() << std::endl;
}
if (!pkt6) {