mirror of https://github.com/getdnsapi/getdns.git
Add libuv support. Change event loop handling in tests
This commit is contained in:
parent
c171b1ccc4
commit
562e2dd6df
|
@ -634,6 +634,8 @@ ac_includes_default="\
|
|||
|
||||
ac_subst_vars='LTLIBOBJS
|
||||
LIBOBJS
|
||||
EXTENSION_LIBUV_OBJ
|
||||
have_libuv
|
||||
EXTENSION_LIBEVENT_OBJ
|
||||
have_libevent
|
||||
DOXYGEN
|
||||
|
@ -11144,6 +11146,7 @@ _ACEOF
|
|||
esac
|
||||
|
||||
|
||||
# libevent extension
|
||||
have_libevent=1
|
||||
EXTENSION_LIBEVENT_OBJ="extension/libevent.lo"
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing event_loop" >&5
|
||||
|
@ -11223,6 +11226,75 @@ fi
|
|||
|
||||
|
||||
|
||||
|
||||
# libuv extension
|
||||
have_libuv=1
|
||||
EXTENSION_LIBUV_OBJ="extension/libuv.lo"
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing uv_run" >&5
|
||||
$as_echo_n "checking for library containing uv_run... " >&6; }
|
||||
if ${ac_cv_search_uv_run+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
ac_func_search_save_LIBS=$LIBS
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
/* Override any GCC internal prototype to avoid an error.
|
||||
Use char because int might match the return type of a GCC
|
||||
builtin and then its argument prototype would still apply. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
char uv_run ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return uv_run ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
for ac_lib in '' uv; do
|
||||
if test -z "$ac_lib"; then
|
||||
ac_res="none required"
|
||||
else
|
||||
ac_res=-l$ac_lib
|
||||
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
|
||||
fi
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
ac_cv_search_uv_run=$ac_res
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext
|
||||
if ${ac_cv_search_uv_run+:} false; then :
|
||||
break
|
||||
fi
|
||||
done
|
||||
if ${ac_cv_search_uv_run+:} false; then :
|
||||
|
||||
else
|
||||
ac_cv_search_uv_run=no
|
||||
fi
|
||||
rm conftest.$ac_ext
|
||||
LIBS=$ac_func_search_save_LIBS
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_uv_run" >&5
|
||||
$as_echo "$ac_cv_search_uv_run" >&6; }
|
||||
ac_res=$ac_cv_search_uv_run
|
||||
if test "$ac_res" != no; then :
|
||||
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
|
||||
|
||||
$as_echo "#define HAVE_LIBUV 1" >>confdefs.h
|
||||
|
||||
else
|
||||
have_libuv=0
|
||||
EXTENSION_LIBUV_OBJ=""
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ac_config_files="$ac_config_files Makefile src/Makefile src/getdns/Makefile src/example/Makefile src/test/Makefile doc/Makefile"
|
||||
|
||||
if test -n "$DOXYGEN"
|
||||
|
|
14
configure.ac
14
configure.ac
|
@ -162,6 +162,7 @@ AC_TYPE_UINT32_T
|
|||
AC_TYPE_UINT64_T
|
||||
AC_TYPE_UINT8_T
|
||||
|
||||
# libevent extension
|
||||
have_libevent=1
|
||||
EXTENSION_LIBEVENT_OBJ="extension/libevent.lo"
|
||||
AC_SEARCH_LIBS([event_loop],
|
||||
|
@ -181,6 +182,19 @@ AC_SEARCH_LIBS([event_loop],
|
|||
|
||||
AC_SUBST(have_libevent)
|
||||
AC_SUBST(EXTENSION_LIBEVENT_OBJ)
|
||||
|
||||
# libuv extension
|
||||
have_libuv=1
|
||||
EXTENSION_LIBUV_OBJ="extension/libuv.lo"
|
||||
AC_SEARCH_LIBS([uv_run],
|
||||
[uv],
|
||||
[AC_DEFINE([HAVE_LIBUV], [1], [Define to 1 to enable the libuv extension])],
|
||||
[have_libuv=0]
|
||||
[EXTENSION_LIBUV_OBJ=""])
|
||||
|
||||
AC_SUBST(have_libuv)
|
||||
AC_SUBST(EXTENSION_LIBUV_OBJ)
|
||||
|
||||
AC_CONFIG_FILES([Makefile src/Makefile src/getdns/Makefile src/example/Makefile src/test/Makefile doc/Makefile])
|
||||
if [ test -n "$DOXYGEN" ]
|
||||
then AC_CONFIG_FILES([src/Doxyfile])
|
||||
|
|
|
@ -33,10 +33,11 @@ CC=gcc
|
|||
CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I/usr/local/include -std=c99
|
||||
LDFLAGS=@LDFLAGS@ @LIBS@
|
||||
EXTENSION_LIBEVENT_OBJ=@EXTENSION_LIBEVENT_OBJ@
|
||||
EXTENSION_LIBUV_OBJ=@EXTENSION_LIBUV_OBJ@
|
||||
GETDNS_OBJ=sync.lo context.lo list.lo dict.lo convert.lo general.lo \
|
||||
hostname.lo service.lo request-internal.lo validate_dnssec.lo \
|
||||
util-internal.lo getdns_error.lo rr-dict.lo validation-chain.lo \
|
||||
$(EXTENSION_LIBEVENT_OBJ)
|
||||
$(EXTENSION_LIBEVENT_OBJ) $(EXTENSION_LIBUV_OBJ)
|
||||
|
||||
.SUFFIXES: .c .o .a .lo .h
|
||||
|
||||
|
@ -55,6 +56,7 @@ install: libgetdns.la
|
|||
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)/getdns
|
||||
$(INSTALL) -m 644 $(srcdir)/getdns/getdns.h $(DESTDIR)$(includedir)/getdns/getdns.h
|
||||
if test $(have_libevent) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libevent.h $(DESTDIR)$(includedir)/getdns/ ; fi
|
||||
if test $(have_libuv) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libuv.h $(DESTDIR)$(includedir)/getdns/ ; fi
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
|
||||
$(LIBTOOL) --mode=install cp libgetdns.la $(DESTDIR)$(libdir)
|
||||
$(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
/* Define to 1 if you have the `unbound' library (-lunbound). */
|
||||
#undef HAVE_LIBUNBOUND
|
||||
|
||||
/* Define to 1 to enable the libuv extension */
|
||||
#undef HAVE_LIBUV
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
/**
|
||||
* \file
|
||||
* \brief Public interfaces to getdns, include in your application to use getdns API.
|
||||
*
|
||||
* This source was taken from the original pseudo-implementation by
|
||||
* Paul Hoffman.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013, NLNet Labs, Versign, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <getdns/getdns_ext_libevent.h>
|
||||
#include "config.h"
|
||||
#include "context.h"
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
#include <uv.h>
|
||||
|
||||
#define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code;
|
||||
|
||||
/* extension info */
|
||||
struct getdns_libuv_data {
|
||||
uv_loop_t* loop;
|
||||
uv_poll_t* poll_handle;
|
||||
};
|
||||
|
||||
/* lib event callbacks */
|
||||
static void
|
||||
getdns_libuv_cb(uv_poll_t* handle, int status, int events) {
|
||||
struct getdns_context* context = (struct getdns_context*) handle->data;
|
||||
getdns_context_process_async(context);
|
||||
}
|
||||
|
||||
static void
|
||||
getdns_libuv_timeout_cb(uv_timer_t* handle, int status) {
|
||||
getdns_timeout_data_t* timeout_data = (getdns_timeout_data_t*) handle->data;
|
||||
timeout_data->callback(timeout_data->userarg);
|
||||
}
|
||||
|
||||
static void
|
||||
getdns_libuv_close_cb(uv_handle_t* handle) {
|
||||
if (handle) {
|
||||
free(handle);
|
||||
}
|
||||
}
|
||||
|
||||
/* getdns extension functions */
|
||||
static getdns_return_t
|
||||
getdns_libuv_cleanup(struct getdns_context* context, void* data) {
|
||||
struct getdns_libuv_data *uv_data = (struct getdns_libuv_data*) data;
|
||||
uv_poll_stop(uv_data->poll_handle);
|
||||
uv_close((uv_handle_t*) uv_data->poll_handle, getdns_libuv_close_cb);
|
||||
/* handle itself gets cleaned up in close_cb */
|
||||
free(uv_data);
|
||||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
||||
static getdns_return_t
|
||||
getdns_libuv_schedule_timeout(struct getdns_context* context,
|
||||
void* eventloop_data, uint16_t timeout,
|
||||
getdns_timeout_data_t* timeout_data,
|
||||
void** eventloop_timer) {
|
||||
|
||||
uv_timer_t *timer;
|
||||
struct getdns_libuv_data* uv_data = (struct getdns_libuv_data*) eventloop_data;
|
||||
|
||||
timer = (uv_timer_t*) malloc(sizeof(uv_timer_t));
|
||||
timer->data = timeout_data;
|
||||
uv_timer_init(uv_data->loop, timer);
|
||||
uv_timer_start(timer, getdns_libuv_timeout_cb, timeout, 0);
|
||||
|
||||
*eventloop_timer = timer;
|
||||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
||||
static getdns_return_t
|
||||
getdns_libuv_clear_timeout(struct getdns_context* context,
|
||||
void* eventloop_data, void** eventloop_timer) {
|
||||
uv_timer_t* timer = (uv_timer_t*) eventloop_timer;
|
||||
uv_timer_stop(timer);
|
||||
uv_close((uv_handle_t*) timer, getdns_libuv_close_cb);
|
||||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
||||
|
||||
static getdns_eventloop_extension LIBUV_EXT = {
|
||||
getdns_libuv_cleanup,
|
||||
getdns_libuv_schedule_timeout,
|
||||
getdns_libuv_clear_timeout
|
||||
};
|
||||
|
||||
/*
|
||||
* getdns_extension_set_libuv_loop
|
||||
*
|
||||
*/
|
||||
getdns_return_t
|
||||
getdns_extension_set_libuv_loop(struct getdns_context *context,
|
||||
struct uv_loop_s *uv_loop)
|
||||
{
|
||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
RETURN_IF_NULL(uv_loop, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
/* TODO: cleanup current extension base */
|
||||
getdns_return_t r = getdns_extension_detach_eventloop(context);
|
||||
if (r != GETDNS_RETURN_GOOD) {
|
||||
return r;
|
||||
}
|
||||
struct getdns_libuv_data* uv_data = (struct getdns_libuv_data*) malloc(sizeof(struct getdns_libuv_data));
|
||||
if (!uv_data) {
|
||||
return GETDNS_RETURN_MEMORY_ERROR;
|
||||
}
|
||||
int fd = getdns_context_fd(context);
|
||||
uv_data->poll_handle = (uv_poll_t*) malloc(sizeof(uv_poll_t));
|
||||
uv_poll_init(uv_loop, uv_data->poll_handle, fd);
|
||||
uv_data->poll_handle->data = context;
|
||||
uv_data->loop = uv_loop;
|
||||
|
||||
uv_poll_start(uv_data->poll_handle, UV_READABLE, getdns_libuv_cb);
|
||||
return getdns_extension_set_eventloop(context, &LIBUV_EXT, uv_data);
|
||||
} /* getdns_extension_set_libuv_loop */
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* \file
|
||||
* \brief Public interfaces to getdns, include in your application to use getdns API.
|
||||
*
|
||||
* This source was taken from the original pseudo-implementation by
|
||||
* Paul Hoffman.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013, NLNet Labs, Versign, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <organization> nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GETDNS_EXT_LIBUV_H
|
||||
#define GETDNS_EXT_LIBUV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <getdns/getdns.h>
|
||||
|
||||
struct uv_loop_s;
|
||||
|
||||
/* For libevent, which we are using for these examples */
|
||||
getdns_return_t
|
||||
getdns_extension_set_libuv_loop(struct getdns_context *context,
|
||||
struct uv_loop_s *uv_loop);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -6,7 +6,6 @@
|
|||
#include <unistd.h>
|
||||
#include <check.h>
|
||||
#include <getdns/getdns.h>
|
||||
#include "check_getdns_libevent.h"
|
||||
#include "check_getdns_common.h"
|
||||
#include "check_getdns_general.h"
|
||||
#include "check_getdns_general_sync.h"
|
||||
|
|
|
@ -4,26 +4,26 @@
|
|||
/*
|
||||
***************************************************
|
||||
* *
|
||||
* T E S T S F O R G E T D N S _ A D D R E S S *
|
||||
* T E S T S F O R G E T D N S _ A D D R E S S *
|
||||
* *
|
||||
***************************************************
|
||||
*/
|
||||
|
||||
|
||||
START_TEST (getdns_address_1)
|
||||
{
|
||||
/*
|
||||
* context = NULL
|
||||
* expect: GETDNS_RETURN_INVALID_PARAMETER
|
||||
*/
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_context *context = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
ASSERT_RC(getdns_address(context, "google.com", NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
ASSERT_RC(getdns_address(context, "google.com", NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address()");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_address_2)
|
||||
{
|
||||
/*
|
||||
|
@ -31,7 +31,7 @@
|
|||
* expect: GETDNS_RETURN_INVALID_PARAMETER
|
||||
*/
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
@ -45,7 +45,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_address_3)
|
||||
{
|
||||
/*
|
||||
|
@ -53,7 +53,7 @@
|
|||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
|
||||
|
||||
|
@ -68,7 +68,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_address_4)
|
||||
{
|
||||
/*
|
||||
|
@ -76,14 +76,14 @@
|
|||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com";
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address(context, name, NULL,
|
||||
ASSERT_RC(getdns_address(context, name, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_address()");
|
||||
|
||||
|
@ -91,7 +91,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_address_5)
|
||||
{
|
||||
/*
|
||||
|
@ -99,13 +99,13 @@
|
|||
* expect: GETDNS_RETURN_INVALID_PARAMETER
|
||||
*/
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address(context, "google.com", NULL,
|
||||
ASSERT_RC(getdns_address(context, "google.com", NULL,
|
||||
NULL, &transaction_id, NULL),
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address()");
|
||||
|
||||
|
@ -113,8 +113,8 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
|
||||
|
||||
START_TEST (getdns_address_6)
|
||||
{
|
||||
/*
|
||||
|
@ -124,13 +124,13 @@
|
|||
*/
|
||||
void verify_getdns_address_6(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address(context, "google.com", NULL,
|
||||
ASSERT_RC(getdns_address(context, "google.com", NULL,
|
||||
verify_getdns_address_6, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
|
||||
|
||||
|
@ -145,8 +145,8 @@
|
|||
//assert_soa_in_authority(ex_response);
|
||||
assert_address_in_answer(ex_response, TRUE, TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
START_TEST (getdns_address_7)
|
||||
{
|
||||
/*
|
||||
|
@ -158,13 +158,13 @@
|
|||
*/
|
||||
void verify_getdns_address_7(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address(context, "localhost", NULL,
|
||||
ASSERT_RC(getdns_address(context, "localhost", NULL,
|
||||
verify_getdns_address_7, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
|
||||
|
||||
|
@ -178,7 +178,7 @@
|
|||
assert_noerror(ex_response);
|
||||
assert_address_in_answer(ex_response, TRUE, TRUE);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_address_8)
|
||||
{
|
||||
/*
|
||||
|
@ -189,14 +189,14 @@
|
|||
*/
|
||||
void verify_getdns_address_8(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_address(context, "hostnamedoesntexist", NULL,
|
||||
ASSERT_RC(getdns_address(context, "hostnamedoesntexist", NULL,
|
||||
verify_getdns_address_8, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
|
||||
|
||||
|
@ -211,13 +211,13 @@
|
|||
assert_nodata(ex_response);
|
||||
assert_soa_in_authority(ex_response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Suite *
|
||||
getdns_address_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("getdns_address()");
|
||||
|
||||
|
||||
/* Negative test caseis */
|
||||
TCase *tc_neg = tcase_create("Negative");
|
||||
tcase_add_test(tc_neg, getdns_address_1);
|
||||
|
@ -226,15 +226,15 @@
|
|||
tcase_add_test(tc_neg, getdns_address_4);
|
||||
tcase_add_test(tc_neg, getdns_address_5);
|
||||
suite_add_tcase(s, tc_neg);
|
||||
|
||||
|
||||
/* Positive test cases */
|
||||
TCase *tc_pos = tcase_create("Positive");
|
||||
tcase_add_test(tc_pos, getdns_address_6);
|
||||
tcase_add_test(tc_pos, getdns_address_7);
|
||||
tcase_add_test(tc_pos, getdns_address_8);
|
||||
suite_add_tcase(s, tc_pos);
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_cancel_callback()");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_cancel_callback_2)
|
||||
{
|
||||
/*
|
||||
|
@ -30,14 +30,14 @@
|
|||
*/
|
||||
void verify_getdns_cancel_callback(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
callback_called = 0; /* Initialize counter */
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
verify_getdns_cancel_callback, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
@ -52,7 +52,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_cancel_callback_3)
|
||||
{
|
||||
/*
|
||||
|
@ -61,14 +61,14 @@
|
|||
*/
|
||||
void verify_getdns_cancel_callback(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
callback_called = 0; /* Initialize counter */
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
verify_getdns_cancel_callback, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
@ -92,7 +92,7 @@
|
|||
*
|
||||
* if transaction_id is odd, callback is canceled before event loop
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
* if transaction_id is even, callback is canceled after event loop
|
||||
* if transaction_id is even, callback is canceled after event loop
|
||||
* expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
|
||||
*
|
||||
* expect: callback to be called with GETDNS_CALLBACK_CANCELED (if canceled)
|
||||
|
@ -105,15 +105,15 @@
|
|||
void *userarg,
|
||||
getdns_transaction_t transaction_id);
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
getdns_transaction_t transaction_id_array[10] = {};
|
||||
int i;
|
||||
int odd = 0;
|
||||
int even = 0;
|
||||
|
||||
/*
|
||||
* Initialize counters
|
||||
/*
|
||||
* Initialize counters
|
||||
*/
|
||||
callback_called = 0;
|
||||
callback_completed = 0;
|
||||
|
@ -123,7 +123,7 @@
|
|||
EVENT_BASE_CREATE;
|
||||
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
{
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
NULL, &transaction_id, cancel_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
@ -143,7 +143,7 @@
|
|||
|
||||
RUN_EVENT_LOOP;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Cancel the callback for even transaction_ids which should be complete
|
||||
*/
|
||||
for(i = 0; i < 10; i++)
|
||||
|
@ -171,7 +171,7 @@
|
|||
*
|
||||
* if transaction_id is odd, callback is canceled before event loop
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
* if transaction_id is even, callback is canceled after event loop
|
||||
* if transaction_id is even, callback is canceled after event loop
|
||||
* expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
|
||||
*
|
||||
* expect: callback to be called with GETDNS_CALLBACK_CANCELED (if canceled)
|
||||
|
@ -184,15 +184,15 @@
|
|||
void *userarg,
|
||||
getdns_transaction_t transaction_id);
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
getdns_transaction_t transaction_id_array[10] = {};
|
||||
int i;
|
||||
int odd = 0;
|
||||
int even = 0;
|
||||
|
||||
/*
|
||||
* Initialize counters
|
||||
/*
|
||||
* Initialize counters
|
||||
*/
|
||||
callback_called = 0;
|
||||
callback_completed = 0;
|
||||
|
@ -203,7 +203,7 @@
|
|||
EVENT_BASE_CREATE;
|
||||
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
{
|
||||
ASSERT_RC(getdns_address(context, "google.com", NULL,
|
||||
NULL, &transaction_id, cancel_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
|
||||
|
@ -223,7 +223,7 @@
|
|||
|
||||
RUN_EVENT_LOOP;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Cancel the callback for even transaction_ids which should be complete
|
||||
*/
|
||||
for(i = 0; i < 10; i++)
|
||||
|
@ -251,7 +251,7 @@
|
|||
*
|
||||
* if transaction_id is odd, callback is canceled before event loop
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
* if transaction_id is even, callback is canceled after event loop
|
||||
* if transaction_id is even, callback is canceled after event loop
|
||||
* expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
|
||||
*
|
||||
* expect: callback to be called with GETDNS_CALLBACK_CANCELED (if canceled)
|
||||
|
@ -264,7 +264,7 @@
|
|||
void *userarg,
|
||||
getdns_transaction_t transaction_id);
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
|
||||
struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
|
||||
struct getdns_dict *address = NULL;
|
||||
|
@ -274,8 +274,8 @@
|
|||
int odd = 0;
|
||||
int even = 0;
|
||||
|
||||
/*
|
||||
* Initialize counters
|
||||
/*
|
||||
* Initialize counters
|
||||
*/
|
||||
callback_called = 0;
|
||||
callback_completed = 0;
|
||||
|
@ -289,9 +289,9 @@
|
|||
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata");
|
||||
ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata");
|
||||
|
||||
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
{
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
NULL, &transaction_id, cancel_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
|
||||
|
@ -311,7 +311,7 @@
|
|||
|
||||
RUN_EVENT_LOOP;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Cancel the callback for even transaction_ids which should be complete
|
||||
*/
|
||||
for(i = 0; i < 10; i++)
|
||||
|
@ -340,7 +340,7 @@
|
|||
*
|
||||
* if transaction_id is odd, callback is canceled before event loop
|
||||
* expect: GETDNS_RETURN_GOOD
|
||||
* if transaction_id is even, callback is canceled after event loop
|
||||
* if transaction_id is even, callback is canceled after event loop
|
||||
* expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
|
||||
*
|
||||
* expect: callback to be called with GETDNS_CALLBACK_CANCELED (if canceled)
|
||||
|
@ -353,15 +353,15 @@
|
|||
void *userarg,
|
||||
getdns_transaction_t transaction_id);
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
getdns_transaction_t transaction_id_array[10] = {};
|
||||
int i;
|
||||
int odd = 0;
|
||||
int even = 0;
|
||||
|
||||
/*
|
||||
* Initialize counters
|
||||
/*
|
||||
* Initialize counters
|
||||
*/
|
||||
callback_called = 0;
|
||||
callback_completed = 0;
|
||||
|
@ -369,9 +369,9 @@
|
|||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
{
|
||||
ASSERT_RC(getdns_service(context, "google.com", NULL,
|
||||
NULL, &transaction_id, cancel_callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_service()");
|
||||
|
@ -391,7 +391,7 @@
|
|||
|
||||
RUN_EVENT_LOOP;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Cancel the callback for even transaction_ids which should be complete
|
||||
*/
|
||||
for(i = 0; i < 10; i++)
|
||||
|
@ -430,7 +430,7 @@
|
|||
if(callback_type == GETDNS_CALLBACK_CANCEL)
|
||||
{
|
||||
callback_canceled++;
|
||||
ck_assert_msg(transaction_id % 2,
|
||||
ck_assert_msg(transaction_id % 2,
|
||||
"Only callbacks with odd transaction_ids were canceled, this one is even: %d",
|
||||
transaction_id);
|
||||
}
|
||||
|
@ -452,7 +452,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Function passed via userarg to async functions for cancel callback tests
|
||||
*/
|
||||
void verify_getdns_cancel_callback(struct extracted_response *ex_response)
|
||||
|
|
|
@ -5,7 +5,15 @@
|
|||
#include <inttypes.h>
|
||||
#include <check.h>
|
||||
#include <getdns/getdns.h>
|
||||
#include "config.h"
|
||||
#if HAVE_LIBEVENT
|
||||
#include "check_getdns_libevent.h"
|
||||
#include <getdns/getdns_ext_libevent.h>
|
||||
#endif
|
||||
#if HAVE_LIBUV
|
||||
#include <getdns/getdns_ext_libuv.h>
|
||||
#include <uv.h>
|
||||
#endif
|
||||
#include "check_getdns_common.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -292,22 +300,29 @@ void update_callbackfn(struct getdns_context *context,
|
|||
changed_item, expected_changed_item);
|
||||
}
|
||||
|
||||
#define NO_LOOP 0
|
||||
#define LIBEVENT_LOOP 1
|
||||
#define LIBUV_LOOP 2
|
||||
|
||||
static int get_event_loop_type() {
|
||||
int result = 0;
|
||||
char* loop = getenv("GETDNS_EVLOOP");
|
||||
if (loop && strcmp("none", loop) == 0) {
|
||||
result = 1;
|
||||
#if HAVE_LIBEVENT
|
||||
if (loop && strcmp("libevent", loop) == 0) {
|
||||
result = LIBEVENT_LOOP;
|
||||
}
|
||||
#endif
|
||||
#if HAVE_LIBUV
|
||||
if (loop && strcmp("uv", loop) == 0) {
|
||||
result = LIBUV_LOOP;
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
void run_event_loop(struct getdns_context* context, struct event_base* base) {
|
||||
void run_event_loop(struct getdns_context* context, void* eventloop) {
|
||||
int event_loop_type = get_event_loop_type();
|
||||
if (event_loop_type == 0) {
|
||||
while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
|
||||
event_base_loop(base, EVLOOP_ONCE);
|
||||
}
|
||||
} else if (event_loop_type == 1) {
|
||||
if (event_loop_type == NO_LOOP) {
|
||||
struct timeval tv;
|
||||
while (getdns_context_get_num_pending_requests(context, &tv) > 0) {
|
||||
int fd = getdns_context_fd(context);
|
||||
|
@ -318,11 +333,28 @@ void run_event_loop(struct getdns_context* context, struct event_base* base) {
|
|||
getdns_context_process_async(context);
|
||||
}
|
||||
}
|
||||
#if HAVE_LIBEVENT
|
||||
else if (event_loop_type == LIBEVENT_LOOP) {
|
||||
struct event_base* base = (struct event_base*) eventloop;
|
||||
while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
|
||||
event_base_loop(base, EVLOOP_ONCE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if HAVE_LIBUV
|
||||
else if (event_loop_type == LIBUV_LOOP) {
|
||||
uv_loop_t* loop = (uv_loop_t*) eventloop;
|
||||
while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
|
||||
uv_run(loop, UV_RUN_ONCE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
struct event_base* create_event_base(struct getdns_context* context) {
|
||||
void* create_event_base(struct getdns_context* context) {
|
||||
int event_loop_type = get_event_loop_type();
|
||||
if (event_loop_type == 0) {
|
||||
#if HAVE_LIBEVENT
|
||||
if (event_loop_type == LIBEVENT_LOOP) {
|
||||
struct event_base* result = event_base_new();
|
||||
ck_assert_msg(result != NULL, "Event base creation failed");
|
||||
ASSERT_RC(getdns_extension_set_libevent_base(context, result),
|
||||
|
@ -330,5 +362,16 @@ struct event_base* create_event_base(struct getdns_context* context) {
|
|||
"Return code from getdns_extension_set_libevent_base()");
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
#if HAVE_LIBUV
|
||||
if (event_loop_type == LIBUV_LOOP) {
|
||||
uv_loop_t* result = uv_default_loop();
|
||||
ck_assert_msg(result != NULL, "UV loop creation failed");
|
||||
ASSERT_RC(getdns_extension_set_libuv_loop(context, result),
|
||||
GETDNS_RETURN_GOOD,
|
||||
"Return code from getdns_extension_set_libuv_loop()");
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _check_getdns_common_h_
|
||||
#define _check_getdns_common_h_
|
||||
|
||||
#include "check_getdns_libevent.h"
|
||||
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
@ -66,12 +66,12 @@
|
|||
* create an event base and put it in the
|
||||
* context.
|
||||
*/
|
||||
#define EVENT_BASE_CREATE event_base = create_event_base(context);
|
||||
#define EVENT_BASE_CREATE eventloop = create_event_base(context);
|
||||
|
||||
/*
|
||||
* The RUN_EVENT_LOOP macro calls the event loop.
|
||||
*/
|
||||
#define RUN_EVENT_LOOP run_event_loop(context, event_base);
|
||||
#define RUN_EVENT_LOOP run_event_loop(context, eventloop);
|
||||
|
||||
/*
|
||||
* The LIST_CREATE macro simply creates a
|
||||
|
@ -180,8 +180,8 @@
|
|||
uint16_t changed_item);
|
||||
|
||||
/* run the event loop */
|
||||
void run_event_loop(struct getdns_context *context, struct event_base* event_base);
|
||||
void run_event_loop(struct getdns_context *context, void* eventloop);
|
||||
|
||||
struct event_base* create_event_base(struct getdns_context* context);
|
||||
void* create_event_base(struct getdns_context* context);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
getdns_context_destroy(NULL);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_context_destroy_2)
|
||||
{
|
||||
/*
|
||||
* destroy called with valid context and no outstanding transactions
|
||||
* expect: nothing, context is freed
|
||||
* expect: nothing, context is freed
|
||||
*/
|
||||
struct getdns_context *context = NULL;
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_context_destroy_3)
|
||||
{
|
||||
/*
|
||||
|
@ -41,14 +41,14 @@
|
|||
*/
|
||||
void verify_getdns_context_destroy(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
callback_called = 0; /* Initialize counter */
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
verify_getdns_context_destroy, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
@ -59,7 +59,7 @@
|
|||
ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_context_destroy_4)
|
||||
{
|
||||
/*
|
||||
|
@ -68,14 +68,14 @@
|
|||
*/
|
||||
void verify_getdns_context_destroy(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
callback_called = 0; /* Initialize counter */
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
|
||||
ASSERT_RC(getdns_address(context, "google.com", NULL,
|
||||
verify_getdns_context_destroy, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
|
||||
|
@ -86,7 +86,7 @@
|
|||
ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_context_destroy_5)
|
||||
{
|
||||
/*
|
||||
|
@ -95,7 +95,7 @@
|
|||
*/
|
||||
void verify_getdns_context_destroy(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
|
||||
struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
|
||||
struct getdns_dict *address = NULL;
|
||||
|
@ -111,7 +111,7 @@
|
|||
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata");
|
||||
ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata");
|
||||
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
verify_getdns_context_destroy, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
|
||||
|
@ -123,7 +123,7 @@
|
|||
ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_context_destroy_6)
|
||||
{
|
||||
/*
|
||||
|
@ -132,14 +132,14 @@
|
|||
*/
|
||||
void verify_getdns_context_destroy(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
callback_called = 0; /* Initialize counter */
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
|
||||
ASSERT_RC(getdns_service(context, "google.com", NULL,
|
||||
verify_getdns_context_destroy, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_service()");
|
||||
|
@ -183,7 +183,7 @@
|
|||
tcase_add_test(tc_pos, getdns_context_destroy_5);
|
||||
tcase_add_test(tc_pos, getdns_context_destroy_6);
|
||||
suite_add_tcase(s, tc_pos);
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,22 +8,22 @@
|
|||
* *
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
START_TEST (getdns_general_1)
|
||||
{
|
||||
/*
|
||||
* context = NULL
|
||||
* expect: GETDNS_RETURN_INVALID_PARAMETER
|
||||
*/
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_context *context = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general()");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_general_2)
|
||||
{
|
||||
/*
|
||||
|
@ -31,7 +31,7 @@
|
|||
* expect: GETDNS_RETURN_INVALID_PARAMETER
|
||||
*/
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
@ -45,7 +45,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_general_3)
|
||||
{
|
||||
/*
|
||||
|
@ -53,7 +53,7 @@
|
|||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
|
||||
|
||||
|
@ -68,7 +68,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_general_4)
|
||||
{
|
||||
/*
|
||||
|
@ -76,14 +76,14 @@
|
|||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com";
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_A, NULL,
|
||||
ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_A, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general()");
|
||||
|
||||
|
@ -91,7 +91,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_general_5)
|
||||
{
|
||||
/*
|
||||
|
@ -99,13 +99,13 @@
|
|||
* expect: GETDNS_RETURN_INVALID_PARAMETER
|
||||
*/
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
NULL, &transaction_id, NULL),
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general()");
|
||||
|
||||
|
@ -113,7 +113,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_general_6)
|
||||
{
|
||||
/*
|
||||
|
@ -126,9 +126,9 @@
|
|||
*/
|
||||
void verify_getdns_general_6(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
|
@ -146,7 +146,7 @@
|
|||
assert_noerror(ex_response);
|
||||
assert_nodata(ex_response);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_general_7)
|
||||
{
|
||||
/*
|
||||
|
@ -159,13 +159,13 @@
|
|||
*/
|
||||
void verify_getdns_general_7(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", 65279, NULL,
|
||||
ASSERT_RC(getdns_general(context, "google.com", 65279, NULL,
|
||||
verify_getdns_general_7, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
|
@ -179,7 +179,7 @@
|
|||
assert_noerror(ex_response);
|
||||
assert_nodata(ex_response);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_general_8)
|
||||
{
|
||||
/*
|
||||
|
@ -193,13 +193,13 @@
|
|||
*/
|
||||
void verify_getdns_general_8(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
verify_getdns_general_8, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
|
@ -213,7 +213,7 @@
|
|||
assert_noerror(ex_response);
|
||||
assert_address_in_answer(ex_response, TRUE, FALSE);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_general_9)
|
||||
{
|
||||
/*
|
||||
|
@ -227,13 +227,13 @@
|
|||
*/
|
||||
void verify_getdns_general_9(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_AAAA, NULL,
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_AAAA, NULL,
|
||||
verify_getdns_general_9, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
|
@ -247,7 +247,7 @@
|
|||
assert_noerror(ex_response);
|
||||
assert_address_in_answer(ex_response, FALSE, TRUE);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_general_10)
|
||||
{
|
||||
/*
|
||||
|
@ -262,14 +262,14 @@
|
|||
*/
|
||||
void verify_getdns_general_10(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
const char *name = "thisdomainsurelydoesntexist.com";
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_TXT, NULL,
|
||||
ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_TXT, NULL,
|
||||
verify_getdns_general_10, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
|
@ -284,7 +284,7 @@
|
|||
assert_nodata(ex_response);
|
||||
assert_soa_in_authority(ex_response);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_general_11)
|
||||
{
|
||||
/*
|
||||
|
@ -297,13 +297,13 @@
|
|||
*/
|
||||
void verify_getdns_general_11(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "hampster.com", GETDNS_RRTYPE_MX, NULL,
|
||||
ASSERT_RC(getdns_general(context, "hampster.com", GETDNS_RRTYPE_MX, NULL,
|
||||
verify_getdns_general_11, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
|
@ -317,7 +317,7 @@
|
|||
assert_noerror(ex_response);
|
||||
assert_nodata(ex_response);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_general_12)
|
||||
{
|
||||
/*
|
||||
|
@ -331,13 +331,13 @@
|
|||
*/
|
||||
void verify_getdns_general_12(struct extracted_response *ex_response);
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
|
||||
verify_getdns_general_12, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
|
||||
|
||||
|
@ -351,22 +351,22 @@
|
|||
assert_noerror(ex_response);
|
||||
assert_address_in_answer(ex_response, TRUE, FALSE);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_general_13)
|
||||
{
|
||||
/*
|
||||
* name = "75.101.146.66"
|
||||
* name = "75.101.146.66"
|
||||
* request_type = GETDNS_RRTYPE_PTR
|
||||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_general(context, "75.101.146.66", GETDNS_RRTYPE_PTR, NULL,
|
||||
ASSERT_RC(getdns_general(context, "75.101.146.66", GETDNS_RRTYPE_PTR, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general()");
|
||||
|
||||
|
@ -383,9 +383,9 @@
|
|||
* expect: GETDNS_RETURN_BAD_DOMAIN_NAME
|
||||
*/
|
||||
struct getdns_context *context = NULL; \
|
||||
struct event_base *event_base = NULL; \
|
||||
void* eventloop = NULL; \
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
|
@ -402,7 +402,7 @@
|
|||
getdns_general_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("getdns_general()");
|
||||
|
||||
|
||||
/* Negative test caseis */
|
||||
TCase *tc_neg = tcase_create("Negative");
|
||||
tcase_add_test(tc_neg, getdns_general_1);
|
||||
|
@ -413,7 +413,7 @@
|
|||
tcase_add_test(tc_neg, getdns_general_13);
|
||||
tcase_add_test(tc_neg, getdns_general_14);
|
||||
suite_add_tcase(s, tc_neg);
|
||||
|
||||
|
||||
/* Positive test cases */
|
||||
TCase *tc_pos = tcase_create("Positive");
|
||||
tcase_add_test(tc_pos, getdns_general_6);
|
||||
|
@ -424,8 +424,8 @@
|
|||
tcase_add_test(tc_pos, getdns_general_11);
|
||||
tcase_add_test(tc_pos, getdns_general_12);
|
||||
suite_add_tcase(s, tc_pos);
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* *
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_1)
|
||||
{
|
||||
/*
|
||||
|
@ -27,14 +27,14 @@
|
|||
ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()");
|
||||
|
||||
DICT_DESTROY(address);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_2)
|
||||
{
|
||||
/*
|
||||
|
@ -42,7 +42,7 @@
|
|||
* expect: GETDNS_RETURN_INVALID_PARAMETER
|
||||
*/
|
||||
struct getdns_context *context = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
@ -56,7 +56,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_3)
|
||||
{
|
||||
/*
|
||||
|
@ -65,7 +65,7 @@
|
|||
*/
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *address = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
@ -81,7 +81,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_4)
|
||||
{
|
||||
/*
|
||||
|
@ -91,7 +91,7 @@
|
|||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *address = NULL;
|
||||
struct getdns_bindata address_type = { 5, (void *) "IPv4" };
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
@ -99,10 +99,10 @@
|
|||
DICT_CREATE(address);
|
||||
ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
|
||||
|
||||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname()");
|
||||
|
||||
|
@ -112,7 +112,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_5)
|
||||
{
|
||||
/*
|
||||
|
@ -123,9 +123,9 @@
|
|||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *address = NULL;
|
||||
struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
DICT_CREATE(address);
|
||||
|
@ -136,7 +136,7 @@
|
|||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname()");
|
||||
|
||||
|
@ -146,19 +146,19 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_6)
|
||||
{
|
||||
/*
|
||||
* dict in address contains names address_type
|
||||
* dict in address contains names address_type
|
||||
* and address_data but data type is not bindata
|
||||
* expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
|
||||
*/
|
||||
struct getdns_context *context = NULL;
|
||||
struct getdns_dict *address = NULL;
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
DICT_CREATE(address);
|
||||
|
@ -169,7 +169,7 @@
|
|||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_hostname()");
|
||||
|
||||
|
@ -179,7 +179,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_7)
|
||||
{
|
||||
/*
|
||||
|
@ -190,9 +190,9 @@
|
|||
struct getdns_dict *address = NULL;
|
||||
struct getdns_bindata address_type = { 5, (void *)"IPv5" };
|
||||
struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
DICT_CREATE(address);
|
||||
|
@ -203,7 +203,7 @@
|
|||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()");
|
||||
|
||||
|
@ -213,7 +213,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_8)
|
||||
{
|
||||
/*
|
||||
|
@ -224,9 +224,9 @@
|
|||
struct getdns_dict *address = NULL;
|
||||
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
|
||||
struct getdns_bindata address_data = { 5, (void *)"\x08\x08\x08\x08\x08" };
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
DICT_CREATE(address);
|
||||
|
@ -237,7 +237,7 @@
|
|||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
NULL, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()");
|
||||
|
||||
|
@ -247,7 +247,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_9)
|
||||
{
|
||||
/*
|
||||
|
@ -258,9 +258,9 @@
|
|||
struct getdns_dict *address = NULL;
|
||||
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
|
||||
struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
DICT_CREATE(address);
|
||||
|
@ -271,7 +271,7 @@
|
|||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
NULL, &transaction_id, NULL),
|
||||
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()");
|
||||
|
||||
|
@ -281,7 +281,7 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_10)
|
||||
{
|
||||
/*
|
||||
|
@ -293,9 +293,9 @@
|
|||
struct getdns_dict *address = NULL;
|
||||
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
|
||||
struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
DICT_CREATE(address);
|
||||
|
@ -306,7 +306,7 @@
|
|||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
verify_getdns_hostname_10, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
|
||||
|
||||
|
@ -316,13 +316,13 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
void verify_getdns_hostname_10(struct extracted_response *ex_response)
|
||||
{
|
||||
assert_noerror(ex_response);
|
||||
assert_ptr_in_answer(ex_response);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_11)
|
||||
{
|
||||
/*
|
||||
|
@ -334,9 +334,9 @@
|
|||
struct getdns_dict *address = NULL;
|
||||
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
|
||||
struct getdns_bindata address_data = { 4, (void *)"\x01\x01\x01\x01" };
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
DICT_CREATE(address);
|
||||
|
@ -347,7 +347,7 @@
|
|||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
verify_getdns_hostname_11, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
|
||||
|
||||
|
@ -357,14 +357,14 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
void verify_getdns_hostname_11(struct extracted_response *ex_response)
|
||||
{
|
||||
assert_nxdomain(ex_response);
|
||||
assert_nodata(ex_response);
|
||||
assert_soa_in_authority(ex_response);
|
||||
assert_soa_in_authority(ex_response);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_12)
|
||||
{
|
||||
/*
|
||||
|
@ -376,9 +376,9 @@
|
|||
struct getdns_dict *address = NULL;
|
||||
struct getdns_bindata address_type = { 5, (void *)"IPv6" };
|
||||
struct getdns_bindata address_data = { 16, (void *)"\x26\x07\xf8\xb0\x40\x06\x08\x02\x00\x00\x00\x00\x00\x00\x10\x04" };
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
DICT_CREATE(address);
|
||||
|
@ -389,7 +389,7 @@
|
|||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
verify_getdns_hostname_12, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
|
||||
|
||||
|
@ -399,13 +399,13 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
void verify_getdns_hostname_12(struct extracted_response *ex_response)
|
||||
{
|
||||
assert_noerror(ex_response);
|
||||
assert_ptr_in_answer(ex_response);
|
||||
}
|
||||
|
||||
|
||||
START_TEST (getdns_hostname_13)
|
||||
{
|
||||
/*
|
||||
|
@ -417,9 +417,9 @@
|
|||
struct getdns_dict *address = NULL;
|
||||
struct getdns_bindata address_type = { 5, (void *)"IPv6" };
|
||||
struct getdns_bindata address_data = { 16, (void *)"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" };
|
||||
struct event_base *event_base = NULL;
|
||||
void* eventloop = NULL;
|
||||
getdns_transaction_t transaction_id = 0;
|
||||
|
||||
|
||||
CONTEXT_CREATE(TRUE);
|
||||
|
||||
DICT_CREATE(address);
|
||||
|
@ -430,7 +430,7 @@
|
|||
|
||||
EVENT_BASE_CREATE;
|
||||
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
ASSERT_RC(getdns_hostname(context, address, NULL,
|
||||
verify_getdns_hostname_13, &transaction_id, callbackfn),
|
||||
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
|
||||
|
||||
|
@ -440,19 +440,19 @@
|
|||
CONTEXT_DESTROY;
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
void verify_getdns_hostname_13(struct extracted_response *ex_response)
|
||||
{
|
||||
assert_nxdomain(ex_response);
|
||||
assert_nodata(ex_response);
|
||||
assert_soa_in_authority(ex_response);
|
||||
assert_soa_in_authority(ex_response);
|
||||
}
|
||||
|
||||
|
||||
Suite *
|
||||
getdns_hostname_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("getdns_hostname()");
|
||||
|
||||
|
||||
/* Negative test caseis */
|
||||
TCase *tc_neg = tcase_create("Negative");
|
||||
tcase_add_test(tc_neg, getdns_hostname_1);
|
||||
|
@ -465,7 +465,7 @@
|
|||
tcase_add_test(tc_neg, getdns_hostname_8);
|
||||
tcase_add_test(tc_neg, getdns_hostname_9);
|
||||
suite_add_tcase(s, tc_neg);
|
||||
|
||||
|
||||
/* Positive test cases */
|
||||
TCase *tc_pos = tcase_create("Positive");
|
||||
tcase_add_test(tc_pos, getdns_hostname_10);
|
||||
|
@ -473,8 +473,8 @@
|
|||
tcase_add_test(tc_pos, getdns_hostname_12);
|
||||
tcase_add_test(tc_pos, getdns_hostname_13);
|
||||
suite_add_tcase(s, tc_pos);
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include "config.h"
|
||||
#ifdef HAVE_EVENT2_EVENT_H
|
||||
#include <event2/event.h>
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue