From: Ole John Aske Date: May 12 2011 6:49am Subject: bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch (ole.john.aske:3494) List-Archive: http://lists.mysql.com/commits/137164 Message-Id: <20110512064912.0D404222@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-5.1-telco-7.0-spj-scan-scan/ based on revid:ole.john.aske@stripped 3494 Ole John Aske 2011-05-12 [merge] Merge telco-7.0 -> SPJ modified: storage/ndb/src/common/portlib/NdbTCP.cpp === modified file 'storage/ndb/src/common/portlib/NdbTCP.cpp' --- a/storage/ndb/src/common/portlib/NdbTCP.cpp 2011-05-11 12:23:24 +0000 +++ b/storage/ndb/src/common/portlib/NdbTCP.cpp 2011-05-11 19:12:56 +0000 @@ -52,7 +52,7 @@ CHECK(const char* address, int expected_ { struct in_addr addr; - fprintf(stderr, "Checking '%s'\n", address); + fprintf(stderr, "Testing '%s'\n", address); int res= Ndb_getInAddr(&addr, address); @@ -72,12 +72,12 @@ CHECK(const char* address, int expected_ none.s_addr = INADDR_NONE; if (memcmp(&addr, &none, sizeof(none)) != 0) { - fprintf(stderr, "> didn't reurn INADDR_NONE after failure, " + fprintf(stderr, "> didn't return INADDR_NONE after failure, " "got: '%s', expected; '%s'\n", inet_ntoa(addr), inet_ntoa(none)); abort(); } - fprintf(stderr, "> got INADDR_NONE\n"); + fprintf(stderr, "> ok\n"); return; } @@ -95,7 +95,7 @@ CHECK(const char* address, int expected_ if (memcmp(&addr, &addr2, sizeof(struct in_addr)) != 0) { fprintf(stderr, "> numeric address '%s' didn't map to same value as " - "inet_addr: '%s'", inet_ntoa(addr2)); + "inet_addr: '%s'", address, inet_ntoa(addr2)); abort(); } fprintf(stderr, "> ok\n"); @@ -140,16 +140,53 @@ socket_library_end() #endif } +static bool +can_resolve_hostname(const char* name) +{ + fprintf(stderr, "Checking if '%s' can be used for testing\n", name); + struct addrinfo hints; + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; // Only IPv4 address + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + struct addrinfo* ai_list; + int err = getaddrinfo(name, NULL, &hints, &ai_list); + + if (err) + { + fprintf(stderr, "> '%s' -> error: %d '%s'\n", + name, err, gai_strerror(err)); + + if (err == EAI_NODATA || + err == EAI_NONAME) + { + // An OK error + fprintf(stderr, "> skipping tests with this name...\n"); + return false; + } + + // Another unhandled error + abort(); + } + + freeaddrinfo(ai_list); + + return true; +} + TAPTEST(NdbGetInAddr) { socket_library_init(); - CHECK("localhost", 0); + if (can_resolve_hostname("localhost")) + CHECK("localhost", 0); CHECK("127.0.0.1", 0, true); char hostname_buf[256]; - if (gethostname(hostname_buf, sizeof(hostname_buf)) == 0) + if (gethostname(hostname_buf, sizeof(hostname_buf)) == 0 && + can_resolve_hostname(hostname_buf)) { // Check this machines hostname CHECK(hostname_buf, 0); No bundle (reason: revision is a merge).