list data type partially implemented, unit test framework started

This commit is contained in:
Glen Wiley 2013-07-19 16:19:22 -04:00
parent cce542dd07
commit 0a6dfa46ae
18 changed files with 1519 additions and 278 deletions

View File

@ -16,7 +16,7 @@ The goals of this implementation of the getdns API are:
* Include examples and tests as part of the build
* Document code using doxygen
* Leverage github as much as possible for project coordination
* Coding style/standards follow the [BSD coding style](ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/share/misc/style)
* Coding style/standards follow the BSD coding style <ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/share/misc/style>
* Follow the git flow branching model described at <http://nvie.com/posts/a-successful-git-branching-model/>
** the master branch is always in a production ready state
** the develop branch contains the latest development changes which are merged from develop into master once they are considered production ready
@ -27,10 +27,10 @@ Non-goals (things we will not be doing) include:
Contributors
============
Neel Goyal, Verisign, Inc.
Allison Mankin, Verisign, Inc.
Melinda Shore, No Mountain Software LLC
Glen Wiley, Verisign, Inc.
* Neel Goyal, Verisign, Inc.
* Allison Mankin, Verisign, Inc.
* Melinda Shore, No Mountain Software LLC
* Glen Wiley, Verisign, Inc.
External Dependencies
=====================
@ -42,6 +42,8 @@ Although [libevent](http://libevent.org) is used initially to implement the asyn
Doxygen is used to generate documentation, while this is not technically necessary for the build it makes things a lot more pleasant.
GNU autoconf is used to generate the configure script (and consequently the Makefiles)
Current State of the Implementation
===================================
We are currently in the early stages of building the API so the code should be considered incomplete. The current target platforms and the personal primarily responsible for ensuring it builds and runs on that platform include:

View File

@ -15,8 +15,24 @@ bindir = ${exec_prefix}/bin
srcdir = .
all clean getdns:
default:
cd common && $(MAKE)
all : default test
test:
cd test && $(MAKE) $@
clean:
cd common && $(MAKE) $@
cd test && $(MAKE) $@
rm -f *.o
distclean:
cd common && $(MAKE) $@
cd test && $(MAKE) $@
rm -f libgetdns*.so config.log config.status Makefile
rm -fR autom4te.cache
$(distdir): FORCE
mkdir -p $(distdir)/src
@ -47,4 +63,4 @@ Makefile: Makefile.in config.status
configure.status: configure
./config.status --recheck
.PHONY: all clean
.PHONY: all distclean clean default

View File

@ -15,8 +15,24 @@ bindir = @bindir@
srcdir = @srcdir@
VPATH = @srcdir@
all clean getdns:
default:
cd common && $(MAKE)
all : default test
test:
cd test && $(MAKE) $@
clean:
cd common && $(MAKE) $@
cd test && $(MAKE) $@
rm -f *.o
distclean:
cd common && $(MAKE) $@
cd test && $(MAKE) $@
rm -f libgetdns*.so config.log config.status Makefile
rm -fR autom4te.cache
$(distdir): FORCE
mkdir -p $(distdir)/src
@ -47,4 +63,4 @@ Makefile: Makefile.in config.status
configure.status: configure
./config.status --recheck
.PHONY: all clean
.PHONY: all distclean clean default

View File

@ -33,6 +33,10 @@ libgetdns: getdns_sync.o getdns_context.o getdns_list.o getdns_dict.o getdns_add
clean:
rm -f *.o $(PROGRAMS) libgetdns.so
distclean : clean
rm -f Makefile config.status config.log
rm -Rf autom4te.cache
$(distdir): FORCE
mkdir -p $(distdir)/src
cp configure.ac $(distdir)

View File

@ -33,6 +33,10 @@ libgetdns: getdns_sync.o getdns_context.o getdns_list.o getdns_dict.o getdns_add
clean:
rm -f *.o $(PROGRAMS) libgetdns.so
distclean : clean
rm -f Makefile config.status config.log
rm -Rf autom4te.cache
$(distdir): FORCE
mkdir -p $(distdir)/src
cp configure.ac $(distdir)

View File

@ -1,17 +0,0 @@
## ---------------------- ##
## Running config.status. ##
## ---------------------- ##
This file was extended by getdns config.status 0.320, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
$ ../config.status Makefile
on ubuntu-11-10
config.status:737: creating Makefile

View File

@ -63,4 +63,16 @@ getdns_display_ip_address(
)
{ UNUSED_PARAM(bindata_of_ipv4_or_ipv6_address); return NULL; }
getdns_return_t
getdns_strerror(getdns_return_t err, char *buf, size_t buflen)
{
getdns_return_t retval = GETDNS_RETURN_GOOD;
/* TODO: make this produce an actual string */
snprintf(buf, buflen, "%d", retval);
return retval;
} /* getdns_strerror */
/* getdns_core_only.c */

View File

@ -65,6 +65,7 @@
#define GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED 309
#define GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED_TEXT A query was made with a context that is using stub resolution and a DNSSEC extension specified.
/** @}
*/
@ -238,114 +239,171 @@
* \defgroup rrtypes RR Types
* @{
*/
#define GETDNS_RRTYPE_A 1
#define GETDNS_RRTYPE_NS 2
#define GETDNS_RRTYPE_MD 3
#define GETDNS_RRTYPE_MF 4
#define GETDNS_RRTYPE_CNAME 5
#define GETDNS_RRTYPE_SOA 6
#define GETDNS_RRTYPE_MB 7
#define GETDNS_RRTYPE_MG 8
#define GETDNS_RRTYPE_MR 9
#define GETDNS_RRTYPE_NULL 10
#define GETDNS_RRTYPE_WKS 11
#define GETDNS_RRTYPE_PTR 12
#define GETDNS_RRTYPE_HINFO 13
#define GETDNS_RRTYPE_MINFO 14
#define GETDNS_RRTYPE_MX 15
#define GETDNS_RRTYPE_TXT 16
#define GETDNS_RRTYPE_RP 17
#define GETDNS_RRTYPE_AFSDB 18
#define GETDNS_RRTYPE_X25 19
#define GETDNS_RRTYPE_ISDN 20
#define GETDNS_RRTYPE_RT 21
#define GETDNS_RRTYPE_NSAP 22
#define GETDNS_RRTYPE_SIG 24
#define GETDNS_RRTYPE_KEY 25
#define GETDNS_RRTYPE_PX 26
#define GETDNS_RRTYPE_GPOS 27
#define GETDNS_RRTYPE_AAAA 28
#define GETDNS_RRTYPE_LOC 29
#define GETDNS_RRTYPE_NXT 30
#define GETDNS_RRTYPE_EID 31
#define GETDNS_RRTYPE_NIMLOC 32
#define GETDNS_RRTYPE_SRV 33
#define GETDNS_RRTYPE_ATMA 34
#define GETDNS_RRTYPE_NAPTR 35
#define GETDNS_RRTYPE_KX 36
#define GETDNS_RRTYPE_CERT 37
#define GETDNS_RRTYPE_A6 38
#define GETDNS_RRTYPE_DNAME 39
#define GETDNS_RRTYPE_SINK 40
#define GETDNS_RRTYPE_OPT 41
#define GETDNS_RRTYPE_APL 42
#define GETDNS_RRTYPE_DS 43
#define GETDNS_RRTYPE_SSHFP 44
#define GETDNS_RRTYPE_IPSECKEY 45
#define GETDNS_RRTYPE_RRSIG 46
#define GETDNS_RRTYPE_NSEC 47
#define GETDNS_RRTYPE_DNSKEY 48
#define GETDNS_RRTYPE_DHCID 49
#define GETDNS_RRTYPE_NSEC3 50
#define GETDNS_RRTYPE_A 1
#define GETDNS_RRTYPE_NS 2
#define GETDNS_RRTYPE_MD 3
#define GETDNS_RRTYPE_MF 4
#define GETDNS_RRTYPE_CNAME 5
#define GETDNS_RRTYPE_SOA 6
#define GETDNS_RRTYPE_MB 7
#define GETDNS_RRTYPE_MG 8
#define GETDNS_RRTYPE_MR 9
#define GETDNS_RRTYPE_NULL 10
#define GETDNS_RRTYPE_WKS 11
#define GETDNS_RRTYPE_PTR 12
#define GETDNS_RRTYPE_HINFO 13
#define GETDNS_RRTYPE_MINFO 14
#define GETDNS_RRTYPE_MX 15
#define GETDNS_RRTYPE_TXT 16
#define GETDNS_RRTYPE_RP 17
#define GETDNS_RRTYPE_AFSDB 18
#define GETDNS_RRTYPE_X25 19
#define GETDNS_RRTYPE_ISDN 20
#define GETDNS_RRTYPE_RT 21
#define GETDNS_RRTYPE_NSAP 22
#define GETDNS_RRTYPE_SIG 24
#define GETDNS_RRTYPE_KEY 25
#define GETDNS_RRTYPE_PX 26
#define GETDNS_RRTYPE_GPOS 27
#define GETDNS_RRTYPE_AAAA 28
#define GETDNS_RRTYPE_LOC 29
#define GETDNS_RRTYPE_NXT 30
#define GETDNS_RRTYPE_EID 31
#define GETDNS_RRTYPE_NIMLOC 32
#define GETDNS_RRTYPE_SRV 33
#define GETDNS_RRTYPE_ATMA 34
#define GETDNS_RRTYPE_NAPTR 35
#define GETDNS_RRTYPE_KX 36
#define GETDNS_RRTYPE_CERT 37
#define GETDNS_RRTYPE_A6 38
#define GETDNS_RRTYPE_DNAME 39
#define GETDNS_RRTYPE_SINK 40
#define GETDNS_RRTYPE_OPT 41
#define GETDNS_RRTYPE_APL 42
#define GETDNS_RRTYPE_DS 43
#define GETDNS_RRTYPE_SSHFP 44
#define GETDNS_RRTYPE_IPSECKEY 45
#define GETDNS_RRTYPE_RRSIG 46
#define GETDNS_RRTYPE_NSEC 47
#define GETDNS_RRTYPE_DNSKEY 48
#define GETDNS_RRTYPE_DHCID 49
#define GETDNS_RRTYPE_NSEC3 50
#define GETDNS_RRTYPE_NSEC3PARAM 51
#define GETDNS_RRTYPE_TLSA 52
#define GETDNS_RRTYPE_HIP 55
#define GETDNS_RRTYPE_NINFO 56
#define GETDNS_RRTYPE_RKEY 57
#define GETDNS_RRTYPE_TALINK 58
#define GETDNS_RRTYPE_CDS 59
#define GETDNS_RRTYPE_SPF 99
#define GETDNS_RRTYPE_UINFO 100
#define GETDNS_RRTYPE_UID 101
#define GETDNS_RRTYPE_GID 102
#define GETDNS_RRTYPE_UNSPEC 103
#define GETDNS_RRTYPE_NID 104
#define GETDNS_RRTYPE_L32 105
#define GETDNS_RRTYPE_L64 106
#define GETDNS_RRTYPE_LP 107
#define GETDNS_RRTYPE_TKEY 249
#define GETDNS_RRTYPE_TSIG 250
#define GETDNS_RRTYPE_IXFR 251
#define GETDNS_RRTYPE_AXFR 252
#define GETDNS_RRTYPE_MAILB 253
#define GETDNS_RRTYPE_MAILA 254
#define GETDNS_RRTYPE_URI 256
#define GETDNS_RRTYPE_CAA 257
#define GETDNS_RRTYPE_TA 32768
#define GETDNS_RRTYPE_DLV 32769
#define GETDNS_RRTYPE_TLSA 52
#define GETDNS_RRTYPE_HIP 55
#define GETDNS_RRTYPE_NINFO 56
#define GETDNS_RRTYPE_RKEY 57
#define GETDNS_RRTYPE_TALINK 58
#define GETDNS_RRTYPE_CDS 59
#define GETDNS_RRTYPE_SPF 99
#define GETDNS_RRTYPE_UINFO 100
#define GETDNS_RRTYPE_UID 101
#define GETDNS_RRTYPE_GID 102
#define GETDNS_RRTYPE_UNSPEC 103
#define GETDNS_RRTYPE_NID 104
#define GETDNS_RRTYPE_L32 105
#define GETDNS_RRTYPE_L64 106
#define GETDNS_RRTYPE_LP 107
#define GETDNS_RRTYPE_TKEY 249
#define GETDNS_RRTYPE_TSIG 250
#define GETDNS_RRTYPE_IXFR 251
#define GETDNS_RRTYPE_AXFR 252
#define GETDNS_RRTYPE_MAILB 253
#define GETDNS_RRTYPE_MAILA 254
#define GETDNS_RRTYPE_URI 256
#define GETDNS_RRTYPE_CAA 257
#define GETDNS_RRTYPE_TA 32768
#define GETDNS_RRTYPE_DLV 32769
/** @}
*/
/* Various typedefs */
typedef struct getdns_context_t *getdns_context_t;
typedef uint16_t getdns_return_t;
typedef uint64_t getdns_transaction_t;
typedef enum some_data_type {
t_dict, t_list, t_int, t_bindata
typedef enum getdns_data_type {
t_dict, t_list, t_int, t_bindata, t_invalid
} getdns_data_type;
typedef struct getdns_bindata {
size_t size;
uint8_t *binary_stuff;
} some_bindata;
typedef struct getdns_dict some_dict;
typedef struct getdns_list some_list;
/* Helper functions for data structures */
uint8_t *data;
} getdns_bindata;
typedef struct getdns_dict getdns_dict;
/**
* @param this_list list of any of the supported data types
* @param answer pointer to previsouly allocated storage for size_t
* translate an error code to a string value, not in the original api description
* but seems like a nice thing to have
* @param err return code from GETDNS_RETURN_* defines
* @param buf buffer to which to copy the error string
* @param buflen length of buf
* @return GETDNS_RETURN_GOOD on success
* @return GETDNS_RETURN_NO_SUCH_DICT_NAME if name argument doesnt exist in the dictionary
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the requested data type doesn't match the contents of the indexed argument or name
*/
getdns_return_t getdns_list_get_length(struct getdns_list *this_list, size_t *answer);
getdns_return_t getdns_strerror(getdns_return_t err, char *buf, size_t buflen);
#define GETDNS_LIST_BLOCKSZ 10
/**
* getdns list data type
* Use helper functions getdns_list_* to manipulate and iterate lists
* lists are implemented as arrays internally since the helper functions
* like to reference indexes in the list. Elements are allocated in blocks
* and then marked valid as they are used and invalid as they are not used
* The use cases do not justify working too hard at shrinking the structures.
* Indexes are 0 based.
*/
typedef struct getdns_list {
int numalloc;
int numinuse;
struct getdns_list_item *items;
} getdns_list;
struct getdns_list_item {
int inuse;
getdns_data_type dtype;
union {
getdns_list *list;
getdns_dict *dict;
int n;
getdns_bindata *bindata;
} data;
};
/**
* @param list list of any of the supported data types
* @param answer number of valid items in the list
* @return GETDNS_RETURN_GOOD on success
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if list is not valid or params are NULL
*/
getdns_return_t getdns_list_get_length(struct getdns_list *list, size_t *answer);
/**
* return the enumerated data type of the indexed list item
* @param list the list from which to fetch the data type
* @param index the item in the list from which to fetch the data type
* @param *answer assigned the value of the data type on success
* @return GETDNS_RETURN_GOOD on success
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
*/
getdns_return_t getdns_list_get_data_type(struct getdns_list *this_list, size_t index, getdns_data_type *answer);
getdns_return_t getdns_list_get_dict(struct getdns_list *this_list, size_t index, struct getdns_dict **answer);
/**
* retrieve the list value of the specified list item
* @param list the list from which to fetch the value
* @param index the item in the list from which to fetch the value
* @param **answer assigned a pointer to the list value of the indexed element
* @return GETDNS_RETURN_GOOD on success
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
*/
getdns_return_t getdns_list_get_list(struct getdns_list *this_list, size_t index, struct getdns_list **answer);
getdns_return_t getdns_list_get_bindata(struct getdns_list *this_list, size_t index, struct getdns_bindata **answer);
getdns_return_t getdns_list_get_int(struct getdns_list *this_list, size_t index, uint32_t *answer);
/**
* retrieve the integer value of the specified list item
* @param list the list from which to fetch the item
* @param index the index of the element in the list to fetch from
* @param *answer assigned the integer value of the indexed element
* @return GETDNS_RETURN_GOOD on success
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
* @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
*/
getdns_return_t getdns_list_get_int(struct getdns_list *list, size_t index, uint32_t *answer);
/* Dicts: get the list of names, get the data_type of the
value at a given name, and get the data at a given name */
@ -357,13 +415,33 @@ getdns_return_t getdns_dict_get_bindata(struct getdns_dict *this_dict, char *nam
getdns_return_t getdns_dict_get_int(struct getdns_dict *this_dict, char *name, uint32_t *answer);
/* Lists: create, destroy, and set the data at a given position */
/**
* create a new list with no items
* @return pointer to an allocated list, NULL if insufficient memory
*/
struct getdns_list * getdns_list_create();
/**
* free memory allocated to the list
*/
void getdns_list_destroy(struct getdns_list *this_list);
getdns_return_t getdns_list_set_dict(struct getdns_list *this_list, size_t index, struct getdns_dict *child_dict);
getdns_return_t getdns_list_set_list(struct getdns_list *this_list, size_t index, struct getdns_list *child_list);
getdns_return_t getdns_list_set_bindata(struct getdns_list *this_list, size_t index, struct getdns_bindata *child_bindata);
getdns_return_t getdns_list_set_int(struct getdns_list *this_list, size_t index, uint32_t child_uint32);
/**
* add an item to the tail of a list - note that this was not in the getdns API
* description but the list_set functions seem to be designed to modify an existing
* item in the list. The newly added item has no data type.
* @param *index assigned to the index of the newly added item on success
* @return GETDNS_RETURN_GOOD on success
* @return GETDNS_RETURN_GENERAL_ERROR if out of memory
*/
getdns_return_t getdns_list_add_item(struct getdns_list *list, size_t *index);
getdns_return_t getdns_list_set_dict(struct getdns_list *list, size_t index, struct getdns_dict *child_dict);
getdns_return_t getdns_list_set_list(struct getdns_list *list, size_t index, struct getdns_list *child_list);
getdns_return_t getdns_list_set_bindata(struct getdns_list *list, size_t index, struct getdns_bindata *child_bindata);
/**
* set the integrer value of the indexed item (zero based index)
* @return GETDNS_RETURN_GOOD on success
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
*/
getdns_return_t getdns_list_set_int(struct getdns_list *list, size_t index, uint32_t child_uint32);
/* Dicts: create, destroy, and set the data at a given name */
struct getdns_dict * getdns_dict_create();

View File

@ -29,33 +29,173 @@
*/
#include <getdns_libevent.h>
#include "getdns_core_only.h"
/* stuff to make it compile pedantically */
#define UNUSED_PARAM(x) ((void)(x))
getdns_return_t getdns_list_get_length(struct getdns_list *this_list, size_t *answer)
{ UNUSED_PARAM(this_list); UNUSED_PARAM(answer); return GETDNS_RETURN_GOOD; }
getdns_return_t getdns_list_get_data_type(struct getdns_list *this_list, size_t index, getdns_data_type *answer)
{ UNUSED_PARAM(this_list); UNUSED_PARAM(index); UNUSED_PARAM(answer); return GETDNS_RETURN_GOOD; }
getdns_return_t
getdns_list_get_length(struct getdns_list *list, size_t *answer)
{
int retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if(list != NULL && answer != NULL)
{
retval = GETDNS_RETURN_GOOD;
*answer = list->numinuse;
}
return retval;
} /* getdns_list_get_length */
/*---------------------------------------- getdns_list_get_data_type */
getdns_return_t
getdns_list_get_data_type(struct getdns_list *list, size_t index, getdns_data_type *answer)
{
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if(list != NULL && index < list->numinuse)
{
*answer = list->items[index].dtype;
retval = GETDNS_RETURN_GOOD;
}
return retval;
} /* getdns_list_get_data_type */
getdns_return_t getdns_list_get_dict(struct getdns_list *this_list, size_t index, struct getdns_dict **answer)
{ UNUSED_PARAM(this_list); UNUSED_PARAM(index); UNUSED_PARAM(answer); return GETDNS_RETURN_GOOD; }
getdns_return_t getdns_list_get_list(struct getdns_list *this_list, size_t index, struct getdns_list **answer)
{ UNUSED_PARAM(this_list); UNUSED_PARAM(index); UNUSED_PARAM(answer); return GETDNS_RETURN_GOOD; }
/*---------------------------------------- getdns_list_get_list */
getdns_return_t
getdns_list_get_list(struct getdns_list *list, size_t index, struct getdns_list **answer)
{
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if(list != NULL && index < list->numinuse)
{
if(list->items[index].dtype != t_list)
retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
else
{
*answer = list->items[index].data.list;
retval = GETDNS_RETURN_GOOD;
}
}
return retval;
} /* getdns_list_get_list */
getdns_return_t getdns_list_get_bindata(struct getdns_list *this_list, size_t index, struct getdns_bindata **answer)
{ UNUSED_PARAM(this_list); UNUSED_PARAM(index); UNUSED_PARAM(answer); return GETDNS_RETURN_GOOD; }
getdns_return_t getdns_list_get_int(struct getdns_list *this_list, size_t index, uint32_t *answer)
{ UNUSED_PARAM(this_list); UNUSED_PARAM(index); UNUSED_PARAM(answer); return GETDNS_RETURN_GOOD; }
/*---------------------------------------- getdns_list_get_int */
getdns_return_t
getdns_list_get_int(struct getdns_list *list, size_t index, uint32_t *answer)
{
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
struct getdns_list * getdns_list_create()
{ return NULL; }
if(list != NULL && index < list->numinuse)
{
if(list->items[index].dtype != t_int)
retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
else
{
*answer = list->items[index].data.n;
retval = GETDNS_RETURN_GOOD;
}
}
void getdns_list_destroy(struct getdns_list *this_list)
{ UNUSED_PARAM(this_list); }
return retval;
} /* getdns_list_get_int */
/*---------------------------------------- getdns_list_realloc */
/**
* private function (API users should not be calling this)
* allocates a block of items, should be called when a list needs to grow
* preserves the existing items
* in case of an error the list should be considered unusable
* @return GETDNS_RETURN_GOOD on success, GETDNS_RETURN_GENERIC_ERROR if out of memory
*/
getdns_return_t
getdns_list_realloc(struct getdns_list *list)
{
getdns_return_t retval = GETDNS_RETURN_GENERIC_ERROR;
int i;
struct getdns_list_item *newlist;
if(list != NULL)
{
newlist = (struct getdns_list_item *) realloc(list->items
, (list->numalloc + GETDNS_LIST_BLOCKSZ) * sizeof(struct getdns_list_item));
if(newlist != NULL)
{
list->items = newlist;
for(i=list->numalloc; i<list->numalloc + GETDNS_LIST_BLOCKSZ; i++)
{
list->items[i].inuse = false;
list->items[i].dtype = t_invalid;
}
list->numalloc += GETDNS_LIST_BLOCKSZ;
retval = GETDNS_RETURN_GOOD;
}
}
return retval;
} /* getdns_list_alloc */
/*---------------------------------------- getdns_list_create */
struct getdns_list *
getdns_list_create()
{
struct getdns_list *list = NULL;
list = (struct getdns_list *) malloc(sizeof(struct getdns_list));
if(list != NULL)
{
list->numalloc = 0;
list->numinuse = 0;
list->items = NULL;
getdns_list_realloc(list);
}
return list;
} /* getdns_list_create */
/*---------------------------------------- getdns_list_destroy */
void
getdns_list_destroy(struct getdns_list *list)
{
if(list != NULL)
{
if(list->items != NULL)
free(list->items);
free(list);
}
} /* getdns_list_destroy */
/*---------------------------------------- getdns_list_add_item */
getdns_return_t
getdns_list_add_item(struct getdns_list *list, size_t *index)
{
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if(list != NULL && index != NULL)
{
if(list->numalloc == list->numinuse)
retval = getdns_list_realloc(list);
else
retval = GETDNS_RETURN_GOOD;
if(retval == GETDNS_RETURN_GOOD)
{
*index = list->numinuse;
list->items[*index].inuse = true;
list->numinuse++;
}
}
return retval;
} /* getdns_list_add_item */
getdns_return_t getdns_list_set_dict(struct getdns_list *this_list, size_t index, struct getdns_dict *child_dict)
{ UNUSED_PARAM(this_list); UNUSED_PARAM(index); UNUSED_PARAM(child_dict); return GETDNS_RETURN_GOOD; }
@ -66,7 +206,22 @@ getdns_return_t getdns_list_set_list(struct getdns_list *this_list, size_t index
getdns_return_t getdns_list_set_bindata(struct getdns_list *this_list, size_t index, struct getdns_bindata *child_bindata)
{ UNUSED_PARAM(this_list); UNUSED_PARAM(index); UNUSED_PARAM(child_bindata); return GETDNS_RETURN_GOOD; }
getdns_return_t getdns_list_set_int(struct getdns_list *this_list, size_t index, uint32_t child_uint32)
{ UNUSED_PARAM(this_list); UNUSED_PARAM(index); UNUSED_PARAM(child_uint32); return GETDNS_RETURN_GOOD; }
/*---------------------------------------- getdns_list_set */
getdns_return_t
getdns_list_set_int(struct getdns_list *list, size_t index, uint32_t child_uint32)
{
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if(list != NULL)
{
if(list->numinuse > index)
{
list->items[index].dtype = t_int;
list->items[index].data.n = child_uint32;
}
}
return retval;
} /* getdns_list_set_int */
/* getdns_list.c */

292
src/configure vendored
View File

@ -1,13 +1,11 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for getdns 0.320.
# Generated by GNU Autoconf 2.69 for getdns 0.320.
#
# Report bugs to <melinda.shore@nomountain.net>.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
# Foundation, Inc.
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
#
#
# This configure script is free software; the Free Software Foundation
@ -136,6 +134,31 @@ export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
# Use a proper internal environment variable to ensure we don't fall
# into an infinite loop, continuously re-executing ourselves.
if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
_as_can_reexec=no; export _as_can_reexec;
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
as_fn_exit 255
fi
# We don't want this to propagate to other subprocesses.
{ _as_can_reexec=; unset _as_can_reexec;}
if test "x$CONFIG_SHELL" = x; then
as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
@ -169,7 +192,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
else
exitcode=1; echo positional parameters were not saved.
fi
test x\$exitcode = x0 || exit 1"
test x\$exitcode = x0 || exit 1
test -x / || exit 1"
as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@ -214,21 +238,25 @@ IFS=$as_save_IFS
if test "x$CONFIG_SHELL" != x; then :
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
export CONFIG_SHELL
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
export CONFIG_SHELL
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
exit 255
fi
if test x$as_have_required = xno; then :
@ -331,6 +359,14 @@ $as_echo X"$as_dir" |
} # as_fn_mkdir_p
# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
test -f "$1" && test -x "$1"
} # as_fn_executable_p
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
@ -452,6 +488,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
# If we had to re-execute with $CONFIG_SHELL, we're ensured to have
# already done that, so ensure we don't try to do so again and fall
# in an infinite loop. This has already happened in practice.
_as_can_reexec=no; export _as_can_reexec
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
@ -486,16 +526,16 @@ if (echo >conf$$.file) 2>/dev/null; then
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
# In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
as_ln_s='cp -pR'
fi
else
as_ln_s='cp -p'
as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
@ -507,28 +547,8 @@ else
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in #(
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
as_test_x='test -x'
as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@ -1120,8 +1140,6 @@ target=$target_alias
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
$as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used" >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
@ -1349,9 +1367,9 @@ test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
getdns configure 0.320
generated by GNU Autoconf 2.68
generated by GNU Autoconf 2.69
Copyright (C) 2010 Free Software Foundation, Inc.
Copyright (C) 2012 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
@ -1427,7 +1445,7 @@ $as_echo "$ac_try_echo"; } >&5
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
test -x conftest$ac_exeext
}; then :
ac_retval=0
else
@ -1725,7 +1743,8 @@ int
main ()
{
static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)];
test_array [0] = 0
test_array [0] = 0;
return test_array [0];
;
return 0;
@ -1758,7 +1777,7 @@ This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by getdns $as_me 0.320, which was
generated by GNU Autoconf 2.68. Invocation command line was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -2131,7 +2150,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2171,7 +2190,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2224,7 +2243,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2265,7 +2284,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
@ -2323,7 +2342,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2367,7 +2386,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2813,8 +2832,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
struct stat;
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
@ -3193,7 +3211,7 @@ do
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
as_fn_executable_p "$ac_path_GREP" || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
@ -3259,7 +3277,7 @@ do
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
as_fn_executable_p "$ac_path_EGREP" || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
@ -3459,60 +3477,60 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdbool.h>
#ifndef bool
"error: bool is not defined"
#endif
#ifndef false
"error: false is not defined"
#endif
#if false
"error: false is not 0"
#endif
#ifndef true
"error: true is not defined"
#endif
#if true != 1
"error: true is not 1"
#endif
#ifndef __bool_true_false_are_defined
"error: __bool_true_false_are_defined is not defined"
#endif
#include <stdbool.h>
#ifndef bool
"error: bool is not defined"
#endif
#ifndef false
"error: false is not defined"
#endif
#if false
"error: false is not 0"
#endif
#ifndef true
"error: true is not defined"
#endif
#if true != 1
"error: true is not 1"
#endif
#ifndef __bool_true_false_are_defined
"error: __bool_true_false_are_defined is not defined"
#endif
struct s { _Bool s: 1; _Bool t; } s;
struct s { _Bool s: 1; _Bool t; } s;
char a[true == 1 ? 1 : -1];
char b[false == 0 ? 1 : -1];
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
char d[(bool) 0.5 == true ? 1 : -1];
/* See body of main program for 'e'. */
char f[(_Bool) 0.0 == false ? 1 : -1];
char g[true];
char h[sizeof (_Bool)];
char i[sizeof s.t];
enum { j = false, k = true, l = false * true, m = true * 256 };
/* The following fails for
HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
_Bool n[m];
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
/* Catch a bug in an HP-UX C compiler. See
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
*/
_Bool q = true;
_Bool *pq = &q;
char a[true == 1 ? 1 : -1];
char b[false == 0 ? 1 : -1];
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
char d[(bool) 0.5 == true ? 1 : -1];
/* See body of main program for 'e'. */
char f[(_Bool) 0.0 == false ? 1 : -1];
char g[true];
char h[sizeof (_Bool)];
char i[sizeof s.t];
enum { j = false, k = true, l = false * true, m = true * 256 };
/* The following fails for
HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
_Bool n[m];
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
/* Catch a bug in an HP-UX C compiler. See
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
*/
_Bool q = true;
_Bool *pq = &q;
int
main ()
{
bool e = &s;
*pq |= q;
*pq |= ! q;
/* Refer to every declared value, to avoid compiler optimizations. */
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+ !m + !n + !o + !p + !q + !pq);
bool e = &s;
*pq |= q;
*pq |= ! q;
/* Refer to every declared value, to avoid compiler optimizations. */
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+ !m + !n + !o + !p + !q + !pq);
;
return 0;
@ -3527,7 +3545,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
$as_echo "$ac_cv_header_stdbool_h" >&6; }
ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
if test "x$ac_cv_type__Bool" = xyes; then :
cat >>confdefs.h <<_ACEOF
@ -3537,6 +3555,7 @@ _ACEOF
fi
if test $ac_cv_header_stdbool_h = yes; then
$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
@ -3609,7 +3628,7 @@ _ACEOF
esac
ac_config_files="$ac_config_files Makefile common/Makefile"
ac_config_files="$ac_config_files Makefile common/Makefile test/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@ -4054,16 +4073,16 @@ if (echo >conf$$.file) 2>/dev/null; then
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
# In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
as_ln_s='cp -pR'
fi
else
as_ln_s='cp -p'
as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
@ -4123,28 +4142,16 @@ else
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in #(
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
test -f "$1" && test -x "$1"
} # as_fn_executable_p
as_test_x='test -x'
as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@ -4166,7 +4173,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# values after options handling.
ac_log="
This file was extended by getdns $as_me 0.320, which was
generated by GNU Autoconf 2.68. Invocation command line was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
@ -4219,10 +4226,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
getdns config.status 0.320
configured by $0, generated by GNU Autoconf 2.68,
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Copyright (C) 2010 Free Software Foundation, Inc.
Copyright (C) 2012 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
@ -4299,7 +4306,7 @@ fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'
@ -4330,6 +4337,7 @@ do
case $ac_config_target in
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"common/Makefile") CONFIG_FILES="$CONFIG_FILES common/Makefile" ;;
"test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac

