From: Brian Aker Date: Sun, 20 Jan 2013 12:42:20 +0000 (-0500) Subject: Clarification in DNS test. X-Git-Tag: 1.0.16~3^2~7 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=feefbfb339a8c31c9a54d938180b153fe60d269b;p=awesomized%2Flibmemcached Clarification in DNS test. --- diff --git a/ChangeLog b/ChangeLog index 26a2dc29..fa642182 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,6 @@ - +1.0.16 * Added support to do two part shutdown of socket. - 1.0.15 Mon Dec 17 07:25:44 EST 2012 * Added support for Murmur3 (HASHKIT_HASH_MURMUR3) * Portability fixes. diff --git a/bootstrap.sh b/bootstrap.sh index ca36e37c..fdc43f99 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2012 Brian Aker +# Copyright (C) 2012-2013 Brian Aker # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -414,7 +414,8 @@ function restore_BUILD () OLD_CONFIGURE_ARG= OLD_MAKE= OLD_TESTS_ENVIRONMENT= - echo "reset happened" + + export -n CC CXX } function push_PREFIX_ARG () @@ -625,7 +626,29 @@ function check_mingw () return 0 } -function make_skeleton_mingw () +function check_clang () +{ + command_exists 'clang' + ret=$? + if [ "$ret" -ne 0 ]; then + return 1 + fi + + return 0 +} + +function check_clang_analyzer () +{ + command_exists 'scan-build' + ret=$? + if [ "$ret" -ne 0 ]; then + return 1 + fi + + return 0 +} + +function make_skeleton () { run_configure ret=$? @@ -642,8 +665,6 @@ function make_skeleton_mingw () if command_exists 'wine'; then TESTS_ENVIRONMENT='wine' fi - elif command_exists 'wineconsole'; then - TESTS_ENVIRONMENT='wineconsole --backend=curses' fi if [[ -n "$TESTS_ENVIRONMENT" ]]; then @@ -662,9 +683,8 @@ function make_skeleton_mingw () function make_for_mingw () { - check_mingw if ! check_mingw; then - die 'mingw64 tools were not found' + return 1 fi # Make sure it is clean @@ -678,11 +698,74 @@ function make_for_mingw () CONFIGURE='mingw64-configure' MAKE='mingw64-make' - CONFIGURE_ARGS='--enable-static' + CONFIGURE_ARGS='--enable-static --disable-shared' + + make_skeleton + ret=$? + + restore_BUILD + + return $ret +} + +function make_for_clang () +{ + if ! check_clang; then + return 1 + fi + + # Make sure it is clean + if [ -f Makefile -o -f configure ]; then + make_maintainer_clean + fi + + run_autoreconf + + save_BUILD - make_skeleton_mingw + CC=clang CXX=clang++ + export CC CXX + + make_skeleton + ret=$? + + make_target 'check' + + restore_BUILD + + return $ret +} + +function make_for_clang_analyzer () +{ + if ! check_clang; then + return 1 + fi + + if ! check_clang_analyzer; then + die 'clang-analyzer was not found' + fi + + # Make sure it is clean + if [ -f Makefile -o -f configure ]; then + make_maintainer_clean + fi + + run_autoreconf + + save_BUILD + + CC=clang CXX=clang++ + export CC CXX + CONFIGURE_ARGS='--enable-debug' + + make_skeleton ret=$? + make_target 'clean' 'warn' + + scan-build -o clang-html make -j4 -k + restore_BUILD return $ret @@ -710,6 +793,8 @@ function make_universe () make_valgrind make_gdb make_rpm + make_for_clang + make_for_clang_analyzer if [ check_mingw -eq 0 ]; then make_for_mingw @@ -883,9 +968,9 @@ function make_target () if [ $ret -ne 0 ]; then if [ -n "$2" ]; then - warn "Cannot execute $MAKE $1: $ret" + warn "Failed to execute $MAKE $1: $ret" else - die "Cannot execute $MAKE $1: $ret" + die "Failed to execute $MAKE $1: $ret" fi fi @@ -1333,6 +1418,10 @@ function check_make_target() ;; 'make_default') ;; + 'clang') + ;; + 'clang-analyzer') + ;; 'test-*') ;; 'valgrind-*') @@ -1417,15 +1506,32 @@ function bootstrap () 'make_default') make_default ;; + 'clang') + if ! check_clang; then + die "clang was not found" + fi + + if ! make_for_clang; then + die "Failed to build clang: $?" + fi + ;; + 'clang-analyzer') + if ! check_clang_analyzer; then + die "clang-analyzer was not found" + fi + if ! check_clang; then + die "clang was not found" + fi + + if ! make_for_clang_analyzer; then + die "Failed to build clang-analyzer: $?" + fi + ;; 'mingw') - check_mingw if ! check_mingw; then die "mingw was not found" fi - make_for_mingw - check_ret=$? - if ! make_for_mingw; then die "Failed to build mingw: $?" fi diff --git a/libtest/dns.cc b/libtest/dns.cc index 3623c4a1..e8e1e7fc 100644 --- a/libtest/dns.cc +++ b/libtest/dns.cc @@ -45,16 +45,29 @@ namespace libtest { bool lookup(const char* host) { - assert(host); bool success= false; - struct addrinfo *addrinfo= NULL; - - int limit= 5; - while (limit--) + if (host) { - int ret; - if ((ret= getaddrinfo(host, NULL, NULL, &(addrinfo)))) + assert(host); + struct addrinfo *addrinfo= NULL; + + int limit= 5; + while (--limit and success == false) { + if (addrinfo) + { + freeaddrinfo(addrinfo); + addrinfo= NULL; + } + + int ret; + fprintf(stderr, ":%s:\n", host); + if ((ret= getaddrinfo(host, NULL, NULL, &addrinfo)) == 0) + { + success= true; + break; + } + switch (ret) { case EAI_AGAIN: @@ -64,16 +77,16 @@ bool lookup(const char* host) default: break; } + + break; } - else + + if (addrinfo) { - success= true; - break; + freeaddrinfo(addrinfo); } } - freeaddrinfo(addrinfo); - return success; } @@ -87,7 +100,7 @@ bool check_dns() if (lookup("does_not_exist.gearman.info")) // This should fail, if it passes,... { - return false; + fatal_assert("Your service provider sucks and is providing bogus DNS. You might be in an airport."); } return true; diff --git a/libtest/unittest.cc b/libtest/unittest.cc index 6b11c3b0..8cc8a65f 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -866,11 +866,8 @@ static test_return_t lookup_true_TEST(void *) static test_return_t lookup_false_TEST(void *) { - if (libtest::lookup("does_not_exist.gearman.info")) - { - Error << "Broken DNS server detected"; - return TEST_SKIPPED; - } + SKIP_IF_(libtest::lookup("does_not_exist.gearman.info"), + "Broken DNS server detected"); return TEST_SUCCESS; }