Browse Source

Fix for distcheck and dhcp6 tests on NetBSD

- Fixed distcheck complaining about file left in src/bin/dhcp4
- Fixed socket binding problem in src/lib/dhcp/tests/iface_mgr
- Fixed OSError problem in src/bin/dhcp6/tests/dhcp6_test.py on NetBSD
Tomek Mrugalski 13 years ago
parent
commit
8177f30e22

+ 2 - 0
src/bin/dhcp4/Makefile.am

@@ -12,6 +12,8 @@ endif
 
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 
+CLEANFILES = spec_config.h
+
 man_MANS = b10-dhcp4.8
 EXTRA_DIST = $(man_MANS) dhcp4.spec
 

+ 1 - 1
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc

@@ -75,7 +75,7 @@ TEST_F(Dhcpv4SrvTest, basic) {
     // nothing to test. DHCPv4_srv instance is created
     // in test fixture. It is destroyed in destructor
 
-    Dhcpv4Srv* srv = 0;
+    Dhcpv4Srv* srv = NULL;
     ASSERT_NO_THROW({
         srv = new Dhcpv4Srv(DHCP4_SERVER_PORT + 10000);
     });

+ 3 - 3
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc

@@ -70,7 +70,7 @@ TEST_F(Dhcpv6SrvTest, basic) {
     // interfaces.txt instead. It will pretend to have detected
     // fe80::1234 link-local address on eth0 interface. Obviously
     // an attempt to bind this socket will fail.
-    Dhcpv6Srv* srv = 0;
+    Dhcpv6Srv* srv = NULL;
     ASSERT_NO_THROW( {
         // open an unpriviledged port
         srv = new Dhcpv6Srv(DHCP6_SERVER_PORT + 10000);
@@ -80,7 +80,7 @@ TEST_F(Dhcpv6SrvTest, basic) {
 }
 
 TEST_F(Dhcpv6SrvTest, Solicit_basic) {
-    NakedDhcpv6Srv * srv = 0;
+    NakedDhcpv6Srv* srv = NULL;
     ASSERT_NO_THROW( srv = new NakedDhcpv6Srv(); );
 
     // a dummy content for client-id
@@ -129,7 +129,7 @@ TEST_F(Dhcpv6SrvTest, Solicit_basic) {
     boost::shared_ptr<Option> tmp = reply->getOption(D6O_IA_NA);
     ASSERT_TRUE( tmp );
 
-    Option6IA * reply_ia = dynamic_cast<Option6IA*> ( tmp.get() );
+    Option6IA* reply_ia = dynamic_cast<Option6IA*> ( tmp.get() );
     EXPECT_EQ( 234, reply_ia->getIAID() );
 
     // check that there's an address included

+ 7 - 1
src/bin/dhcp6/tests/dhcp6_test.py

@@ -59,7 +59,13 @@ class TestDhcpv6Daemon(unittest.TestCase):
         # kill this process
         # XXX: b10-dhcp6 is too dumb to understand 'shutdown' command for now,
         #      so let's just kill the bastard
-        os.kill(pi.pid, signal.SIGTERM)
+
+        # TODO: Ignore errors for now. This test will be more thorough once ticket #1503
+        # (passing port number to b10-dhcp6 daemon) is implemented.
+        try:
+            os.kill(pi.pid, signal.SIGTERM)
+        except OSError:
+            print("Ignoring failed kill attempt. Process is dead already.")
 
 if __name__ == '__main__':
     unittest.main()

+ 16 - 11
src/lib/dhcp/tests/iface_mgr_unittest.cc

@@ -100,9 +100,9 @@ TEST_F(IfaceMgrTest, dhcp6Sniffer) {
     interfaces << "eth0 fe80::21e:8cff:fe9b:7349";
     interfaces.close();
 
-    NakedIfaceMgr * ifacemgr = new NakedIfaceMgr();
+    NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
 
-    Pkt6 * pkt = 0;
+    Pkt6* pkt = NULL;
     int cnt = 0;
     cout << "---8X-----------------------------------------" << endl;
     while (true) {
@@ -154,7 +154,7 @@ TEST_F(IfaceMgrTest, basic) {
 TEST_F(IfaceMgrTest, ifaceClass) {
     // basic tests for Iface inner class
 
-    IfaceMgr::Iface * iface = new IfaceMgr::Iface("eth5", 7);
+    IfaceMgr::Iface* iface = new IfaceMgr::Iface("eth5", 7);
 
     EXPECT_STREQ("eth5/7", iface->getFullName().c_str());
 
@@ -167,7 +167,7 @@ TEST_F(IfaceMgrTest, ifaceClass) {
 TEST_F(IfaceMgrTest, getIface) {
 
     cout << "Interface checks. Please ignore socket binding errors." << endl;
-    NakedIfaceMgr * ifacemgr = new NakedIfaceMgr();
+    NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
 
     // interface name, ifindex
     IfaceMgr::Iface iface1("lo1", 1);
@@ -191,7 +191,7 @@ TEST_F(IfaceMgrTest, getIface) {
 
 
     // check that interface can be retrieved by ifindex
-    IfaceMgr::Iface * tmp = ifacemgr->getIface(5);
+    IfaceMgr::Iface* tmp = ifacemgr->getIface(5);
     // ASSERT_NE(NULL, tmp); is not supported. hmmmm.
     ASSERT_TRUE( tmp != NULL );
 
@@ -224,11 +224,11 @@ TEST_F(IfaceMgrTest, detectIfaces) {
     // interfaces. Nevertheless, this fake interface should
     // be on list, but if_nametoindex() will fail.
 
-    NakedIfaceMgr * ifacemgr = new NakedIfaceMgr();
+    NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
 
     ASSERT_TRUE( ifacemgr->getIface("eth0") != NULL );
 
-    IfaceMgr::Iface * eth0 = ifacemgr->getIface("eth0");
+    IfaceMgr::Iface* eth0 = ifacemgr->getIface("eth0");
 
     // there should be one address
     IfaceMgr::AddressCollection addrs = eth0->getAddresses();
@@ -239,6 +239,7 @@ TEST_F(IfaceMgrTest, detectIfaces) {
     EXPECT_STREQ( "fe80::1234", addr.toText().c_str() );
 
     delete ifacemgr;
+    unlink(INTERFACE_FILE);
 }
 
 TEST_F(IfaceMgrTest, sockets6) {
@@ -247,7 +248,7 @@ TEST_F(IfaceMgrTest, sockets6) {
 
     createLoInterfacesTxt();
 
-    NakedIfaceMgr * ifacemgr = new NakedIfaceMgr();
+    NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
 
     IOAddress loAddr("::1");
 
@@ -271,6 +272,7 @@ TEST_F(IfaceMgrTest, sockets6) {
     close(socket2);
 
     delete ifacemgr;
+    unlink(INTERFACE_FILE);
 }
 
 // TODO: disabled due to other naming on various systems
@@ -279,7 +281,7 @@ TEST_F(IfaceMgrTest, DISABLED_sockets6Mcast) {
     // testing socket operation in a portable way is tricky
     // without interface detection implemented
 
-    NakedIfaceMgr * ifacemgr = new NakedIfaceMgr();
+    NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
 
     IOAddress loAddr("::1");
     IOAddress mcastAddr("ff02::1:2");
@@ -354,6 +356,7 @@ TEST_F(IfaceMgrTest, sendReceive6) {
     EXPECT_TRUE( (rcvPkt->remote_port_ == 10546) || (rcvPkt->remote_port_ == 10547) );
 
     delete ifacemgr;
+    unlink(INTERFACE_FILE);
 }
 
 TEST_F(IfaceMgrTest, sendReceive4) {
@@ -465,11 +468,12 @@ TEST_F(IfaceMgrTest, socket4) {
     close(socket1);
 
     delete ifacemgr;
+    unlink(INTERFACE_FILE);
 }
 
 // Test the Iface structure itself
 TEST_F(IfaceMgrTest, iface) {
-    IfaceMgr::Iface* iface = 0;
+    IfaceMgr::Iface* iface = NULL;
     EXPECT_NO_THROW(
         iface = new IfaceMgr::Iface("eth0",1);
     );
@@ -526,7 +530,7 @@ TEST_F(IfaceMgrTest, socketInfo) {
 
     // now let's test if IfaceMgr handles socket info properly
     createLoInterfacesTxt();
-    NakedIfaceMgr * ifacemgr = new NakedIfaceMgr();
+    NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
     IfaceMgr::Iface* loopback = ifacemgr->getIface(LOOPBACK);
     ASSERT_TRUE(loopback);
     loopback->addSocket(sock1);
@@ -594,6 +598,7 @@ TEST_F(IfaceMgrTest, socketInfo) {
     );
 
     delete ifacemgr;
+    unlink(INTERFACE_FILE);
 }
 
 }