convert config_test; remove ATF from lib/lwres/tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
syntax(2)
|
||||
test_suite('bind9')
|
||||
|
||||
atf_test_program{name='config_test'}
|
||||
tap_test_program{name='config_test'}
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
# See the COPYRIGHT file distributed with this work for additional
|
||||
# information regarding copyright ownership.
|
||||
|
||||
# $Id$
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
@@ -21,13 +19,14 @@ VERSION=@BIND9_VERSION@
|
||||
|
||||
@BIND9_MAKE_INCLUDES@
|
||||
|
||||
CINCLUDES = -I. -Iinclude -I../include ${LWRES_INCLUDES}
|
||||
CINCLUDES = -I. -Iinclude -I../include ${LWRES_INCLUDES} ${ISC_INCLUDES}
|
||||
CDEFINES = -DTESTS="\"${top_builddir}/lib/lwres/tests/\""
|
||||
|
||||
LWRESLIBS = ../liblwres.@A@
|
||||
LWRESDEPLIBS = ../liblwres.@A@
|
||||
|
||||
LIBS = @LIBS@ @ATFLIBS@
|
||||
CFLAGS = @CFLAGS@ @CMOCKA_CFLAGS@
|
||||
LIBS = @LIBS@ @CMOCKA_LIBS@
|
||||
|
||||
OBJS =
|
||||
SRCS = config_test.c
|
||||
|
||||
@@ -11,30 +11,37 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
#if HAVE_CMOCKA
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
|
||||
#include "../lwconfig.c"
|
||||
|
||||
#define UNIT_TESTING
|
||||
#include <cmocka.h>
|
||||
|
||||
static void
|
||||
setup_test() {
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
ATF_CHECK(chdir(TESTS) != -1);
|
||||
assert_int_not_equal(chdir(TESTS), -1);
|
||||
}
|
||||
|
||||
ATF_TC(parse_linklocal);
|
||||
ATF_TC_HEAD(parse_linklocal, tc) {
|
||||
atf_tc_set_md_var(tc, "descr", "lwres_conf_parse link-local nameserver");
|
||||
}
|
||||
ATF_TC_BODY(parse_linklocal, tc) {
|
||||
/* lwres_conf_parse link-local nameserver */
|
||||
static void
|
||||
parse_linklocal(void **state) {
|
||||
lwres_result_t result;
|
||||
lwres_context_t *ctx = NULL;
|
||||
unsigned char addr[16] = { 0xfe, 0x80, 0x00, 0x00,
|
||||
@@ -42,27 +49,40 @@ ATF_TC_BODY(parse_linklocal, tc) {
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01 };
|
||||
|
||||
UNUSED(tc);
|
||||
UNUSED(state);
|
||||
|
||||
setup_test();
|
||||
|
||||
lwres_context_create(&ctx, NULL, NULL, NULL,
|
||||
LWRES_CONTEXT_USEIPV4 | LWRES_CONTEXT_USEIPV6);
|
||||
ATF_CHECK_EQ(ctx->confdata.nsnext, 0);
|
||||
ATF_CHECK_EQ(ctx->confdata.nameservers[0].zone, 0);
|
||||
assert_int_equal(ctx->confdata.nsnext, 0);
|
||||
assert_int_equal(ctx->confdata.nameservers[0].zone, 0);
|
||||
|
||||
result = lwres_conf_parse(ctx, "testdata/link-local.conf");
|
||||
ATF_CHECK_EQ(result, LWRES_R_SUCCESS);
|
||||
ATF_CHECK_EQ(ctx->confdata.nsnext, 1);
|
||||
ATF_CHECK_EQ(ctx->confdata.nameservers[0].zone, 1);
|
||||
ATF_CHECK_EQ(memcmp(ctx->confdata.nameservers[0].address, addr, 16), 0);
|
||||
assert_int_equal(result, LWRES_R_SUCCESS);
|
||||
assert_int_equal(ctx->confdata.nsnext, 1);
|
||||
assert_int_equal(ctx->confdata.nameservers[0].zone, 1);
|
||||
assert_memory_equal(ctx->confdata.nameservers[0].address, addr, 16);
|
||||
lwres_context_destroy(&ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
ATF_TP_ADD_TCS(tp) {
|
||||
ATF_TP_ADD_TC(tp, parse_linklocal);
|
||||
return (atf_no_error());
|
||||
int
|
||||
main(void) {
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(parse_linklocal),
|
||||
};
|
||||
|
||||
return (cmocka_run_group_tests(tests, NULL, NULL));
|
||||
}
|
||||
|
||||
#else /* HAVE_CMOCKA */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(void) {
|
||||
printf("1..0 # Skipped: cmocka not available\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user