BIND 10 trac1239, updated. 84ef9da129de44dfa74933f83db60bdaf2dce51e [1239] libdhcp++/IfaceMgr test improvements:
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Dec 16 17:04:01 UTC 2011
The branch, trac1239 has been updated
via 84ef9da129de44dfa74933f83db60bdaf2dce51e (commit)
via 8177f30e22454cf9bc2561c16695f3c58c4a59c5 (commit)
from eb591a94c560e7ac7067141ee451b7d693a2bae1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 84ef9da129de44dfa74933f83db60bdaf2dce51e
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Fri Dec 16 17:57:41 2011 +0100
[1239] libdhcp++/IfaceMgr test improvements:
- unlink() moved to destructor as suggested by Jinmei
- added missing dummy interfaces.txt
commit 8177f30e22454cf9bc2561c16695f3c58c4a59c5
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Wed Dec 14 18:32:41 2011 +0100
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
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp4/Makefile.am | 2 +
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc | 2 +-
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc | 6 ++--
src/bin/dhcp6/tests/dhcp6_test.py | 8 ++++++-
src/lib/dhcp/tests/iface_mgr_unittest.cc | 32 ++++++++++++++++++----------
5 files changed, 33 insertions(+), 17 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp4/Makefile.am b/src/bin/dhcp4/Makefile.am
index 71a4531..cbad39c 100644
--- a/src/bin/dhcp4/Makefile.am
+++ b/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
diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
index 1f2c2a0..8041425 100644
--- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
+++ b/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);
});
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 540fc8f..5078cab 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/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
diff --git a/src/bin/dhcp6/tests/dhcp6_test.py b/src/bin/dhcp6/tests/dhcp6_test.py
index 5ae1f5e..d63e04d 100644
--- a/src/bin/dhcp6/tests/dhcp6_test.py
+++ b/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()
diff --git a/src/lib/dhcp/tests/iface_mgr_unittest.cc b/src/lib/dhcp/tests/iface_mgr_unittest.cc
index 6eacd97..feefa46 100644
--- a/src/lib/dhcp/tests/iface_mgr_unittest.cc
+++ b/src/lib/dhcp/tests/iface_mgr_unittest.cc
@@ -55,6 +55,10 @@ public:
fakeifaces << LOOPBACK << " ::1";
fakeifaces.close();
}
+
+ ~IfaceMgrTest() {
+ unlink(INTERFACE_FILE);
+ }
};
// We need some known interface to work reliably. Loopback interface
@@ -100,9 +104,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) {
@@ -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);
}
@@ -154,20 +160,21 @@ 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());
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();
+ NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
// interface name, ifindex
IfaceMgr::Iface iface1("lo1", 1);
@@ -191,7 +198,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 );
@@ -209,6 +216,7 @@ TEST_F(IfaceMgrTest, getIface) {
EXPECT_EQ(static_cast<void*>(NULL), ifacemgr->getIface("wifi0") );
delete ifacemgr;
+
}
TEST_F(IfaceMgrTest, detectIfaces) {
@@ -224,11 +232,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();
@@ -247,7 +255,7 @@ TEST_F(IfaceMgrTest, sockets6) {
createLoInterfacesTxt();
- NakedIfaceMgr * ifacemgr = new NakedIfaceMgr();
+ NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
IOAddress loAddr("::1");
@@ -279,7 +287,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");
@@ -469,7 +477,7 @@ TEST_F(IfaceMgrTest, socket4) {
// 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 +534,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);
More information about the bind10-changes
mailing list