View File

@ -27,5 +27,5 @@ AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
AC_CONFIG_FILES([Makefile common/Makefile])
AC_CONFIG_FILES([Makefile common/Makefile test/Makefile])
AC_OUTPUT

527
src/install-sh Executable file
View File

@ -0,0 +1,527 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-11-20.07; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set fnord $dstdir
shift
$posix_glob set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

79
src/test/Makefile.in Normal file
View File

@ -0,0 +1,79 @@
#
# @configure_input@
#
# TODO: OSX, fix DYLD_LIBRARY_PATH problem
package = @PACKAGE_NAME@
version = @PACKAGE_VERSION@
tarname = @PACKAGE_TARNAME@
distdir = $(tarname)-$(version)
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
srcdir = @srcdir@
VPATH = @srcdir@
CC=gcc
CFLAGS=-Wall -g -I./ -I../common -I$(srcdir)/ -std=c99
LDFLAGS=-L../common
LDLIBS=-lgetdns
PROGRAMS=tests_list
.SUFFIXES: .c .o .a .lo .h .can .out .res
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
.out.res:
diff $< $(basename $<).can > $@
all: tests_list tests_list.res
tests_list: tests_list.o ../common/libgetdns.so testmessages.o
$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
# we want the library that was just built to be used in the tests
# NOT one that is installed on the system
tests_list.out : tests_list
DYLD_LIBRARY_PATH=../common; ./tests_list > tests_list.out
clean:
rm -f *.o *.out *.res $(PROGRAMS)
distclean : clean
rm -f Makefile config.status config.log
rm -Rf autom4te.cache
$(distdir): FORCE
mkdir -p $(distdir)/src
cp configure.ac $(distdir)
cp configure $(distdir)
cp Makefile.in $(distdir)
cp src/Makefile.in $(distdir)/src
distcheck: $(distdir).tar.gz
gzip -cd $(distdir).tar.gz | tar xvf -
cd $(distdir) && ./configure
cd $(distdir) && $(MAKE) all
cd $(distdir) && $(MAKE) check
cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install
cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall
@remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \
if test "$${remaining}" -ne 0; then
echo "@@@ $${remaining} file(s) remaining in stage directory!"; \
exit 1; \
fi
cd $(distdir) && $(MAKE) clean
rm -rf $(distdir)
@echo "*** Package $(distdir).tar.gz is ready for distribution"
Makefile: Makefile.in ../config.status
cd .. && ./config.status $@
configure.status: configure
cd .. && ./config.status --recheck
.PHONY: all clean distclean

