From 9aa1d067d26cfdab42dda93aef3874c28a4ec55a Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 21 Dec 2017 16:21:10 +0100 Subject: [PATCH] Detect dnsmasq and skip the unit test that fails with it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This actually resolves issue #300 Thanks Tim Rühsen and Konomi Kitten --- ChangeLog | 4 ++-- src/test/check_getdns_context_set_dns_transport.h | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 159b00ca..e5431a6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ * 2017-12-??: Version 1.3.0 - * Skip unit tests that fail with dnsmasq when the SKIP_DNSMASQ_ISSUE - variable is set. Thanks Konomi Kitten + * Bugfix #300: Detect dnsmasq and skip unit test that fails with it. + Thanks Tim Rühsen and Konomi Kitten * Specify default available cipher suites for authenticated TLS upstreams with getdns_context_set_tls_ciphers_list() An upstream specific available cipher suite may also be given diff --git a/src/test/check_getdns_context_set_dns_transport.h b/src/test/check_getdns_context_set_dns_transport.h index 9fb4956c..cecb7b47 100644 --- a/src/test/check_getdns_context_set_dns_transport.h +++ b/src/test/check_getdns_context_set_dns_transport.h @@ -144,6 +144,8 @@ uint16_t payload_size; uint8_t do_bit; getdns_transport_t trans; + int upstream_is_dnsmasq = 0; + getdns_bindata *version_str = NULL; /* Note that stricly this test just establishes that the requested transport and the reported transport are consistent, it does not guarentee which @@ -155,6 +157,17 @@ GETDNS_RETURN_GOOD, "Return code from getdns_context_set_resolution_type()"); ASSERT_RC(getdns_dict_set_int(extensions,"return_call_reporting", GETDNS_EXTENSION_TRUE), GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); + ASSERT_RC(getdns_dict_set_int(extensions,"specify_class", GETDNS_RRCLASS_CH), + GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); + + ASSERT_RC(getdns_general_sync(context, "version.bind.", GETDNS_RRTYPE_TXT, extensions, &response), + GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); + (void) getdns_dict_get_bindata(response, "/replies_tree/0/answer/0/rdata/txt_strings/0", &version_str); + upstream_is_dnsmasq = version_str && version_str->size > 7 && + strncmp((char *)version_str->data, "dnsmasq", 7) == 0; + + ASSERT_RC(getdns_dict_set_int(extensions,"specify_class", GETDNS_RRCLASS_IN), + GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()"); /* Request a response that should be truncated over UDP */ ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_ONLY), @@ -187,7 +200,7 @@ ASSERT_RC(type, GETDNS_RESOLUTION_STUB, "Query did not use stub mode"); ASSERT_RC(getdns_dict_get_int(response, "/replies_tree/0/header/tc", &tc), GETDNS_RETURN_GOOD, "Failed to extract \"tc\""); - if (!getenv("SKIP_DNSMASQ_ISSUE")) { + if (!upstream_is_dnsmasq) { ASSERT_RC(tc, 1, "Packet not truncated as expected"); /* Re-do over TCP */