add cmocka support to remaining unit test makefiles
- also cleaned up some existing test code
This commit is contained in:
@@ -115,8 +115,10 @@ dns_test_begin(FILE *logfile, bool start_managers) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
CHECK(isc_mem_create(0, 0, &mctx));
|
||||
|
||||
CHECK(dst_lib_init(mctx, NULL));
|
||||
dst_active = true;
|
||||
if (!dst_active) {
|
||||
CHECK(dst_lib_init(mctx, NULL));
|
||||
dst_active = true;
|
||||
}
|
||||
|
||||
if (logfile != NULL) {
|
||||
isc_logdestination_t destination;
|
||||
@@ -145,12 +147,13 @@ dns_test_begin(FILE *logfile, bool start_managers) {
|
||||
CHECK(create_managers());
|
||||
|
||||
/*
|
||||
* atf-run changes us to a /tmp directory, so tests
|
||||
* The caller might run from another directory, so tests
|
||||
* that access test data files must first chdir to the proper
|
||||
* location.
|
||||
*/
|
||||
if (chdir(TESTS) == -1)
|
||||
if (chdir(TESTS) == -1) {
|
||||
CHECK(ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
|
||||
@@ -102,44 +102,37 @@ dns_tkeyctx_destroy_test(void **state) {
|
||||
dns_tkeyctx_destroy(&tctx);
|
||||
}
|
||||
|
||||
#else /* LD_WRAP */
|
||||
|
||||
#define _setup NULL
|
||||
#define _teardown NULL
|
||||
|
||||
static void
|
||||
dns_tkeyctx_create_test(void **state __attribute__ ((unused))) {
|
||||
skip();
|
||||
}
|
||||
|
||||
static void
|
||||
dns_tkeyctx_destroy_test(void **state __attribute__ ((unused))) {
|
||||
skip();
|
||||
}
|
||||
|
||||
#endif /* LD_WRAP */
|
||||
|
||||
int main(void) {
|
||||
int
|
||||
main(void) {
|
||||
#if LD_WRAP
|
||||
const struct CMUnitTest tkey_tests[] = {
|
||||
cmocka_unit_test_teardown(dns_tkeyctx_create_test, _teardown),
|
||||
/* cmocka_unit_test(dns_tkey_processquery_test), */
|
||||
/* cmocka_unit_test(dns_tkey_builddhquery_test), */
|
||||
/* cmocka_unit_test(dns_tkey_buildgssquery_test), */
|
||||
/* cmocka_unit_test(dns_tkey_builddeletequery_test), */
|
||||
/* cmocka_unit_test(dns_tkey_processdhresponse_test), */
|
||||
/* cmocka_unit_test(dns_tkey_processgssresponse_test), */
|
||||
/* cmocka_unit_test(dns_tkey_processdeleteresponse_test), */
|
||||
/* cmocka_unit_test(dns_tkey_gssnegotiate_test), */
|
||||
cmocka_unit_test_setup(dns_tkeyctx_destroy_test, _setup),
|
||||
#if 0 /* not yet */
|
||||
cmocka_unit_test(dns_tkey_processquery_test),
|
||||
cmocka_unit_test(dns_tkey_builddhquery_test),
|
||||
cmocka_unit_test(dns_tkey_buildgssquery_test),
|
||||
cmocka_unit_test(dns_tkey_builddeletequery_test),
|
||||
cmocka_unit_test(dns_tkey_processdhresponse_test),
|
||||
cmocka_unit_test(dns_tkey_processgssresponse_test),
|
||||
cmocka_unit_test(dns_tkey_processdeleteresponse_test),
|
||||
cmocka_unit_test(dns_tkey_gssnegotiate_test),
|
||||
#endif
|
||||
};
|
||||
return (cmocka_run_group_tests(tkey_tests, NULL, NULL));
|
||||
#else
|
||||
print_message("1..0 # Skip tkey_test requires LD_WRAP");
|
||||
#endif /* LD_WRAP */
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int
|
||||
main(void) {
|
||||
printf("1..0 # Skipped: cmocka not available\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ IRSDEPLIBS = ../libirs.@A@
|
||||
|
||||
LIBS = ${IRSLIBS} ${CFGLIBS} ${DNSLIBS} ${ISCLIBS} @LIBS@ @ATFLIBS@
|
||||
|
||||
CMOCKA_CFLAGS = @CMOCKA_CFLAGS@
|
||||
CMOCKA_LIBS = @CMOCKA_LIBS@
|
||||
|
||||
OBJS =
|
||||
SRCS = resconf_test.c
|
||||
|
||||
|
||||
@@ -27,10 +27,8 @@ ISCDEPLIBS = ../../isc/libisc.@A@
|
||||
ISCCCLIBS = ../libisccc.@A@
|
||||
ISCCCDEPLIBS = ../libisccc.@A@
|
||||
|
||||
LIBS = @LIBS@ @ATFLIBS@
|
||||
|
||||
CMOCKA_CFLAGS = @CMOCKA_CFLAGS@
|
||||
CMOCKA_LIBS = @CMOCKA_LIBS@
|
||||
CFLAGS = @CFLAGS@ @CMOCKA_CFLAGS@
|
||||
LIBS = @LIBS@ @CMOCKA_LIBS@
|
||||
|
||||
OBJS =
|
||||
SRCS = result_test.c
|
||||
@@ -40,9 +38,9 @@ TARGETS = result_test@EXEEXT@
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
result_test@EXEEXT@: result_test.@O@ ${ISCDEPLIBS} ${ISCCCDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${CMOCKA_FLAGS} \
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} \
|
||||
${LDFLAGS} -o $@ result_test.@O@ \
|
||||
${ISCCCLIBS} ${ISCLIBS} ${LIBS} ${CMOCKA_LIBS}
|
||||
${ISCCCLIBS} ${ISCLIBS} ${LIBS}
|
||||
|
||||
unit::
|
||||
sh ${top_builddir}/unit/unittest.sh
|
||||
|
||||
@@ -33,6 +33,9 @@ ISCCFGDEPLIBS = ../libisccfg.@A@
|
||||
|
||||
LIBS = @LIBS@ @ATFLIBS@
|
||||
|
||||
CMOCKA_CFLAGS = @CMOCKA_CFLAGS@
|
||||
CMOCKA_LIBS = @CMOCKA_LIBS@
|
||||
|
||||
OBJS =
|
||||
SRCS = parser_test.c
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@ NSDEPLIBS = ../libns.@A@
|
||||
|
||||
LIBS = @LIBS@ @ATFLIBS@
|
||||
|
||||
CMOCKA_CFLAGS = @CMOCKA_CFLAGS@
|
||||
CMOCKA_LIBS = @CMOCKA_LIBS@
|
||||
|
||||
OBJS = nstest.@O@
|
||||
SRCS = nstest.c \
|
||||
listenlist_test.c \
|
||||
|
||||
Reference in New Issue
Block a user