22
src/test/README Normal file
View File

@ -0,0 +1,22 @@
The programs in this directory are intended to provide a regression
test suite - we should be adding tests here as we build the package.
When building unit tests one approach that makes regression testing
easy is to generate canonical output and maintain that with the
code. Changes to the code should produce output that matches the
canonical output, if it doesn't then the developer needs to look at
the differences to determine whether something broke or is fixed. Once
the new output is verified it can replace the canonical output.
A typical flow might be illustrated via tests_list:
- build tests_list (an executable linked against the library)
- run the regression tests
./tests_list > tests_list.out
- compare output to canonical output
diff tests_list.out tests_list.can > tests_list.res
- if there are any diffs then a change affected the output
- verify the new output and copy it to tests_list.can
- commit the new canonical output to the repository
Some of the tests that remain to be implemented:
- memory leak testing integrated into the test progs

81
src/test/testmessages.c Normal file
View File

@ -0,0 +1,81 @@
/**
* \file
* \brief display messages to support unit testing
*/
/* The MIT License (MIT)
* Copyright (c) 2013 Verisign, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include "testmessages.h"
static char *testprog = NULL;
static char **cases = NULL;
static int ncases = 0;
void
tstmsg_prog_begin(char *prognm)
{
if(testprog != NULL)
{ tstmsg_prog_end();
free(testprog);
}
testprog = strdup(prognm);
printf("TESTPROG %s START\n", testprog);
} /* tstmsg_prog_begin */
void
tstmsg_prog_end()
{
printf("TESTPROG %s END\n", testprog);
} /* tstmsg_prog_end */
void
tstmsg_case_begin(char *casenm)
{
ncases++;
cases = (char **) realloc(cases, sizeof(char *) * ncases);
cases[ncases-1] = strdup(casenm);
printf("TESTCASE %s:%s BEGIN\n", testprog, cases[ncases-1]);
} /* tstmsg_case_begin */
void
tstmsg_case_end(void)
{
if(ncases > 0)
{
printf("TESTCASE %s:%s END\n", testprog, cases[ncases-1]);
ncases--;
free(cases[ncases]);
cases = (char **) realloc(cases, sizeof(char *) * ncases);
}
} /* tstmsg_case_end */
void
tstmsg_case_msg(char *msg)
{
printf(" %s:%s: %s\n", testprog, cases[ncases-1], msg);
} /* tstmsg_case_msg */
/* testmessages.c */

