]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Fix for distcheck and dhcp6 tests on NetBSD
authorTomek Mrugalski <tomasz@isc.org>
Wed, 14 Dec 2011 17:32:41 +0000 (18:32 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Wed, 14 Dec 2011 17:32:41 +0000 (18:32 +0100)
- 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

src/bin/dhcp4/Makefile.am
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/dhcp6_test.py
src/lib/dhcp/tests/iface_mgr_unittest.cc

index eccbc2d27f21965e635231ef0845dbb49e411da3..513ae1cca24b6f9dd68d0be5d595284ed5a1d77a 100644 (file)
@@ -12,6 +12,8 @@ endif
 
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 
+CLEANFILES = spec_config.h
+
 man_MANS = b10-dhcp4.8
 EXTRA_DIST = $(man_MANS) dhcp4.spec
 
index c20e983a94b45c25cd87689bb54bf42ef90fb507..c1976e19d5acdd4891caf81ac5c9ad788614db6e 100644 (file)
@@ -64,7 +64,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();
     });
index 50f37af9c85ee8eb9f640e6a53d89e7b8e562059..092dd2e58308b37c09479ac38602e472849f4197 100644 (file)
@@ -57,7 +57,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);
@@ -67,7 +67,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
@@ -116,7 +116,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
index 5ae1f5eba50c90fc071f488708c9d328344892b2..d63e04d7f0ca25ccf81980ec1bc990e52efb129f 100644 (file)
@@ -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()
index 088f1774df63605ffeaf8152a070c46116395c54..b647c18bf6e0b299b57808a710b96d2fe8564cd3 100644 (file)
@@ -101,9 +101,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) {
@@ -155,7 +155,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());
 
@@ -168,7 +168,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);
@@ -192,7 +192,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 );
 
@@ -225,11 +225,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();
@@ -240,6 +240,7 @@ TEST_F(IfaceMgrTest, detectIfaces) {
     EXPECT_STREQ( "fe80::1234", addr.toText().c_str() );
 
     delete ifacemgr;
+    unlink(INTERFACE_FILE);
 }
 
 TEST_F(IfaceMgrTest, sockets6) {
@@ -248,7 +249,7 @@ TEST_F(IfaceMgrTest, sockets6) {
 
     createLoInterfacesTxt();
 
-    NakedIfaceMgr * ifacemgr = new NakedIfaceMgr();
+    NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
 
     IOAddress loAddr("::1");
 
@@ -272,6 +273,7 @@ TEST_F(IfaceMgrTest, sockets6) {
     close(socket2);
 
     delete ifacemgr;
+    unlink(INTERFACE_FILE);
 }
 
 // TODO: disabled due to other naming on various systems
@@ -280,7 +282,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");
@@ -358,6 +360,7 @@ TEST_F(IfaceMgrTest, sendReceive6) {
     EXPECT_TRUE( (rcvPkt->remote_port_ == 10546) || (rcvPkt->remote_port_ == 10547) );
 
     delete ifacemgr;
+    unlink(INTERFACE_FILE);
 }
 
 TEST_F(IfaceMgrTest, socket4) {
@@ -385,11 +388,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);
     );
@@ -446,7 +450,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);
@@ -514,6 +518,7 @@ TEST_F(IfaceMgrTest, socketInfo) {
     );
 
     delete ifacemgr;
+    unlink(INTERFACE_FILE);
 }
 
 }