Browse Source

[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
JINMEI Tatuya 12 years ago
parent
commit
07ecaaf470
1 changed files with 13 additions and 2 deletions
  1. 13 2
      src/lib/dns/tests/rdata_in_a_unittest.cc

+ 13 - 2
src/lib/dns/tests/rdata_in_a_unittest.cc

@@ -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";