58
src/test/testmessages.h Normal file
View File

@ -0,0 +1,58 @@
/**
* \file
* \brief display messages to support unit testing
*/
/* The MIT License (MIT)
* Copyright (c) 2013 Verisign, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef TESTMESSAGES_H
#define TESTMESSAGES_H 1
/**
* call at the start of a test program to display start message
*/
void tstmsg_prog_begin(char *prognm);
/**
* call at the end of a test program to display end message
*/
void tstmsg_prog_end();
/**
* call at the start of a test case (after test_prog_begin)
* to display case start message
*/
void tstmsg_case_begin(char *casenm);
/**
* call at the end of a test case (after test_prog_begin/test_case_begin)
* to display case end message
*/
void tstmsg_case_end();
/**
* call to display message regarding the current test case
* to display case end message
*/
void tstmsg_case_msg(char *msg);
#endif
/* testmessages.h */

173
src/test/tests_list.c Normal file
View File

@ -0,0 +1,173 @@
/**
* \file
* \brief unit tests for getdns_list helper routines
*/
/* The MIT License (MIT)
* Copyright (c) 2013 Verisign, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include "testmessages.h"
#include "getdns_core_only.h"
#define TSTMSGBUF 80
/*---------------------------------------- tst_setget */
/**
* test the routines that set and get values of items in the list
*/
void
tst_setget(void)
{
char msg[TSTMSGBUF];
size_t index;
uint32_t ans_int;
getdns_return_t retval;
struct getdns_list *list = NULL;
tstmsg_case_begin("tst_setget");
list = getdns_list_create();
/* test get functions against empty list and with bogus params */
tstmsg_case_msg("getdns_list_get_int() empty list");
retval = getdns_list_get_int(NULL, index, &ans_int);
sprintf(msg, "getdns_list_get_int(NULL, index, &ans_int),retval = %d", retval);
tstmsg_case_msg(msg);
retval = getdns_list_get_int(list, index, NULL);
sprintf(msg, "getdns_list_get_int(list, index, NULL),retval = %d", retval);
tstmsg_case_msg(msg);
tstmsg_case_msg("getdns_list_get_int(list, 0, &ans_int)");
retval = getdns_list_get_int(list, 0, &ans_int);
sprintf(msg, "getdns_list_get_int,retval = %d", retval);
tstmsg_case_msg(msg);
tstmsg_case_msg("getdns_list_get_int(list, 1, &ans_int)");
retval = getdns_list_get_int(list, 1, &ans_int);
sprintf(msg, "getdns_list_set_int,retval = %d", retval);
tstmsg_case_msg(msg);
getdns_list_destroy(list);
tstmsg_case_end();
return;
} /* tst_setget */
/*---------------------------------------- tst_create */
/**
* test the create, destroy and allocation functions
*/
void
tst_create(void)
{
char msg[TSTMSGBUF];
size_t index;
int i;
getdns_return_t retval;
struct getdns_list *list = NULL;
/* make sure we can do a simple create/destroy first */
tstmsg_case_begin("tst_create");
tstmsg_case_msg("getdns_list_create");
list = getdns_list_create();
if(list != NULL)
{
tstmsg_case_msg("getdns_list_destroy(list)");
getdns_list_destroy(list);
}
tstmsg_case_msg("getdns_list_destroy(NULL)");
getdns_list_destroy(NULL);
/* add items until we force it to allocate more storage */
tstmsg_case_msg("getdns_add_item(list) past block size");
list = getdns_list_create();
for(i=0; i<GETDNS_LIST_BLOCKSZ+2; i++)
{
retval = getdns_list_add_item(list, &index);
if(retval != GETDNS_RETURN_GOOD)
{
sprintf(msg, "getdns_list_add_item,i=%d,retval = %d", i, retval);
tstmsg_case_msg(msg);
}
else
{
if(index != i)
{
sprintf(msg, "getdns_list_add_item,i=%d,index=%d,retval = %d"
, i, (int) index, retval);
tstmsg_case_msg(msg);
}
}
}
tstmsg_case_msg("getdns_list_get_length(list)");
retval = getdns_list_get_length(list, &index);
sprintf(msg, "list length = %d", (int) index);
tstmsg_case_msg(msg);
tstmsg_case_msg("getdns_list_get_length()");
retval = getdns_list_get_length(NULL, &index);
sprintf(msg, "NUll, &i, retval = %d", retval);
tstmsg_case_msg(msg);
retval = getdns_list_get_length(NULL, NULL);
sprintf(msg, "NUll, NULL, retval = %d", retval);
tstmsg_case_msg(msg);
retval = getdns_list_get_length(list, NULL);
sprintf(msg, "list, NULL, retval = %d", retval);
tstmsg_case_msg(msg);
getdns_list_destroy(list);
tstmsg_case_end();
return;
} /* tst_create */
/**
* runs unit tests against list management routines
*/
int
main(int argc, char *argv[])
{
tstmsg_prog_begin("tests_list");
tst_create();
tst_setget();
tstmsg_prog_end();
return 0;
} /* main */
/* end tests_list.c */

