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

[992] Added dummy tests for dummy Dhcpv4_srv::process* methods.

parent 0f4dd0cf
......@@ -23,8 +23,8 @@ using namespace isc;
using namespace isc::dhcp;
using namespace isc::asiolink;
Dhcpv4Srv::Dhcpv4Srv() {
cout << "Initialization" << endl;
Dhcpv4Srv::Dhcpv4Srv(uint16_t port) {
cout << "Initialization: opening sockets on port " << port << endl;
// first call to instance() will create IfaceMgr (it's a singleton)
// it may throw something if things go wrong
......@@ -148,7 +148,7 @@ void Dhcpv4Srv::processDecline(boost::shared_ptr<Pkt4> decline) {
cout << "Received DECLINE on " << decline->getIface() << " interface." << endl;
}
boost::shared_ptr<Pkt4> processInform(boost::shared_ptr<Pkt4> inform) {
boost::shared_ptr<Pkt4> Dhcpv4Srv::processInform(boost::shared_ptr<Pkt4> inform) {
/// TODO: Currently implemented echo mode. Implement this for real
return (inform);
}
......@@ -17,6 +17,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <dhcp/dhcp4.h>
#include <dhcp/pkt4.h>
#include <dhcp/option.h>
#include <iostream>
......@@ -41,7 +42,7 @@ public:
/// In particular, creates IfaceMgr that will be responsible for
/// network interaction. Will instantiate lease manager, and load
/// old or create new DUID.
Dhcpv4Srv();
Dhcpv4Srv(uint16_t port = DHCP4_SERVER_PORT);
/// @brief Destructor. Used during DHCPv6 service shutdown.
~Dhcpv4Srv();
......
......@@ -34,33 +34,135 @@ class NakedDhcpv4Srv: public Dhcpv4Srv {
public:
NakedDhcpv4Srv() { }
boost::shared_ptr<Pkt4>
processDiscover(boost::shared_ptr<Pkt4>& discover) {
boost::shared_ptr<Pkt4> processDiscover(boost::shared_ptr<Pkt4>& discover) {
return Dhcpv4Srv::processDiscover(discover);
}
boost::shared_ptr<Pkt4>
processRequest(boost::shared_ptr<Pkt4>& request) {
boost::shared_ptr<Pkt4> processRequest(boost::shared_ptr<Pkt4>& request) {
return Dhcpv4Srv::processRequest(request);
}
void processRelease(boost::shared_ptr<Pkt4>& release) {
return Dhcpv4Srv::processRelease(release);
}
void processDecline(boost::shared_ptr<Pkt4>& decline) {
Dhcpv4Srv::processDecline(decline);
}
boost::shared_ptr<Pkt4> processInform(boost::shared_ptr<Pkt4>& inform) {
return Dhcpv4Srv::processInform(inform);
}
};
class Dhcpv4SrvTest : public ::testing::Test {
public:
Dhcpv4SrvTest() {
}
~Dhcpv4SrvTest() {
};
};
TEST_F(Dhcpv4SrvTest, basic) {
// there's almost no code now. What's there provides echo capability
// that is just a proof of concept and will be removed soon
// No need to thoroughly test it
// nothing to test. DHCPv4_srv instance is created
// in test fixture. It is destroyed in destructor
EXPECT_NO_THROW( {
Dhcpv4Srv * srv = new Dhcpv4Srv();
Dhcpv4Srv* srv = 0;
ASSERT_NO_THROW({
srv = new Dhcpv4Srv();
});
delete srv;
if (srv) {
ASSERT_NO_THROW({
delete srv;
});
}
}
TEST_F(Dhcpv4SrvTest, processDiscover) {
NakedDhcpv4Srv* srv = new NakedDhcpv4Srv();
boost::shared_ptr<Pkt4> pkt(new Pkt4(DHCPDISCOVER, 1234));
// should not throw
EXPECT_NO_THROW(
srv->processDiscover(pkt);
);
// should return something
EXPECT_TRUE(srv->processDiscover(pkt));
// TODO: Implement more reasonable tests before starting
// work on processSomething() method.
delete srv;
}
TEST_F(Dhcpv4SrvTest, processRequest) {
NakedDhcpv4Srv* srv = new NakedDhcpv4Srv();
boost::shared_ptr<Pkt4> pkt(new Pkt4(DHCPREQUEST, 1234));
// should not throw
EXPECT_NO_THROW(
srv->processRequest(pkt);
);
// should return something
EXPECT_TRUE(srv->processRequest(pkt));
// TODO: Implement more reasonable tests before starting
// work on processSomething() method.
delete srv;
}
TEST_F(Dhcpv4SrvTest, processRelease) {
NakedDhcpv4Srv* srv = new NakedDhcpv4Srv();
boost::shared_ptr<Pkt4> pkt(new Pkt4(DHCPRELEASE, 1234));
// should not throw
EXPECT_NO_THROW(
srv->processRelease(pkt);
);
// TODO: Implement more reasonable tests before starting
// work on processSomething() method.
delete srv;
}
TEST_F(Dhcpv4SrvTest, processDecline) {
NakedDhcpv4Srv* srv = new NakedDhcpv4Srv();
boost::shared_ptr<Pkt4> pkt(new Pkt4(DHCPDECLINE, 1234));
// should not throw
EXPECT_NO_THROW(
srv->processDecline(pkt);
);
// TODO: Implement more reasonable tests before starting
// work on processSomething() method.
delete srv;
}
TEST_F(Dhcpv4SrvTest, processInform) {
NakedDhcpv4Srv* srv = new NakedDhcpv4Srv();
boost::shared_ptr<Pkt4> pkt(new Pkt4(DHCPINFORM, 1234));
// should not throw
EXPECT_NO_THROW(
srv->processInform(pkt);
);
// should return something
EXPECT_TRUE(srv->processInform(pkt));
// TODO: Implement more reasonable tests before starting
// work on processSomething() method.
delete srv;
}
} // end of anonymous namespace
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