From 12b36ad9e060addde99d93d33bc6ac99d7e1ed50 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 28 Aug 2010 20:32:58 +0000 Subject: [PATCH] don't run the test that requires proper NX_DOMAIN support if the internet connection doesn't support it --- test/test_http_connection.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/test_http_connection.cpp b/test/test_http_connection.cpp index 0a285dce0..40069cb4c 100644 --- a/test/test_http_connection.cpp +++ b/test/test_http_connection.cpp @@ -158,12 +158,19 @@ void run_suite(std::string const& protocol, proxy_settings const& ps, int port) run_test(url_base + "test_file", 3216, 200, 1, error_code(), ps); run_test(url_base + "test_file.gz", 3216, 200, 1, error_code(), ps); run_test(url_base + "non-existing-file", -1, 404, 1, err(), ps); - // if we're going through an http proxy, we won't get the same error as if the hostname - // resolution failed - if ((ps.type == proxy_settings::http || ps.type == proxy_settings::http_pw) && protocol != "https") - run_test(protocol + "://non-existent-domain.se/non-existing-file", -1, 502, 1, err(), ps); - else - run_test(protocol + "://non-existent-domain.se/non-existing-file", -1, -1, 0, err(), ps); + + // only run the tests to handle NX_DOMAIN if we have a proper internet + // connection that doesn't inject false DNS responses (like Comcast does) + hostent* h = gethostbyname("non-existent-domain.se"); + if (h == 0 && h_errno == HOST_NOT_FOUND) + { + // if we're going through an http proxy, we won't get the same error as if the hostname + // resolution failed + if ((ps.type == proxy_settings::http || ps.type == proxy_settings::http_pw) && protocol != "https") + run_test(protocol + "://non-existent-domain.se/non-existing-file", -1, 502, 1, err(), ps); + else + run_test(protocol + "://non-existent-domain.se/non-existing-file", -1, -1, 0, err(), ps); + } if (ps.type != proxy_settings::none) stop_proxy(ps.port);