Commit 07ecaaf4 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[master] customize check logic against extra space for in::A based on inet_pton

this will avoid unittest failure on netbsd, whose inet_pton behaves
differently than others:
http://git.bind10.isc.org/~tester/builder//BIND10/20130226211101-NetBSD6-i386-GCC/logs/unittests.out
parent 66535ab5
......@@ -30,6 +30,9 @@
#include <sstream>
#include <arpa/inet.h>
#include <sys/socket.h>
using isc::UnitTestUtil;
using namespace std;
using namespace isc::dns;
......@@ -67,13 +70,21 @@ TEST_F(Rdata_IN_A_Test, createFromText) {
// or any meaningless text as an IP address
checkFromTextIN_A("xxx");
// NetBSD's inet_pton accepts trailing space after an IPv4 address, which
// would confuse some of the tests below. We check the case differently
// in these cases depending on the strictness of inet_pton (most
// implementations seem to be stricter).
uint8_t v4addr_buf[4];
const bool reject_extra_space =
inet_pton(AF_INET, "192.0.2.1 ", v4addr_buf) == 0;
// trailing white space: only string version throws
checkFromTextIN_A("192.0.2.1 ", true, false);
checkFromTextIN_A("192.0.2.1 ", reject_extra_space, false);
// same for beginning white space.
checkFromTextIN_A(" 192.0.2.1", true, false);
// same for trailing non-space garbage (note that lexer version still
// ignore it; it's expected to be detected at a higher layer).
checkFromTextIN_A("192.0.2.1 xxx", true, false);
checkFromTextIN_A("192.0.2.1 xxx", reject_extra_space, false);
// nul character after a valid textual representation.
string nul_after_addr = "192.0.2.1";
......
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