diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d22d3ca..10d10b99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -489,9 +489,19 @@ if (NOT ENABLE_STUB_ONLY) set(CMAKE_REQUIRED_INCLUDES ${LIBUNBOUND_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES ${LIBUNBOUND_LIBRARIES}) - check_include_file(unbound-event.h HAVE_UNBOUND_EVENT_H) - check_symbol_exists(ub_ctx_create_ub_event "unbound-event.h" HAVE_UNBOUND_EVENT_API) - check_symbol_exists(ub_ctx_set_stub "unbound-event.h" HAVE_UB_CTX_SET_STUB) + + check_symbol_exists(ub_ctx_set_stub "unbound.h" HAVE_UB_CTX_SET_STUB) + + if (ENABLE_UNBOUND_EVENT_API) + check_include_file(unbound-event.h HAVE_UNBOUND_EVENT_H) + check_symbol_exists(ub_ctx_create_ub_event "unbound-event.h" HAVE_UNBOUND_EVENT_API) + endif () +else () + # Ensure we're not using libunbound items. + set(HAVE_LIBUNBOUND 0) + set(HAVE_UNBOUND_EVENT_H 0) + set(HAVE_UNBOUND_EVENT_API 0) + set(HAVE_UB_CTX_SET_STUB 0) endif () # Event loop extension diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c index 9816f8ff..723f7f81 100644 --- a/src/test/check_getdns_common.c +++ b/src/test/check_getdns_common.c @@ -57,6 +57,8 @@ int event_loop_type = 0; void extract_response(struct getdns_dict *response, struct extracted_response *ex_response) { int have_answer_type = 0; + int get_reply = 0; + uint32_t rcode; ck_assert_msg(response != NULL, "Response should not be NULL"); /* fprintf(stderr, "%s\n", getdns_pretty_print_dict(response)); */ @@ -103,10 +105,18 @@ void extract_response(struct getdns_dict *response, struct extracted_response *e ex_response->question = NULL; return; } + /* Work around dnsmasq issue in which NXDOMAIN AAAA responses + * are returned as NODATA. In such cases use the other A response + * which does have rcode NXDOMAIN. + */ + if (ex_response->status == GETDNS_RESPSTATUS_NO_NAME + && !getdns_dict_get_int(response, "/replies_tree/1/header/rcode", &rcode) + && rcode == GETDNS_RCODE_NXDOMAIN) + get_reply = 1; - ASSERT_RC(getdns_list_get_dict(ex_response->replies_tree, 0, &ex_response->replies_tree_sub_dict), - GETDNS_RETURN_GOOD, "Failed to extract \"replies_tree[0]\""); - ck_assert_msg(ex_response->replies_tree_sub_dict != NULL, "replies_tree[0] dict should not be NULL"); + ASSERT_RC(getdns_list_get_dict(ex_response->replies_tree, get_reply, &ex_response->replies_tree_sub_dict), + GETDNS_RETURN_GOOD, "Failed to extract \"replies_tree[#]\""); + ck_assert_msg(ex_response->replies_tree_sub_dict != NULL, "replies_tree[#] dict should not be NULL"); ASSERT_RC(getdns_dict_get_list(ex_response->replies_tree_sub_dict, "additional", &ex_response->additional), GETDNS_RETURN_GOOD, "Failed to extract \"additional\"");