23
src/test/tests_list.can Normal file
View File

@ -0,0 +1,23 @@
TESTPROG tests_list START
TESTCASE tests_list:tst_create BEGIN
tests_list:tst_create: getdns_list_create
tests_list:tst_create: getdns_list_destroy(list)
tests_list:tst_create: getdns_list_destroy(NULL)
tests_list:tst_create: getdns_add_item(list) past block size
tests_list:tst_create: getdns_list_get_length(list)
tests_list:tst_create: list length = 12
tests_list:tst_create: getdns_list_get_length()
tests_list:tst_create: NUll, &i, retval = 304
tests_list:tst_create: NUll, NULL, retval = 304
tests_list:tst_create: list, NULL, retval = 304
TESTCASE tests_list:tst_create END
TESTCASE tests_list:tst_setget BEGIN
tests_list:tst_setget: getdns_list_get_int() empty list
tests_list:tst_setget: getdns_list_get_int(NULL, index, &ans_int),retval = 304
tests_list:tst_setget: getdns_list_get_int(list, index, NULL),retval = 304
tests_list:tst_setget: getdns_list_get_int(list, 0, &ans_int)
tests_list:tst_setget: getdns_list_get_int,retval = 304
tests_list:tst_setget: getdns_list_get_int(list, 1, &ans_int)
tests_list:tst_setget: getdns_list_set_int,retval = 304
TESTCASE tests_list:tst_setget END
TESTPROG tests_list END