Commit 57d3634c authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3173] Addressed review comments.

parent b2686c2d
......@@ -861,13 +861,6 @@ private:
/// specified, this function expects that IA_PD option is present in the
/// packet encapsulated by pkt_to object.
///
/// \todo In the future it is planned to add support for the perfdhcp to
/// request address and prefix in the same DHCP message (request both
/// IA_NA and IA_PD options). In this case, this function will have to
/// be extended to copy both IA_NA and IA_PD options.
///
/// \warning
///
/// \param [in] pkt_from A packet from which options should be copied.
/// \param [out] pkt_to A packet to which options should be copied.
///
......
......@@ -81,6 +81,10 @@ public:
///
/// Method simulates sending or receiving multiple DHCPv6 packets.
///
/// \note The xchg_type parameter is passed as non-const value to avoid
/// false cppcheck errors which expect enum value being passed by reference.
/// This error is not reported when non-const enum is passed by value.
///
/// \param stats_mgr Statistics Manager instance to be used.
/// \param xchg_type packet exchange types.
/// \param packet_type DHCPv6 packet type.
......@@ -88,7 +92,7 @@ public:
/// \param receive simulated packets are received (if true)
/// or sent (if false)
void passMultiplePackets6(const boost::shared_ptr<StatsMgr6> stats_mgr,
const StatsMgr6::ExchangeType xchg_type,
StatsMgr6::ExchangeType xchg_type,
const uint8_t packet_type,
const int num_packets,
const bool receive = false) {
......
......@@ -521,14 +521,8 @@ public:
boost::shared_ptr<Pkt6>
advertise_pkt6(createAdvertisePkt6(transid));
// Receive ADVERTISE and send REQUEST.
/* ASSERT_NO_THROW(tc.processReceivedPacket6(sock,
advertise_pkt6)); */
try {
tc.processReceivedPacket6(sock,
advertise_pkt6);
} catch (const Exception& ex) {
std::cout << ex.what() << std::endl;
}
ASSERT_NO_THROW(tc.processReceivedPacket6(sock,
advertise_pkt6));
++transid;
}
if (tc.checkExitConditions()) {
......@@ -980,7 +974,7 @@ TEST_F(TestControlTest, Packet4Exchange) {
EXPECT_EQ(12, iterations_performed);
}
TEST_F(TestControlTest, Packet6Exchange) {
TEST_F(TestControlTest, Packet6ExchangeFromTemplate) {
// Get the local loopback interface to open socket on
// it and test packets exchanges. We don't want to fail
// the test if interface is not available.
......@@ -1015,11 +1009,56 @@ TEST_F(TestControlTest, Packet6Exchange) {
// then test should be interrupted and actual number of iterations will
// be 6.
const int received_num = 3;
// Simulate the number of Solicit-Advertise-Request-Reply (SARR) echanges.
// The test function generates server's responses and passes it to the
// TestControl class methods for processing. The number of exchanges
// actually performed is returned in 'iterations_performed' argument. If
// processing is successful, the number of performed iterations should be
// equal to the number of exchanges specified with the '-n' command line
// parameter (10 in this case). All exchanged packets carry the IA_NA option
// to simulate the IPv6 address acquisition and to verify that the
// IA_NA options returned by the server are processed correctly.
testPkt6Exchange(iterations_num, received_num, use_templates,
iterations_performed);
EXPECT_EQ(6, iterations_performed);
}
TEST_F(TestControlTest, Packet6Exchange) {
// Get the local loopback interface to open socket on
// it and test packets exchanges. We don't want to fail
// the test if interface is not available.
std::string loopback_iface(getLocalLoopback());
if (loopback_iface.empty()) {
std::cout << "Unable to find the loopback interface. Skip test."
<< std::endl;
return;
}
const int iterations_num = 100;
// Set number of iterations to 10.
processCmdLine("perfdhcp -l " + loopback_iface
+ " -e address-only"
+ " -6 -r 100 -n 10 -R 20 -L 10547 ::1");
int iterations_performed = 0;
// Set number of received packets equal to number of iterations.
// This simulates no packet drops.
bool use_templates = false;
// Simulate the number of Solicit-Advertise-Request-Reply (SARR) echanges.
// The test function generates server's responses and passes it to the
// TestControl class methods for processing. The number of exchanges
// actually performed is returned in 'iterations_performed' argument. If
// processing is successful, the number of performed iterations should be
// equal to the number of exchanges specified with the '-n' command line
// parameter (10 in this case). All exchanged packets carry the IA_NA option
// to simulate the IPv6 address acqusition and to verify that the IA_NA
// options returned by the server are processed correctly.
testPkt6Exchange(iterations_num, iterations_num, use_templates,
iterations_performed);
// Actual number of iterations should be 10.
EXPECT_EQ(10, iterations_performed);
}
TEST_F(TestControlTest, Packet6ExchangePrefixDelegation) {
// Get the local loopback interface to open socket on
// it and test packets exchanges. We don't want to fail
......@@ -1040,6 +1079,16 @@ TEST_F(TestControlTest, Packet6ExchangePrefixDelegation) {
// Set number of received packets equal to number of iterations.
// This simulates no packet drops.
bool use_templates = false;
// Simulate the number of Solicit-Advertise-Request-Reply (SARR) echanges.
// The test function generates server's responses and passes it to the
// TestControl class methods for processing. The number of exchanges
// actually performed is returned in 'iterations_performed' argument. If
// processing is successful, the number of performed iterations should be
// equal to the number of exchanges specified with the '-n' command line
// parameter (10 in this case). All exchanged packets carry the IA_PD option
// to simulate the Prefix Delegation and to verify that the IA_PD options
// returned by the server are processed correctly.
testPkt6Exchange(iterations_num, iterations_num, use_templates,
iterations_performed);
// Actual number of iterations should be 10.
......@@ -1066,6 +1115,16 @@ TEST_F(TestControlTest, Packet6ExchangeAddressAndPrefix) {
// Set number of received packets equal to number of iterations.
// This simulates no packet drops.
bool use_templates = false;
// Simulate the number of Solicit-Advertise-Request-Reply (SARR) echanges.
// The test function generates server's responses and passes it to the
// TestControl class methods for processing. The number of exchanges
// actually performed is returned in 'iterations_performed' argument. If
// processing is successful, the number of performed iterations should be
// equal to the number of exchanges specified with the '-n' command line
// parameter (10 in this case). All exchanged packets carry either IA_NA
// or IA_PD options to simulate the address and prefix acquisition with
// the single message and to verify that the IA_NA and IA_PD options
// returned by the server are processed correctly.
testPkt6Exchange(iterations_num, iterations_num, use_templates,
iterations_performed);
// Actual number of iterations should be 10.
......
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