api: Add option to expose some internal functions
Purely for testing, add --enable-expose-statics option to configure which converts some static internal functions to be externally visible.
This commit is contained in:
parent
b619d13693
commit
d493e9b17c
|
@ -77,7 +77,7 @@ static char *lookup_service(unsigned short port, int flags,
|
|||
static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int scopeid,
|
||||
char *buf, size_t buflen);
|
||||
#endif
|
||||
static char *ares_striendstr(const char *s1, const char *s2);
|
||||
STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2);
|
||||
|
||||
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||
ares_socklen_t salen,
|
||||
|
@ -391,7 +391,7 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags,
|
|||
#endif
|
||||
|
||||
/* Determines if s1 ends with the string in s2 (case-insensitive) */
|
||||
static char *ares_striendstr(const char *s1, const char *s2)
|
||||
STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2)
|
||||
{
|
||||
const char *c1, *c2, *c1_begin;
|
||||
int lo1, lo2;
|
||||
|
|
|
@ -43,6 +43,13 @@
|
|||
#define INADDR_NONE 0xffffffff
|
||||
#endif
|
||||
|
||||
#ifdef CARES_EXPOSE_STATICS
|
||||
/* Make some internal functions visible for testing */
|
||||
#define STATIC_TESTABLE
|
||||
#else
|
||||
#define STATIC_TESTABLE static
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) && !defined(WATT32)
|
||||
|
||||
#define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
|
||||
|
|
|
@ -44,7 +44,7 @@ static void search_callback(void *arg, int status, int timeouts,
|
|||
static void end_squery(struct search_query *squery, int status,
|
||||
unsigned char *abuf, int alen);
|
||||
static int cat_domain(const char *name, const char *domain, char **s);
|
||||
static int single_domain(ares_channel channel, const char *name, char **s);
|
||||
STATIC_TESTABLE int single_domain(ares_channel channel, const char *name, char **s);
|
||||
|
||||
void ares_search(ares_channel channel, const char *name, int dnsclass,
|
||||
int type, ares_callback callback, void *arg)
|
||||
|
@ -225,7 +225,7 @@ static int cat_domain(const char *name, const char *domain, char **s)
|
|||
* the string we should query, in an allocated buffer. If not, set *s
|
||||
* to NULL.
|
||||
*/
|
||||
static int single_domain(ares_channel channel, const char *name, char **s)
|
||||
STATIC_TESTABLE int single_domain(ares_channel channel, const char *name, char **s)
|
||||
{
|
||||
size_t len = strlen(name);
|
||||
const char *hostaliases;
|
||||
|
|
|
@ -19,6 +19,7 @@ CARES_CHECK_OPTION_WARNINGS
|
|||
CARES_CHECK_OPTION_WERROR
|
||||
CARES_CHECK_OPTION_CURLDEBUG
|
||||
CARES_CHECK_OPTION_SYMBOL_HIDING
|
||||
CARES_CHECK_OPTION_EXPOSE_STATICS
|
||||
|
||||
XC_CHECK_PATH_SEPARATOR
|
||||
|
||||
|
|
|
@ -219,6 +219,44 @@ AC_HELP_STRING([--disable-symbol-hiding],[Disable hiding of library internal sym
|
|||
])
|
||||
|
||||
|
||||
dnl CARES_CHECK_OPTION_EXPOSE_STATICS
|
||||
dnl -------------------------------------------------
|
||||
dnl Verify if configure has been invoked with option
|
||||
dnl --enable-expose-statics or --disable-expose-statics,
|
||||
dnl setting shell variable want_expose_statics value.
|
||||
|
||||
AC_DEFUN([CARES_CHECK_OPTION_EXPOSE_STATICS], [
|
||||
AC_MSG_CHECKING([whether to expose internal static functions for testing])
|
||||
OPT_EXPOSE_STATICS="default"
|
||||
AC_ARG_ENABLE(expose-statics,
|
||||
AC_HELP_STRING([--enable-expose-statics],[Enable exposure of internal static functions for testing])
|
||||
AC_HELP_STRING([--disable-expose-statics],[Disable exposure of internal static functions for testing]),
|
||||
OPT_EXPOSE_STATICS=$enableval)
|
||||
case "$OPT_EXPOSE_STATICS" in
|
||||
no)
|
||||
dnl --disable-expose-statics option used.
|
||||
want_expose_statics="no"
|
||||
AC_MSG_RESULT([no])
|
||||
;;
|
||||
default)
|
||||
dnl configure's expose-statics option not specified.
|
||||
dnl Handle this as if --disable-expose-statics option was given.
|
||||
want_expose_statics="no"
|
||||
AC_MSG_RESULT([no])
|
||||
;;
|
||||
*)
|
||||
dnl --enable-expose-statics option used.
|
||||
want_expose_statics="yes"
|
||||
AC_MSG_RESULT([yes])
|
||||
;;
|
||||
esac
|
||||
if test "$want_expose_statics" = "yes"; then
|
||||
AC_DEFINE_UNQUOTED(CARES_EXPOSE_STATICS, 1,
|
||||
[Defined for build that exposes internal static functions for testing.])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl CARES_CHECK_OPTION_WARNINGS
|
||||
dnl -------------------------------------------------
|
||||
dnl Verify if configure has been invoked with option
|
||||
|
|
Loading…
Reference in New Issue