Commit 84ef9da1 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[1239] libdhcp++/IfaceMgr test improvements:

- unlink() moved to destructor as suggested by Jinmei
- added missing dummy interfaces.txt
parent 8177f30e
......@@ -55,6 +55,10 @@ public:
fakeifaces << LOOPBACK << " ::1";
fakeifaces.close();
}
~IfaceMgrTest() {
unlink(INTERFACE_FILE);
}
};
// We need some known interface to work reliably. Loopback interface
......@@ -147,6 +151,8 @@ TEST_F(IfaceMgrTest, dhcp6Sniffer) {
TEST_F(IfaceMgrTest, basic) {
// checks that IfaceManager can be instantiated
createLoInterfacesTxt();
IfaceMgr & ifacemgr = IfaceMgr::instance();
ASSERT_TRUE(&ifacemgr != 0);
}
......@@ -159,13 +165,14 @@ TEST_F(IfaceMgrTest, ifaceClass) {
EXPECT_STREQ("eth5/7", iface->getFullName().c_str());
delete iface;
}
// TODO: Implement getPlainMac() test as soon as interface detection
// is implemented.
TEST_F(IfaceMgrTest, getIface) {
createLoInterfacesTxt();
cout << "Interface checks. Please ignore socket binding errors." << endl;
NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
......@@ -209,6 +216,7 @@ TEST_F(IfaceMgrTest, getIface) {
EXPECT_EQ(static_cast<void*>(NULL), ifacemgr->getIface("wifi0") );
delete ifacemgr;
}
TEST_F(IfaceMgrTest, detectIfaces) {
......@@ -239,7 +247,6 @@ TEST_F(IfaceMgrTest, detectIfaces) {
EXPECT_STREQ( "fe80::1234", addr.toText().c_str() );
delete ifacemgr;
unlink(INTERFACE_FILE);
}
TEST_F(IfaceMgrTest, sockets6) {
......@@ -272,7 +279,6 @@ TEST_F(IfaceMgrTest, sockets6) {
close(socket2);
delete ifacemgr;
unlink(INTERFACE_FILE);
}
// TODO: disabled due to other naming on various systems
......@@ -356,7 +362,6 @@ TEST_F(IfaceMgrTest, sendReceive6) {
EXPECT_TRUE( (rcvPkt->remote_port_ == 10546) || (rcvPkt->remote_port_ == 10547) );
delete ifacemgr;
unlink(INTERFACE_FILE);
}
TEST_F(IfaceMgrTest, sendReceive4) {
......@@ -468,7 +473,6 @@ TEST_F(IfaceMgrTest, socket4) {
close(socket1);
delete ifacemgr;
unlink(INTERFACE_FILE);
}
// Test the Iface structure itself
......@@ -598,7 +602,6 @@ TEST_F(IfaceMgrTest, socketInfo) {
);
delete ifacemgr;
unlink(INTERFACE_FILE);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment