Commit 4e8325e1 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[master] Merge branch 'trac2479'

parents a6865a76 238b3432
......@@ -1308,7 +1308,7 @@ AC_CONFIG_FILES([Makefile
tests/tools/badpacket/tests/Makefile
tests/tools/perfdhcp/Makefile
tests/tools/perfdhcp/tests/Makefile
tests/tools/perfdhcp/templates/Makefile
tests/tools/perfdhcp/tests/testdata/Makefile
dns++.pc
])
AC_OUTPUT([doc/version.ent
......
SUBDIRS = . tests templates
SUBDIRS = . tests
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/log -I$(top_builddir)/src/lib/log
......
SUBDIRS = .
SUBDIRS = . testdata
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(abs_srcdir)/testdata\"
AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
......
......@@ -185,6 +185,18 @@ public:
return ("");
}
/// \brief Get full path to a file in testdata directory.
///
/// \param filename filename being appended to absolute
/// path to testdata directory
///
/// \return full path to a file in testdata directory.
std::string getFullPath(const std::string& filename) const {
std::ostringstream stream;
stream << TEST_DATA_DIR << "/" << filename;
return (stream.str());
}
/// \brief Match requested options in the buffer with given list.
///
/// This method iterates through options provided in the buffer
......@@ -896,7 +908,7 @@ TEST_F(TestControlTest, Packet6) {
}
}
TEST_F(TestControlTest, DISABLED_Packet4Exchange) {
TEST_F(TestControlTest, Packet4Exchange) {
// 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.
......@@ -925,8 +937,8 @@ TEST_F(TestControlTest, DISABLED_Packet4Exchange) {
// Use templates for this test.
processCmdLine("perfdhcp -l " + loopback_iface
+ " -r 100 -R 20 -n 20 -D 10% -L 10547"
+ " -T ../templates/discover-example.hex"
+ " -T ../templates/request4-example.hex"
+ " -T " + getFullPath("discover-example.hex")
+ " -T " + getFullPath("request4-example.hex")
+ " 127.0.0.1");
// The number iterations is restricted by the percentage of
// dropped packets (-D 10%). We also have to bump up the number
......@@ -939,7 +951,7 @@ TEST_F(TestControlTest, DISABLED_Packet4Exchange) {
EXPECT_EQ(12, iterations_performed);
}
TEST_F(TestControlTest, DISABLED_Packet6Exchange) {
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.
......@@ -967,8 +979,8 @@ TEST_F(TestControlTest, DISABLED_Packet6Exchange) {
use_templates = true;
processCmdLine("perfdhcp -l " + loopback_iface
+ " -6 -r 100 -n 10 -R 20 -D 3 -L 10547"
+ " -T ../templates/solicit-example.hex"
+ " -T ../templates/request6-example.hex ::1");
+ " -T " + getFullPath("solicit-example.hex")
+ " -T " + getFullPath("request6-example.hex ::1"));
// For the first 3 packets we are simulating responses from server.
// For other packets we don't so packet as 4,5,6 will be dropped and
// then test should be interrupted and actual number of iterations will
......@@ -981,9 +993,9 @@ TEST_F(TestControlTest, DISABLED_Packet6Exchange) {
TEST_F(TestControlTest, PacketTemplates) {
std::vector<uint8_t> template1(256);
std::string file1("../templates/test1.hex");
std::string file1(getFullPath("test1.hex"));
std::vector<uint8_t> template2(233);
std::string file2("../templates/test2.hex");
std::string file2(getFullPath("test2.hex"));
for (int i = 0; i < template1.size(); ++i) {
template1[i] = static_cast<uint8_t>(random() % 256);
}
......@@ -1011,7 +1023,7 @@ TEST_F(TestControlTest, PacketTemplates) {
EXPECT_TRUE(std::equal(template2.begin(), template2.end(), buf2.begin()));
// Try to read template file with odd number of digits.
std::string file3("../templates/test3.hex");
std::string file3(getFullPath("test3.hex"));
// Size of the file is 2 times larger than binary data size and it is always
// even number. Substracting 1 makes file size odd.
ASSERT_TRUE(createTemplateFile(file3, template1, template1.size() * 2 - 1));
......@@ -1021,7 +1033,7 @@ TEST_F(TestControlTest, PacketTemplates) {
EXPECT_THROW(tc.initPacketTemplates(), isc::OutOfRange);
// Try to read empty file.
std::string file4("../templates/test4.hex");
std::string file4(getFullPath("test4.hex"));
ASSERT_TRUE(createTemplateFile(file4, template2, 0));
ASSERT_NO_THROW(
processCmdLine("perfdhcp -l 127.0.0.1 -T " + file4 + " all")
......@@ -1029,7 +1041,7 @@ TEST_F(TestControlTest, PacketTemplates) {
EXPECT_THROW(tc.initPacketTemplates(), isc::OutOfRange);
// Try reading file with non hexadecimal characters.
std::string file5("../templates/test5.hex");
std::string file5(getFullPath("test5.hex"));
ASSERT_TRUE(createTemplateFile(file5, template1, template1.size() * 2, true));
ASSERT_NO_THROW(
processCmdLine("perfdhcp -l 127.0.0.1 -T " + file5 + " all")
......
......@@ -4,7 +4,5 @@ SUBDIRS = .
# unit tests and have to be removed.
CLEANFILES = test1.hex test2.hex test3.hex test4.hex test5.hex
perfdhcpdir = $(pkgdatadir)
EXTRA_DIST = discover-example.hex request4-example.hex
EXTRA_DIST += solicit-example.hex request6-example.hex
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