+4752. [test] Add unit test for isc_net_pton. [RT #46171]
+
4751. [func] "dnssec-signzone -S" can now automatically add parent
synchronization records (CDS and CDNSKEY) according
to key metadata set using the -Psync and -Dsync
tp += strlen(tp);
break;
}
- INSIST((tp - tmp) < sizeof(tmp));
+ INSIST((size_t)(tp - tmp) < sizeof(tmp));
tp += snprintf(tp, sizeof(tmp) - (tp - tmp), "%x", words[i]);
}
/* Was it a trailing run of 0x00's? */
tp: file_test
tp: hash_test
tp: ht_test
+tp: inet_ntop_test
tp: lex_test
tp: mem_test
tp: netaddr_test
OBJS = isctest.@O@
SRCS = isctest.c aes_test.c buffer_test.c counter_test.c \
errno_test.c file_test.c hash_test.c ht_test.c \
- lex_test.c mem_test.c netaddr_test.c parse_test.c \
- pool_test.c print_test.c queue_test.c radix_test.c \
- random_test.c regex_test.c result_test.c safe_test.c \
- sockaddr_test.c socket_test.c socket_test.c \
+ inet_ntop_test.c lex_test.c mem_test.c netaddr_test.c \
+ parse_test.c pool_test.c print_test.c queue_test.c \
+ radix_test.c random_test.c regex_test.c result_test.c \
+ safe_test.c sockaddr_test.c socket_test.c socket_test.c \
symtab_test.c task_test.c taskpool_test.c time_test.c
SUBDIRS =
TARGETS = aes_test@EXEEXT@ buffer_test@EXEEXT@ counter_test@EXEEXT@ \
errno_test@EXEEXT@ file_test@EXEEXT@ hash_test@EXEEXT@ \
- ht_test@EXEEXT@ lex_test@EXEEXT@ mem_test@EXEEXT@ \
- netaddr_test@EXEEXT@ parse_test@EXEEXT@ pool_test@EXEEXT@ \
- print_test@EXEEXT@ queue_test@EXEEXT@ radix_test@EXEEXT@ \
- random_test@EXEEXT@ regex_test@EXEEXT@ result_test@EXEEXT@ \
- safe_test@EXEEXT@ sockaddr_test@EXEEXT@ socket_test@EXEEXT@ \
+ ht_test@EXEEXT@ inet_ntop_test@EXEEXT@ lex_test@EXEEXT@ \
+ mem_test@EXEEXT@ netaddr_test@EXEEXT@ parse_test@EXEEXT@ \
+ pool_test@EXEEXT@ print_test@EXEEXT@ queue_test@EXEEXT@ \
+ radix_test@EXEEXT@ random_test@EXEEXT@ regex_test@EXEEXT@ \
+ result_test@EXEEXT@ safe_test@EXEEXT@ \
+ sockaddr_test@EXEEXT@ socket_test@EXEEXT@ \
socket_test@EXEEXT@ symtab_test@EXEEXT@ task_test@EXEEXT@ \
taskpool_test@EXEEXT@ time_test@EXEEXT@
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
ht_test.@O@ ${ISCLIBS} ${LIBS}
+inet_ntop_test.c.@O@: ${top_srcdir}/lib/isc/ntop_test.c
+inet_ntop_test@EXEEXT@: inet_ntop_test.@O@ ${ISCDEPLIBS}
+ ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
+ inet_ntop_test.@O@ ${ISCLIBS} ${LIBS}
+
lex_test@EXEEXT@: lex_test.@O@ ${ISCDEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
lex_test.@O@ ${ISCLIBS} ${LIBS}
--- /dev/null
+/*
+ * Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <config.h>
+
+#include <atf-c.h>
+
+/*
+ * Force the prototype for isc_net_ntop to be declared.
+ */
+#include <isc/platform.h>
+#undef ISC_PLATFORM_NEEDNTOP
+#define ISC_PLATFORM_NEEDNTOP
+#include "../inet_ntop.c"
+
+ATF_TC(isc_net_ntop);
+ATF_TC_HEAD(isc_net_ntop, tc) {
+ atf_tc_set_md_var(tc, "descr", "isc_net_ntop implementation");
+}
+ATF_TC_BODY(isc_net_ntop, tc) {
+ char buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
+ int r;
+ size_t i;
+ unsigned char abuf[16];
+ struct {
+ int family;
+ const char * address;
+ } testdata[] = {
+ { AF_INET, "0.0.0.0" },
+ { AF_INET, "0.1.0.0" },
+ { AF_INET, "0.0.2.0" },
+ { AF_INET, "0.0.0.3" },
+ { AF_INET, "255.255.255.255" },
+ { AF_INET6, "::" },
+ { AF_INET6, "::1.2.3.4" },
+ { AF_INET6, "::ffff:1.2.3.4" },
+ { AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" }
+ };
+
+ for (i = 0; i < sizeof(testdata)/sizeof(testdata[0]); i++) {
+ r = inet_pton(testdata[i].family, testdata[i].address, abuf);
+ ATF_REQUIRE_EQ_MSG(r, 1, "%s", testdata[i].address);
+ isc_net_ntop(testdata[i].family, abuf, buf, sizeof(buf));
+ ATF_CHECK_STREQ(buf, testdata[i].address);
+ }
+}
+
+/*
+ * Main
+ */
+ATF_TP_ADD_TCS(tp) {
+ ATF_TP_ADD_TC(tp, isc_net_ntop);
+ return (atf_no_error());
+}