From bab0e6d440f1c5dc6615bd1b72712c663929b87f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 7 Nov 2007 04:28:54 +0000 Subject: [PATCH] r16492@catbus: nickm | 2007-11-06 23:27:32 -0500 Fix unit tests so that an outdated nameserver means "Skip IPv6 tests", not "Abort." svn:r487 --- ChangeLog | 4 +++- test/regress_dns.c | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 294319ff..a78429ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,4 +38,6 @@ Changes in current version: o Small code cleanups in epoll_dispatch(). o Increase the maximum number of addresses read from a packet in evdns to 32. o Remove support for the rtsig method: it hasn't compiled for a while, and nobody seems to miss it very much. Let us know if there's a good reason to put it back in. - o Rename the "class" field in evdns_server_request to dns_question_class, so that it won't break compilation under C++. Use a macro so that old code won't break. Mark the macro as deprecated. \ No newline at end of file + o Rename the "class" field in evdns_server_request to dns_question_class, so that it won't break compilation under C++. Use a macro so that old code won't break. Mark the macro as deprecated. + o Fix DNS unit tests so that having a DNS server with broken IPv6 support is no longer cause for aborting the unit tests. + diff --git a/test/regress_dns.c b/test/regress_dns.c index 1b14adc6..0161de0e 100644 --- a/test/regress_dns.c +++ b/test/regress_dns.c @@ -64,15 +64,24 @@ #include "log.h" static int dns_ok = 0; +static int dns_err = 0; void dns_gethostbyname_cb(int result, char type, int count, int ttl, void *addresses, void *arg) { - dns_ok = 0; + dns_ok = dns_err = 0; - if (result != DNS_ERR_NONE) + if (result == DNS_ERR_TIMEOUT) { + fprintf(stdout, "[Timed out] "); + dns_err = result; goto out; + } + + if (result != DNS_ERR_NONE) { + fprintf(stdout, "[Error code %d] ", result); + goto out; + } fprintf(stderr, "type: %d, count: %d, ttl: %d: ", type, count, ttl); @@ -148,8 +157,10 @@ dns_gethostbyname6(void) if (dns_ok == DNS_IPv6_AAAA) { fprintf(stdout, "OK\n"); + } else if (!dns_ok && dns_err == DNS_ERR_TIMEOUT) { + fprintf(stdout, "SKIPPED\n"); } else { - fprintf(stdout, "FAILED\n"); + fprintf(stdout, "FAILED (%d)\n", dns_ok); exit(1); } }