mirror of https://github.com/getdnsapi/getdns.git
Updates to unit tests and tpkg
This commit is contained in:
parent
5f225d6be3
commit
98d636b99d
|
@ -1645,8 +1645,7 @@ getdns_context_set_namespaces(getdns_context *context,
|
|||
size_t i;
|
||||
getdns_return_t r = GETDNS_RETURN_GOOD;
|
||||
|
||||
if (!context)
|
||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
|
||||
if (namespace_count == 0 || namespaces == NULL)
|
||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
|
@ -1659,7 +1658,7 @@ getdns_context_set_namespaces(getdns_context *context,
|
|||
|
||||
else if (namespaces[i] != GETDNS_NAMESPACE_DNS &&
|
||||
namespaces[i] != GETDNS_NAMESPACE_LOCALNAMES)
|
||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
}
|
||||
GETDNS_FREE(context->my_mf, context->namespaces);
|
||||
|
||||
|
@ -1682,7 +1681,8 @@ getdns_set_base_dns_transports(
|
|||
size_t i;
|
||||
getdns_transport_list_t *new_transports;
|
||||
|
||||
if (!context || transport_count == 0 || transports == NULL)
|
||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
if (transport_count == 0 || !transports)
|
||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
|
||||
/* Check for valid transports and that they are used only once*/
|
||||
|
@ -1693,11 +1693,11 @@ getdns_set_base_dns_transports(
|
|||
case GETDNS_TRANSPORT_UDP: u++; break;
|
||||
case GETDNS_TRANSPORT_TCP: t++; break;
|
||||
case GETDNS_TRANSPORT_TLS: l++; break;
|
||||
default: return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
default: return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
}
|
||||
}
|
||||
if ( u>1 || t>1 || l>1)
|
||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
|
||||
if (!(new_transports = GETDNS_XMALLOC(context->my_mf,
|
||||
getdns_transport_list_t, transport_count)))
|
||||
|
@ -1770,18 +1770,17 @@ getdns_context_set_dns_transport(
|
|||
size_t count = 2;
|
||||
getdns_transport_list_t *new_transports;
|
||||
|
||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
|
||||
if (value == GETDNS_TRANSPORT_UDP_ONLY ||
|
||||
value == GETDNS_TRANSPORT_TCP_ONLY ||
|
||||
value == GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN ||
|
||||
value == GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN)
|
||||
count = 1;
|
||||
|
||||
if (!context)
|
||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||
|
||||
if (!(new_transports = GETDNS_XMALLOC(
|
||||
context->my_mf, getdns_transport_list_t, count)))
|
||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
context->my_mf, getdns_transport_list_t, count)))
|
||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
|
||||
if (context->dns_transports)
|
||||
GETDNS_FREE(context->my_mf, context->dns_transports);
|
||||
|
|
|
@ -127,7 +127,7 @@ typedef struct getdns_upstream {
|
|||
int fd;
|
||||
getdns_transport_list_t transport;
|
||||
SSL* tls_obj;
|
||||
SSL_SESSION* tls_session;
|
||||
SSL_SESSION* tls_session;
|
||||
getdns_tls_hs_state_t tls_hs_state;
|
||||
getdns_eventloop_event event;
|
||||
getdns_eventloop *loop;
|
||||
|
|
|
@ -242,7 +242,7 @@ check_getdns.lo check_getdns.o: $(srcdir)/check_getdns.c ../getdns/getdns.h $(sr
|
|||
$(srcdir)/check_getdns_context_set_timeout.h \
|
||||
$(srcdir)/check_getdns_context_set_upstream_recursive_servers.h \
|
||||
$(srcdir)/check_getdns_service.h $(srcdir)/check_getdns_service_sync.h \
|
||||
$(srcdir)/check_getdns_transport.h
|
||||
$(srcdir)/check_getdns_transport.h $(srcdir)/check_getdns_context_set_dns_transport.h
|
||||
check_getdns_common.lo check_getdns_common.o: $(srcdir)/check_getdns_common.c ../getdns/getdns.h \
|
||||
../config.h $(srcdir)/check_getdns_common.h ../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_eventloop.h
|
||||
|
|
|
@ -33,125 +33,129 @@
|
|||
#include <check.h>
|
||||
#include "getdns/getdns.h"
|
||||
#include "check_getdns_common.h"
|
||||
#include "check_getdns_general.h"
|
||||
#include "check_getdns_general_sync.h"
|
||||
#include "check_getdns_address.h"
|
||||
#include "check_getdns_address_sync.h"
|
||||
#include "check_getdns_hostname.h"
|
||||
#include "check_getdns_hostname_sync.h"
|
||||
#include "check_getdns_cancel_callback.h"
|
||||
#include "check_getdns_context_create.h"
|
||||
#include "check_getdns_context_destroy.h"
|
||||
#include "check_getdns_cancel_callback.h"
|
||||
#include "check_getdns_list_get_length.h"
|
||||
#include "check_getdns_list_get_data_type.h"
|
||||
#include "check_getdns_list_get_dict.h"
|
||||
#include "check_getdns_list_get_list.h"
|
||||
#include "check_getdns_list_get_int.h"
|
||||
#include "check_getdns_list_get_bindata.h"
|
||||
#include "check_getdns_dict_get_names.h"
|
||||
#include "check_getdns_dict_get_data_type.h"
|
||||
#include "check_getdns_dict_get_dict.h"
|
||||
#include "check_getdns_dict_get_list.h"
|
||||
#include "check_getdns_dict_get_bindata.h"
|
||||
#include "check_getdns_dict_get_int.h"
|
||||
#include "check_getdns_dict_destroy.h"
|
||||
#include "check_getdns_dict_set_dict.h"
|
||||
#include "check_getdns_dict_set_list.h"
|
||||
#include "check_getdns_dict_set_bindata.h"
|
||||
#include "check_getdns_dict_set_int.h"
|
||||
#include "check_getdns_convert_ulabel_to_alabel.h"
|
||||
#include "check_getdns_convert_alabel_to_ulabel.h"
|
||||
#include "check_getdns_pretty_print_dict.h"
|
||||
#include "check_getdns_display_ip_address.h"
|
||||
#include "check_getdns_context_set_context_update_callback.h"
|
||||
#include "check_getdns_context_set_dns_transport.h"
|
||||
#include "check_getdns_context_set_timeout.h"
|
||||
#include "check_getdns_context_set_upstream_recursive_servers.h"
|
||||
#include "check_getdns_convert_alabel_to_ulabel.h"
|
||||
#include "check_getdns_convert_ulabel_to_alabel.h"
|
||||
#include "check_getdns_dict_destroy.h"
|
||||
#include "check_getdns_dict_get_bindata.h"
|
||||
#include "check_getdns_dict_get_data_type.h"
|
||||
#include "check_getdns_dict_get_dict.h"
|
||||
#include "check_getdns_dict_get_int.h"
|
||||
#include "check_getdns_dict_get_list.h"
|
||||
#include "check_getdns_dict_get_names.h"
|
||||
#include "check_getdns_dict_set_bindata.h"
|
||||
#include "check_getdns_dict_set_dict.h"
|
||||
#include "check_getdns_dict_set_int.h"
|
||||
#include "check_getdns_dict_set_list.h"
|
||||
#include "check_getdns_display_ip_address.h"
|
||||
#include "check_getdns_general.h"
|
||||
#include "check_getdns_general_sync.h"
|
||||
#include "check_getdns_hostname.h"
|
||||
#include "check_getdns_hostname_sync.h"
|
||||
#include "check_getdns_list_get_bindata.h"
|
||||
#include "check_getdns_list_get_data_type.h"
|
||||
#include "check_getdns_list_get_dict.h"
|
||||
#include "check_getdns_list_get_int.h"
|
||||
#include "check_getdns_list_get_length.h"
|
||||
#include "check_getdns_list_get_list.h"
|
||||
#include "check_getdns_pretty_print_dict.h"
|
||||
#include "check_getdns_service.h"
|
||||
#include "check_getdns_service_sync.h"
|
||||
#include "check_getdns_transport.h"
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char** argv)
|
||||
{
|
||||
int number_failed;
|
||||
SRunner *sr ;
|
||||
|
||||
Suite *getdns_general_suite(void);
|
||||
Suite *getdns_general_sync_suite(void);
|
||||
Suite *getdns_address_suite(void);
|
||||
Suite *getdns_address_sync_suite(void);
|
||||
Suite *getdns_hostname_suite(void);
|
||||
Suite *getdns_hostname_sync_suite(void);
|
||||
Suite *getdns_cancel_callback_suite(void);
|
||||
Suite *getdns_context_create_suite(void);
|
||||
Suite *getdns_context_destroy_suite(void);
|
||||
Suite *getdns_cancel_callback_suite(void);
|
||||
Suite *getdns_list_get_length_suite(void);
|
||||
Suite *getdns_list_get_dict_suite(void);
|
||||
Suite *getdns_list_get_list_suite(void);
|
||||
Suite *getdns_list_get_int_suite(void);
|
||||
Suite *getdns_list_get_data_type_suite(void);
|
||||
Suite *getdns_list_get_bindata_suite(void);
|
||||
Suite *getdns_dict_get_names_suite(void);
|
||||
Suite *getdns_context_set_context_update_callback_suite(void);
|
||||
Suite *getdns_context_set_dns_transport_suite(void);
|
||||
Suite *getdns_context_set_timeout_suite(void);
|
||||
Suite *getdns_context_set_upstream_recursive_servers_suite(void);
|
||||
Suite *getdns_convert_alabel_to_ulabel_suite(void);
|
||||
Suite *getdns_convert_ulabel_to_alabel_suite(void);
|
||||
Suite *getdns_dict_destroy_suite(void);
|
||||
Suite *getdns_dict_get_bindata_suite(void);
|
||||
Suite *getdns_dict_get_data_type_suite(void);
|
||||
Suite *getdns_dict_get_dict_suite(void);
|
||||
Suite *getdns_dict_get_list_suite(void);
|
||||
Suite *getdns_dict_get_dict_suite(void);
|
||||
Suite *getdns_dict_get_bindata_suite(void);
|
||||
Suite *getdns_dict_get_int_suite(void);
|
||||
Suite *getdns_dict_destroy_suite(void);
|
||||
Suite *getdns_dict_set_dict_suite(void);
|
||||
Suite *getdns_dict_set_list_suite(void);
|
||||
Suite *getdns_dict_get_list_suite(void);
|
||||
Suite *getdns_dict_get_names_suite(void);
|
||||
Suite *getdns_dict_set_bindata_suite(void);
|
||||
Suite *getdns_dict_set_dict_suite(void);
|
||||
Suite *getdns_dict_set_int_suite(void);
|
||||
Suite *getdns_convert_ulabel_to_alabel_suite(void);
|
||||
Suite *getdns_convert_alabel_to_ulabel_suite(void);
|
||||
Suite *getdns_pretty_print_dict_suite(void);
|
||||
Suite *getdns_dict_set_list_suite(void);
|
||||
Suite *getdns_display_ip_address_suite(void);
|
||||
Suite *getdns_context_set_context_update_callback_suite(void);
|
||||
Suite *getdns_context_set_upstream_recursive_servers_suite(void);
|
||||
Suite *getdns_general_suite(void);
|
||||
Suite *getdns_general_sync_suite(void);
|
||||
Suite *getdns_hostname_suite(void);
|
||||
Suite *getdns_hostname_sync_suite(void);
|
||||
Suite *getdns_list_get_bindata_suite(void);
|
||||
Suite *getdns_list_get_data_type_suite(void);
|
||||
Suite *getdns_list_get_dict_suite(void);
|
||||
Suite *getdns_list_get_int_suite(void);
|
||||
Suite *getdns_list_get_length_suite(void);
|
||||
Suite *getdns_list_get_list_suite(void);
|
||||
Suite *getdns_pretty_print_dict_suite(void);
|
||||
Suite *getdns_service_suite(void);
|
||||
Suite *getdns_service_sync_suite(void);
|
||||
Suite *getdns_context_set_timeout_suite(void);
|
||||
Suite *getdns_transport_suite(void);
|
||||
|
||||
sr = srunner_create(getdns_general_suite());
|
||||
srunner_add_suite(sr, getdns_general_sync_suite());
|
||||
srunner_add_suite(sr, getdns_address_suite());
|
||||
sr = srunner_create(getdns_address_suite());
|
||||
srunner_add_suite(sr, getdns_address_sync_suite());
|
||||
srunner_add_suite(sr, getdns_hostname_suite());
|
||||
srunner_add_suite(sr, getdns_hostname_sync_suite());
|
||||
srunner_add_suite(sr, getdns_cancel_callback_suite());
|
||||
srunner_add_suite(sr, getdns_context_create_suite());
|
||||
srunner_add_suite(sr, getdns_context_destroy_suite());
|
||||
srunner_add_suite(sr, getdns_cancel_callback_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_length_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_data_type_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_dict_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_list_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_int_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_bindata_suite());
|
||||
srunner_add_suite(sr, getdns_dict_get_names_suite());
|
||||
srunner_add_suite(sr, getdns_context_set_context_update_callback_suite());
|
||||
srunner_add_suite(sr, getdns_context_set_dns_transport_suite());
|
||||
srunner_add_suite(sr, getdns_context_set_timeout_suite());
|
||||
srunner_add_suite(sr, getdns_context_set_upstream_recursive_servers_suite());
|
||||
srunner_add_suite(sr, getdns_convert_alabel_to_ulabel_suite());
|
||||
srunner_add_suite(sr, getdns_convert_ulabel_to_alabel_suite());
|
||||
srunner_add_suite(sr, getdns_dict_destroy_suite());
|
||||
srunner_add_suite(sr, getdns_dict_get_bindata_suite());
|
||||
srunner_add_suite(sr, getdns_dict_get_data_type_suite());
|
||||
srunner_add_suite(sr, getdns_dict_get_dict_suite());
|
||||
srunner_add_suite(sr, getdns_dict_get_list_suite());
|
||||
srunner_add_suite(sr, getdns_dict_get_bindata_suite());
|
||||
srunner_add_suite(sr, getdns_dict_get_int_suite());
|
||||
srunner_add_suite(sr, getdns_dict_destroy_suite());
|
||||
srunner_add_suite(sr, getdns_dict_set_dict_suite());
|
||||
srunner_add_suite(sr, getdns_dict_set_list_suite());
|
||||
srunner_add_suite(sr, getdns_dict_get_list_suite());
|
||||
srunner_add_suite(sr, getdns_dict_get_names_suite());
|
||||
srunner_add_suite(sr, getdns_dict_set_bindata_suite());
|
||||
srunner_add_suite(sr, getdns_dict_set_dict_suite());
|
||||
srunner_add_suite(sr, getdns_dict_set_int_suite());
|
||||
srunner_add_suite(sr, getdns_convert_ulabel_to_alabel_suite());
|
||||
srunner_add_suite(sr, getdns_convert_alabel_to_ulabel_suite());
|
||||
srunner_add_suite(sr, getdns_dict_set_list_suite());
|
||||
srunner_add_suite(sr, getdns_display_ip_address_suite());
|
||||
srunner_add_suite(sr, getdns_general_suite());
|
||||
srunner_add_suite(sr, getdns_general_sync_suite());
|
||||
srunner_add_suite(sr, getdns_hostname_suite());
|
||||
srunner_add_suite(sr, getdns_hostname_sync_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_bindata_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_data_type_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_dict_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_int_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_length_suite());
|
||||
srunner_add_suite(sr, getdns_list_get_list_suite());
|
||||
srunner_add_suite(sr, getdns_pretty_print_dict_suite());
|
||||
srunner_add_suite(sr,getdns_display_ip_address_suite());
|
||||
srunner_add_suite(sr,getdns_context_set_context_update_callback_suite());
|
||||
srunner_add_suite(sr,getdns_context_set_timeout_suite());
|
||||
srunner_add_suite(sr,getdns_context_set_upstream_recursive_servers_suite());
|
||||
srunner_add_suite(sr,getdns_service_suite());
|
||||
srunner_add_suite(sr,getdns_service_sync_suite());
|
||||
srunner_add_suite(sr,getdns_transport_suite());
|
||||
|
||||
srunner_add_suite(sr, getdns_service_suite());
|
||||
srunner_add_suite(sr, getdns_service_sync_suite());
|
||||
srunner_add_suite(sr, getdns_transport_suite());
|
||||
|
||||
srunner_run_all(sr, CK_NORMAL);
|
||||
number_failed = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
|
|
|
@ -412,7 +412,28 @@
|
|||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_context_set_context_update_callback_22)
|
||||
{
|
||||
/*
|
||||
* value is NULL
|
||||
* expect: GETDNS_RETURN_INVALID_PARAMETER
|
||||
*/
|
||||
|
||||
struct getdns_context *context = NULL;
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
|
||||
|
||||
expected_changed_item = GETDNS_CONTEXT_CODE_IDLE_TIMEOUT;
|
||||
|
||||
ASSERT_RC(getdns_context_set_idle_timeout(context, 100),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()");
|
||||
|
||||
CONTEXT_DESTROY;
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite *
|
||||
getdns_context_set_context_update_callback_suite (void)
|
||||
|
@ -440,6 +461,7 @@
|
|||
tcase_add_test(tc_pos, getdns_context_set_context_update_callback_19);
|
||||
tcase_add_test(tc_pos, getdns_context_set_context_update_callback_20);
|
||||
tcase_add_test(tc_pos, getdns_context_set_context_update_callback_21);
|
||||
tcase_add_test(tc_pos, getdns_context_set_context_update_callback_22);
|
||||
suite_add_tcase(s, tc_pos);
|
||||
|
||||
return s;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
/*
|
||||
**************************************************************************
|
||||
* *
|
||||
* T E S T S F O R G E T D N S _ C O N T E X T _ S E T _ C O N T E X T _ U P D A T E _ C A L L B A C K *
|
||||
* T E S T S F O R G E T D N S _ C O N T E X T _ S E T _ D N S _ T R A N S P O R T *
|
||||
* *
|
||||
**************************************************************************
|
||||
*/
|
||||
|
@ -46,7 +46,7 @@
|
|||
uint16_t value = 302;
|
||||
|
||||
ASSERT_RC(getdns_context_set_dns_transport(context, value),
|
||||
GETDNS_RETURN_BAD_CONTEXT, "Return code from getdns_context_set_dns_transport()");
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_dns_transport()");
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
@ -71,108 +71,222 @@
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_context_set_dns_transport_3)
|
||||
{
|
||||
/*
|
||||
* Call getdns_context_set_dns_transport() with value = GETDNS_TRANSPORT_UDP_ONLY
|
||||
* Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
|
||||
* getdns_context_set_resolution_type() to GETDNS_RESOLUTION_STUB
|
||||
* expect: GETDNS_CONTEXT_CODE_RESOLUTION_TYPE
|
||||
*/
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
uint32_t ancount;
|
||||
uint32_t arcount;
|
||||
uint32_t nscount;
|
||||
uint32_t tcp_ancount;
|
||||
uint32_t tcp_arcount;
|
||||
uint32_t tcp_nscount;
|
||||
int udp_sum;
|
||||
int tcp_sum;
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
START_TEST (getdns_context_set_dns_transport_list_3)
|
||||
{
|
||||
/*
|
||||
* context is NULL
|
||||
* expect: GETDNS_RETURN_INVALID_PARAMETER
|
||||
*/
|
||||
|
||||
struct getdns_context *context = NULL;
|
||||
getdns_transport_list_t transports[1];
|
||||
transports[0] = GETDNS_TRANSPORT_UDP;
|
||||
size_t transport_count = sizeof(transports);
|
||||
|
||||
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_ONLY),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
|
||||
|
||||
ASSERT_RC(getdns_context_set_dns_transport_list(context, transport_count, transports),
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_dns_transport()");
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "google.com", 255, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
EXTRACT_RESPONSE;
|
||||
START_TEST (getdns_context_set_dns_transport_list_4)
|
||||
{
|
||||
/*
|
||||
* list is invalid
|
||||
* expect: GETDNS_RETURN_CONTEXT_UPDATE_FAIL
|
||||
*/
|
||||
|
||||
struct getdns_context *context = NULL;
|
||||
getdns_transport_list_t transports[1];
|
||||
transports[0] = GETDNS_TRANSPORT_UDP;
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(ex_response.header, "ancount", &ancount),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(ex_response.header, "arcount", &arcount),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(ex_response.header, "nscount", &nscount),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
|
||||
|
||||
printf("the resp is %s\n", getdns_pretty_print_dict(response));
|
||||
printf("the ancount is %d\n", ancount);
|
||||
printf("the arcount is %d\n", arcount);
|
||||
printf("the nscount is %d\n", nscount);
|
||||
udp_sum = ancount + arcount + nscount;
|
||||
printf("the udp_sum is %d\n", udp_sum);
|
||||
|
||||
//tcp count
|
||||
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_TCP_ONLY),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
|
||||
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "google.com", 255, NULL, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
struct extracted_response ex_response1;
|
||||
extract_response(response, &ex_response1);
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(ex_response1.header, "ancount", &tcp_ancount),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(ex_response1.header, "arcount", &tcp_arcount),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(ex_response1.header, "nscount", &tcp_nscount),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
|
||||
|
||||
printf("the resp is %s\n", getdns_pretty_print_dict(response));
|
||||
|
||||
printf("the tcp_ancount is %d\n", tcp_ancount);
|
||||
printf("the tcp_arcount is %d\n", tcp_arcount);
|
||||
printf("the tcp_nscount is %d\n", tcp_nscount);
|
||||
tcp_sum = tcp_ancount + tcp_arcount + tcp_nscount;
|
||||
printf("the tcp_sum is %d\n", udp_sum);
|
||||
ASSERT_RC(getdns_context_set_dns_transport_list(context, 0, NULL),
|
||||
GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_dns_transport()");
|
||||
ASSERT_RC(getdns_context_set_dns_transport_list(context, 1, NULL),
|
||||
GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_dns_transport()");
|
||||
ASSERT_RC(getdns_context_set_dns_transport_list(context, 0, transports),
|
||||
GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_dns_transport()");
|
||||
ASSERT_RC(getdns_context_set_dns_transport_list(context, 2, transports),
|
||||
GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_dns_transport()");
|
||||
|
||||
CONTEXT_DESTROY;
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_context_set_dns_transport_stub_5)
|
||||
{
|
||||
/*
|
||||
* Request answer larger then 512 bytes but set UDP payload to that
|
||||
* Call getdns_context_set_dns_transport() with value = GETDNS_TRANSPORT_UDP_ONLY
|
||||
* expect: Message uses UDP but is truncated
|
||||
* Call getdns_context_set_dns_transport() with value = GETDNS_TRANSPORT_TCP_ONLY
|
||||
* expect: Message uses TCP and is not truncated
|
||||
* Call getdns_context_set_dns_transport() with value = GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP
|
||||
* expect: Message uses TCP and is not truncated
|
||||
*/
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
struct getdns_dict *extensions = getdns_dict_create();
|
||||
uint32_t tc;
|
||||
uint32_t transport;
|
||||
|
||||
/* Note that stricly this test just establishes that the requested transport
|
||||
and the reported transport are consistent, it does not guarentee which
|
||||
transport is used on the wire...*/
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
ASSERT_RC(getdns_context_set_resolution_type(context, GETDNS_RESOLUTION_STUB),
|
||||
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()");
|
||||
|
||||
/* Request a response that should be truncated over UDP */
|
||||
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_ONLY),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
|
||||
ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_maximum_udp_payload_size()");
|
||||
ASSERT_RC(getdns_context_set_edns_do_bit(context, 1),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_do_bit()");
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "getdnsapi.net", 48, extensions, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(response, "/call_reporting/0/transport", &transport),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"transport\"");
|
||||
ASSERT_RC(transport, GETDNS_TRANSPORT_UDP, "Query did not go over UDP");
|
||||
ASSERT_RC(getdns_dict_get_int(response, "/replies_tree/0/header/tc", &tc),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"tc\"");
|
||||
ASSERT_RC(tc, 1, "Packet not trucated as expected");
|
||||
|
||||
/* Re-do over TCP */
|
||||
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_TCP_ONLY),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "getdnsapi.net", 48, extensions, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(response, "/call_reporting/0/transport", &transport),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"transport\"");
|
||||
ASSERT_RC(transport, GETDNS_TRANSPORT_TCP, "Query did not go over TCP");
|
||||
ASSERT_RC(getdns_dict_get_int(response, "/replies_tree/0/header/tc", &tc),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"tc\"");
|
||||
ASSERT_RC(tc, 0, "Packet trucated - not as expected");
|
||||
|
||||
/* Now let it fall back to TCP */
|
||||
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
|
||||
ASSERT_RC(getdns_general_sync(context, "getdnsapi.net", 48, extensions, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(response, "/call_reporting/0/transport", &transport),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"transport\"");
|
||||
ASSERT_RC(transport, GETDNS_TRANSPORT_TCP, "Query did not go over TCP");
|
||||
ASSERT_RC(getdns_dict_get_int(response, "/replies_tree/0/header/tc", &tc),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"tc\"");
|
||||
ASSERT_RC(tc, 0, "Packet trucated - not as expected");
|
||||
|
||||
CONTEXT_DESTROY;
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (getdns_context_set_dns_transport_recursing_6)
|
||||
{
|
||||
/*
|
||||
* Request answer larger then 512 bytes but set UDP payload to that
|
||||
* Call getdns_context_set_dns_transport() with value = GETDNS_TRANSPORT_UDP_ONLY
|
||||
* expect: No response returned
|
||||
* Call getdns_context_set_dns_transport() with value = GETDNS_TRANSPORT_TCP_ONLY
|
||||
* expect: Response returned
|
||||
* Call getdns_context_set_dns_transport() with value = GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP
|
||||
* expect: Response returned
|
||||
*/
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *response = NULL;
|
||||
struct getdns_dict *extensions = getdns_dict_create();
|
||||
uint32_t status;
|
||||
uint32_t tc;
|
||||
|
||||
/* Recursive mode does not report the transport used and does not answer
|
||||
if the response is trucated. Also, transport can't be changed on a ub ctx.*/
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
/* Request a response that should be truncated over UDP */
|
||||
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_ONLY),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
|
||||
ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_maximum_udp_payload_size()");
|
||||
|
||||
ASSERT_RC(getdns_general_sync(context, "getdnsapi.net", 48, extensions, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(response, "status", &status),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"status\"");
|
||||
|
||||
/* THIS SHOULDN'T BE A TIMEOUT, but that seems to be what libunbound is doing */
|
||||
ASSERT_RC(status, GETDNS_RESPSTATUS_ALL_TIMEOUT, "Status not as expected");
|
||||
|
||||
CONTEXT_DESTROY;
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
/* Re-do over TCP */
|
||||
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_TCP_ONLY),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
|
||||
ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_maximum_udp_payload_size()");
|
||||
ASSERT_RC(getdns_general_sync(context, "getdnsapi.net", 48, extensions, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(response, "/replies_tree/0/header/tc", &tc),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"tc\"");
|
||||
ASSERT_RC(tc, 0, "Packet trucated - not as expected");
|
||||
|
||||
CONTEXT_DESTROY;
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
/* Now let it fall back to TCP */
|
||||
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
|
||||
ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_maximum_udp_payload_size()");
|
||||
ASSERT_RC(getdns_general_sync(context, "getdnsapi.net", 48, extensions, &response),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
|
||||
|
||||
ASSERT_RC(getdns_dict_get_int(response, "/replies_tree/0/header/tc", &tc),
|
||||
GETDNS_RETURN_GOOD, "Failed to extract \"tc\"");
|
||||
ASSERT_RC(tc, 0, "Packet trucated - not as expected");
|
||||
|
||||
CONTEXT_DESTROY;
|
||||
|
||||
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Suite *
|
||||
getdns_context_set_dns_transport_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("getdns_context_set_dns_transport()");
|
||||
|
||||
/* Negative test caseis */
|
||||
|
||||
/* Negative test cases */
|
||||
TCase *tc_neg = tcase_create("Negative");
|
||||
tcase_add_test(tc_neg, getdns_context_set_dns_transport_1);
|
||||
tcase_add_test(tc_neg, getdns_context_set_dns_transport_2);
|
||||
tcase_add_test(tc_neg, getdns_context_set_dns_transport_list_3);
|
||||
tcase_add_test(tc_neg, getdns_context_set_dns_transport_list_4);
|
||||
/* TODO: Test which specific lists are not supported */
|
||||
suite_add_tcase(s, tc_neg);
|
||||
|
||||
|
||||
/* Positive test cases */
|
||||
TCase *tc_pos = tcase_create("Positive");
|
||||
tcase_add_test(tc_pos, getdns_context_set_dns_transport_3);
|
||||
|
||||
/* TODO: Test which specific lists are supported */
|
||||
tcase_add_test(tc_pos, getdns_context_set_dns_transport_stub_5);
|
||||
tcase_add_test(tc_pos, getdns_context_set_dns_transport_recursing_6);
|
||||
/* TODO: TLS... */
|
||||
|
||||
suite_add_tcase(s, tc_pos);
|
||||
|
||||
return s;
|
||||
|
|
|
@ -11,4 +11,6 @@ cp -p ${SRCROOT}/src/libgetdns.symbols libgetdns.symbols.orig
|
|||
)
|
||||
cp -p ${SRCROOT}/src/libgetdns.symbols libgetdns.symbols.new
|
||||
cp -p libgetdns.symbols.orig ${SRCROOT}/src/libgetdns.symbols
|
||||
diff libgetdns.symbols.orig libgetdns.symbols.new
|
||||
sort libgetdns.symbols.orig > libgetdns.symbols.temp
|
||||
diff libgetdns.symbols.temp libgetdns.symbols.new
|
||||
|
||||
|
|
|
@ -3,15 +3,25 @@
|
|||
export SRCDIR=`dirname $0`
|
||||
. `dirname $0`/setup-env.sh
|
||||
|
||||
control_c()
|
||||
# run if user hits control-c
|
||||
{
|
||||
echo -en "\n*** Exiting ***\n"
|
||||
exit $?
|
||||
}
|
||||
|
||||
|
||||
LCOV_MERGE=""
|
||||
for TEST_PKG in ${SRCDIR}/*.tpkg
|
||||
do
|
||||
# when we run our test, we need to compile with profiling
|
||||
CFLAGS="-fprofile-arcs -ftest-coverage -O0" "${TPKG}" $* exe "${TEST_PKG}"
|
||||
CFLAGS="-fprofile-arcs -ftest-coverage -O0" "${TPKG}" $* exe "${TEST_PKG}"
|
||||
# after the test is complete, we need to collect the coverage data
|
||||
INFO_FILE=`echo $TEST_PKG | sed 's/.tpkg$//'`.info
|
||||
geninfo $SRCDIR/.. -o $INFO_FILE
|
||||
LCOV_MERGE="$LCOV_MERGE -a $INFO_FILE"
|
||||
# trap keyboard interrupt (control-c)
|
||||
trap control_c 2
|
||||
done
|
||||
lcov $LCOV_MERGE -o run-all.info
|
||||
genhtml run-all.info --output-directory coverage-html
|
||||
|
|
|
@ -3,8 +3,18 @@
|
|||
export SRCDIR=`dirname $0`
|
||||
. `dirname $0`/setup-env.sh
|
||||
|
||||
control_c()
|
||||
# run if user hits control-c
|
||||
{
|
||||
echo -en "\n*** Exiting ***\n"
|
||||
exit $?
|
||||
}
|
||||
|
||||
|
||||
for TEST_PKG in ${SRCDIR}/*.tpkg
|
||||
do
|
||||
"${TPKG}" $* exe "${TEST_PKG}"
|
||||
# trap keyboard interrupt (control-c)
|
||||
trap control_c 2
|
||||
done
|
||||
"${TPKG}" r
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
export SRCDIR=`dirname $0`
|
||||
. `dirname $0`/setup-env.sh
|
||||
|
||||
# pass a single test name as the first paramter (without .tpgk extension)
|
||||
ONE_TEST=$1
|
||||
shift
|
||||
|
||||
"${TPKG}" $* exe ${SRCDIR}/${ONE_TEST}.tpkg
|
|
@ -1119,7 +1119,7 @@ getdns_apply_network_result(getdns_network_req* netreq,
|
|||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
||||
if (rcode == GETDNS_RCODE_SERVFAIL) {
|
||||
if (rcode == GETDNS_RCODE_SERVFAIL) {
|
||||
/* Likely to be caused by timeout from a synchronous
|
||||
* lookup. Don't forge a packet.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue