From dc6bb0fa524858ee263abe2e964817dc30a15b1a Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 13 Dec 2018 15:24:37 +0100 Subject: [PATCH] Something wrong with /etc/hosts? --- src/test/check_getdns_address.h | 2 +- src/test/check_getdns_address_sync.h | 2 +- src/test/check_getdns_common.c | 10 +++++++--- src/test/check_getdns_common.h | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/test/check_getdns_address.h b/src/test/check_getdns_address.h index f898bdd8..10e4b7b2 100644 --- a/src/test/check_getdns_address.h +++ b/src/test/check_getdns_address.h @@ -192,7 +192,7 @@ CONTEXT_CREATE(TRUE); EVENT_BASE_CREATE; - ASSERT_RC(getdns_address(context, "localhost", NULL, + ASSERT_RC(getdns_address(context, "localhost.", NULL, &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); diff --git a/src/test/check_getdns_address_sync.h b/src/test/check_getdns_address_sync.h index f9e6b97d..07f8408f 100644 --- a/src/test/check_getdns_address_sync.h +++ b/src/test/check_getdns_address_sync.h @@ -127,7 +127,7 @@ CONTEXT_CREATE(TRUE); - ASSERT_RC(getdns_address_sync(context, "localhost", NULL, &response), + ASSERT_RC(getdns_address_sync(context, "localhost.", NULL, &response), GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()"); EXTRACT_LOCAL_RESPONSE; diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c index af894be5..a13e671a 100644 --- a/src/test/check_getdns_common.c +++ b/src/test/check_getdns_common.c @@ -70,6 +70,7 @@ void extract_response(struct getdns_dict *response, struct extracted_response *e * If it is absent, do not try to decompose the replies_tree, because the * answer most likely came not from DNS. */ + ex_response->reponse = response; have_answer_type = getdns_dict_get_int(response, "answer_type", &ex_response->top_answer_type) == GETDNS_RETURN_GOOD; @@ -233,11 +234,14 @@ void assert_address_in_answer(struct extracted_response *ex_response, int a, int */ void assert_address_in_just_address_answers(struct extracted_response *ex_response) { - size_t length; + size_t length = 0; + char *resp_str = ""; ASSERT_RC(getdns_list_get_length(ex_response->just_address_answers, &length), GETDNS_RETURN_GOOD, "Failed to extract \"just_address_answers\" length"); - - ck_assert_msg(length > 0, "Expected \"just_address_answers\" length > 0, got %d", length); + + if (length == 0) resp_str = getdns_pretty_print_dict(ex_response->response); + ck_assert_msg(length > 0, "Expected \"just_address_answers\" length > 0, got %d\n%s", length, resp_str); + if (length == 0) free(resp_str); } /* diff --git a/src/test/check_getdns_common.h b/src/test/check_getdns_common.h index 6fb3b555..c9691b59 100644 --- a/src/test/check_getdns_common.h +++ b/src/test/check_getdns_common.h @@ -41,6 +41,7 @@ struct extracted_response { uint32_t top_answer_type; + struct getdns_dict *response; struct getdns_bindata *top_canonical_name; struct getdns_list *just_address_answers; struct getdns_list *replies_full;