Commit ebb759a0 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

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
parent b015cf73
...@@ -12,6 +12,8 @@ endif ...@@ -12,6 +12,8 @@ endif
pkglibexecdir = $(libexecdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@
CLEANFILES = spec_config.h
man_MANS = b10-dhcp4.8 man_MANS = b10-dhcp4.8
EXTRA_DIST = $(man_MANS) dhcp4.spec EXTRA_DIST = $(man_MANS) dhcp4.spec
......
...@@ -64,7 +64,7 @@ TEST_F(Dhcpv4SrvTest, basic) { ...@@ -64,7 +64,7 @@ TEST_F(Dhcpv4SrvTest, basic) {
// nothing to test. DHCPv4_srv instance is created // nothing to test. DHCPv4_srv instance is created
// in test fixture. It is destroyed in destructor // in test fixture. It is destroyed in destructor
Dhcpv4Srv* srv = 0; Dhcpv4Srv* srv = NULL;
ASSERT_NO_THROW({ ASSERT_NO_THROW({
srv = new Dhcpv4Srv(); srv = new Dhcpv4Srv();
}); });
......
...@@ -57,7 +57,7 @@ TEST_F(Dhcpv6SrvTest, basic) { ...@@ -57,7 +57,7 @@ TEST_F(Dhcpv6SrvTest, basic) {
// interfaces.txt instead. It will pretend to have detected // interfaces.txt instead. It will pretend to have detected
// fe80::1234 link-local address on eth0 interface. Obviously // fe80::1234 link-local address on eth0 interface. Obviously
// an attempt to bind this socket will fail. // an attempt to bind this socket will fail.
Dhcpv6Srv* srv = 0; Dhcpv6Srv* srv = NULL;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
// open an unpriviledged port // open an unpriviledged port
srv = new Dhcpv6Srv(DHCP6_SERVER_PORT + 10000); srv = new Dhcpv6Srv(DHCP6_SERVER_PORT + 10000);
...@@ -67,7 +67,7 @@ TEST_F(Dhcpv6SrvTest, basic) { ...@@ -67,7 +67,7 @@ TEST_F(Dhcpv6SrvTest, basic) {
} }
TEST_F(Dhcpv6SrvTest, Solicit_basic) { TEST_F(Dhcpv6SrvTest, Solicit_basic) {
NakedDhcpv6Srv * srv = 0; NakedDhcpv6Srv* srv = NULL;
ASSERT_NO_THROW( srv = new NakedDhcpv6Srv(); ); ASSERT_NO_THROW( srv = new NakedDhcpv6Srv(); );
// a dummy content for client-id // a dummy content for client-id
...@@ -116,7 +116,7 @@ TEST_F(Dhcpv6SrvTest, Solicit_basic) { ...@@ -116,7 +116,7 @@ TEST_F(Dhcpv6SrvTest, Solicit_basic) {
boost::shared_ptr<Option> tmp = reply->getOption(D6O_IA_NA); boost::shared_ptr<Option> tmp = reply->getOption(D6O_IA_NA);
ASSERT_TRUE( tmp ); 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() ); EXPECT_EQ( 234, reply_ia->getIAID() );
// check that there's an address included // check that there's an address included
......
...@@ -59,7 +59,13 @@ class TestDhcpv6Daemon(unittest.TestCase): ...@@ -59,7 +59,13 @@ class TestDhcpv6Daemon(unittest.TestCase):
# kill this process # kill this process
# XXX: b10-dhcp6 is too dumb to understand 'shutdown' command for now, # XXX: b10-dhcp6 is too dumb to understand 'shutdown' command for now,
# so let's just kill the bastard # so let's just kill the bastard
# 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) os.kill(pi.pid, signal.SIGTERM)
except OSError:
print("Ignoring failed kill attempt. Process is dead already.")
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -101,9 +101,9 @@ TEST_F(IfaceMgrTest, dhcp6Sniffer) { ...@@ -101,9 +101,9 @@ TEST_F(IfaceMgrTest, dhcp6Sniffer) {
interfaces << "eth0 fe80::21e:8cff:fe9b:7349"; interfaces << "eth0 fe80::21e:8cff:fe9b:7349";
interfaces.close(); interfaces.close();
NakedIfaceMgr * ifacemgr = new NakedIfaceMgr(); NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
Pkt6 * pkt = 0; Pkt6* pkt = NULL;
int cnt = 0; int cnt = 0;
cout << "---8X-----------------------------------------" << endl; cout << "---8X-----------------------------------------" << endl;
while (true) { while (true) {
...@@ -155,7 +155,7 @@ TEST_F(IfaceMgrTest, basic) { ...@@ -155,7 +155,7 @@ TEST_F(IfaceMgrTest, basic) {
TEST_F(IfaceMgrTest, ifaceClass) { TEST_F(IfaceMgrTest, ifaceClass) {
// basic tests for Iface inner class // 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()); EXPECT_STREQ("eth5/7", iface->getFullName().c_str());
...@@ -168,7 +168,7 @@ TEST_F(IfaceMgrTest, ifaceClass) { ...@@ -168,7 +168,7 @@ TEST_F(IfaceMgrTest, ifaceClass) {
TEST_F(IfaceMgrTest, getIface) { TEST_F(IfaceMgrTest, getIface) {
cout << "Interface checks. Please ignore socket binding errors." << endl; cout << "Interface checks. Please ignore socket binding errors." << endl;
NakedIfaceMgr * ifacemgr = new NakedIfaceMgr(); NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
// interface name, ifindex // interface name, ifindex
IfaceMgr::Iface iface1("lo1", 1); IfaceMgr::Iface iface1("lo1", 1);
...@@ -192,7 +192,7 @@ TEST_F(IfaceMgrTest, getIface) { ...@@ -192,7 +192,7 @@ TEST_F(IfaceMgrTest, getIface) {
// check that interface can be retrieved by ifindex // 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_NE(NULL, tmp); is not supported. hmmmm.
ASSERT_TRUE( tmp != NULL ); ASSERT_TRUE( tmp != NULL );
...@@ -225,11 +225,11 @@ TEST_F(IfaceMgrTest, detectIfaces) { ...@@ -225,11 +225,11 @@ TEST_F(IfaceMgrTest, detectIfaces) {
// interfaces. Nevertheless, this fake interface should // interfaces. Nevertheless, this fake interface should
// be on list, but if_nametoindex() will fail. // be on list, but if_nametoindex() will fail.
NakedIfaceMgr * ifacemgr = new NakedIfaceMgr(); NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
ASSERT_TRUE( ifacemgr->getIface("eth0") != NULL ); ASSERT_TRUE( ifacemgr->getIface("eth0") != NULL );
IfaceMgr::Iface * eth0 = ifacemgr->getIface("eth0"); IfaceMgr::Iface* eth0 = ifacemgr->getIface("eth0");
// there should be one address // there should be one address
IfaceMgr::AddressCollection addrs = eth0->getAddresses(); IfaceMgr::AddressCollection addrs = eth0->getAddresses();
...@@ -240,6 +240,7 @@ TEST_F(IfaceMgrTest, detectIfaces) { ...@@ -240,6 +240,7 @@ TEST_F(IfaceMgrTest, detectIfaces) {
EXPECT_STREQ( "fe80::1234", addr.toText().c_str() ); EXPECT_STREQ( "fe80::1234", addr.toText().c_str() );
delete ifacemgr; delete ifacemgr;
unlink(INTERFACE_FILE);
} }
TEST_F(IfaceMgrTest, sockets6) { TEST_F(IfaceMgrTest, sockets6) {
...@@ -248,7 +249,7 @@ TEST_F(IfaceMgrTest, sockets6) { ...@@ -248,7 +249,7 @@ TEST_F(IfaceMgrTest, sockets6) {
createLoInterfacesTxt(); createLoInterfacesTxt();
NakedIfaceMgr * ifacemgr = new NakedIfaceMgr(); NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
IOAddress loAddr("::1"); IOAddress loAddr("::1");
...@@ -272,6 +273,7 @@ TEST_F(IfaceMgrTest, sockets6) { ...@@ -272,6 +273,7 @@ TEST_F(IfaceMgrTest, sockets6) {
close(socket2); close(socket2);
delete ifacemgr; delete ifacemgr;
unlink(INTERFACE_FILE);
} }
// TODO: disabled due to other naming on various systems // TODO: disabled due to other naming on various systems
...@@ -280,7 +282,7 @@ TEST_F(IfaceMgrTest, DISABLED_sockets6Mcast) { ...@@ -280,7 +282,7 @@ TEST_F(IfaceMgrTest, DISABLED_sockets6Mcast) {
// testing socket operation in a portable way is tricky // testing socket operation in a portable way is tricky
// without interface detection implemented // without interface detection implemented
NakedIfaceMgr * ifacemgr = new NakedIfaceMgr(); NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
IOAddress loAddr("::1"); IOAddress loAddr("::1");
IOAddress mcastAddr("ff02::1:2"); IOAddress mcastAddr("ff02::1:2");
...@@ -358,6 +360,7 @@ TEST_F(IfaceMgrTest, sendReceive6) { ...@@ -358,6 +360,7 @@ TEST_F(IfaceMgrTest, sendReceive6) {
EXPECT_TRUE( (rcvPkt->remote_port_ == 10546) || (rcvPkt->remote_port_ == 10547) ); EXPECT_TRUE( (rcvPkt->remote_port_ == 10546) || (rcvPkt->remote_port_ == 10547) );
delete ifacemgr; delete ifacemgr;
unlink(INTERFACE_FILE);
} }
TEST_F(IfaceMgrTest, socket4) { TEST_F(IfaceMgrTest, socket4) {
...@@ -385,11 +388,12 @@ TEST_F(IfaceMgrTest, socket4) { ...@@ -385,11 +388,12 @@ TEST_F(IfaceMgrTest, socket4) {
close(socket1); close(socket1);
delete ifacemgr; delete ifacemgr;
unlink(INTERFACE_FILE);
} }
// Test the Iface structure itself // Test the Iface structure itself
TEST_F(IfaceMgrTest, iface) { TEST_F(IfaceMgrTest, iface) {
IfaceMgr::Iface* iface = 0; IfaceMgr::Iface* iface = NULL;
EXPECT_NO_THROW( EXPECT_NO_THROW(
iface = new IfaceMgr::Iface("eth0",1); iface = new IfaceMgr::Iface("eth0",1);
); );
...@@ -446,7 +450,7 @@ TEST_F(IfaceMgrTest, socketInfo) { ...@@ -446,7 +450,7 @@ TEST_F(IfaceMgrTest, socketInfo) {
// now let's test if IfaceMgr handles socket info properly // now let's test if IfaceMgr handles socket info properly
createLoInterfacesTxt(); createLoInterfacesTxt();
NakedIfaceMgr * ifacemgr = new NakedIfaceMgr(); NakedIfaceMgr* ifacemgr = new NakedIfaceMgr();
IfaceMgr::Iface* loopback = ifacemgr->getIface(LOOPBACK); IfaceMgr::Iface* loopback = ifacemgr->getIface(LOOPBACK);
ASSERT_TRUE(loopback); ASSERT_TRUE(loopback);
loopback->addSocket(sock1); loopback->addSocket(sock1);
...@@ -514,6 +518,7 @@ TEST_F(IfaceMgrTest, socketInfo) { ...@@ -514,6 +518,7 @@ TEST_F(IfaceMgrTest, socketInfo) {
); );
delete ifacemgr; 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