summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2014-12-05 15:47:38 -0500
committerThomas Markwalder <tmark@isc.org>2014-12-05 15:47:38 -0500
commit2731a82c8369439178f0e1cc7de58f30f0fe8897 (patch)
treeb3b252cc97b03e3a08ac3d332262693e1b39611e
parent04daf4fe4b5dd4afac1aed901bfe8dda3ec0edf3 (diff)
downloadisc-dhcp-2731a82c8369439178f0e1cc7de58f30f0fe8897.tar.gz
[master] Updated build to accomodate new unit tests in common
Merges in rt20558_b.
-rw-r--r--.gitignore1
-rw-r--r--common/options.c3
-rw-r--r--common/tests/Makefile.am8
-rw-r--r--common/tests/Makefile.in31
-rw-r--r--common/tests/ns_name_test.c96
-rw-r--r--common/tree.c4
6 files changed, 135 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index a68a802e..2faf8b47 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ client/tests/test-suite.log
common/tests/alloc_unittest
common/tests/dns_unittest
common/tests/misc_unittest
+common/tests/ns_name_unittest
config.log
config.report
config.status
diff --git a/common/options.c b/common/options.c
index 725d3bef..faeb3efb 100644
--- a/common/options.c
+++ b/common/options.c
@@ -2277,9 +2277,10 @@ void set_option (universe, options, option, op)
(memcmp(oc->option->format, "Dc", 2) == 0))) {
case 1:
/* Only one is "Dc", this won't work
- * Not sure if you make this occur, but just
+ * Not sure if you can make this occur, but just
* in case. */
log_error ("Both options must be Dc format");
+ option_cache_dereference (&noc, MDL);
return;
case 2:
/* Both are "Dc", change the code */
diff --git a/common/tests/Makefile.am b/common/tests/Makefile.am
index 08d76fc3..b9b11219 100644
--- a/common/tests/Makefile.am
+++ b/common/tests/Makefile.am
@@ -8,7 +8,7 @@ ATF_TESTS =
if HAVE_ATF
-ATF_TESTS += alloc_unittest dns_unittest misc_unittest
+ATF_TESTS += alloc_unittest dns_unittest misc_unittest ns_name_unittest
alloc_unittest_SOURCES = test_alloc.c $(top_srcdir)/tests/t_api_dhcp.c
alloc_unittest_LDADD = $(ATF_LDFLAGS)
@@ -28,6 +28,12 @@ misc_unittest_LDADD += ../libdhcp.a \
../../omapip/libomapi.a ../../bind/lib/libirs.a \
../../bind/lib/libdns.a ../../bind/lib/libisccfg.a ../../bind/lib/libisc.a
+ns_name_unittest_SOURCES = ns_name_test.c $(top_srcdir)/tests/t_api_dhcp.c
+ns_name_unittest_LDADD = $(ATF_LDFLAGS)
+ns_name_unittest_LDADD += ../libdhcp.a \
+ ../../omapip/libomapi.a ../../bind/lib/libirs.a \
+ ../../bind/lib/libdns.a ../../bind/lib/libisccfg.a ../../bind/lib/libisc.a
+
check: $(ATF_TESTS)
atf-run | atf-report
diff --git a/common/tests/Makefile.in b/common/tests/Makefile.in
index 8a5d3f1e..c9148eea 100644
--- a/common/tests/Makefile.in
+++ b/common/tests/Makefile.in
@@ -77,7 +77,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-@HAVE_ATF_TRUE@am__append_1 = alloc_unittest dns_unittest misc_unittest
+@HAVE_ATF_TRUE@am__append_1 = alloc_unittest dns_unittest misc_unittest ns_name_unittest
check_PROGRAMS = $(am__EXEEXT_2)
subdir = common/tests
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
@@ -91,7 +91,8 @@ CONFIG_HEADER = $(top_builddir)/includes/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@HAVE_ATF_TRUE@am__EXEEXT_1 = alloc_unittest$(EXEEXT) \
-@HAVE_ATF_TRUE@ dns_unittest$(EXEEXT) misc_unittest$(EXEEXT)
+@HAVE_ATF_TRUE@ dns_unittest$(EXEEXT) misc_unittest$(EXEEXT) \
+@HAVE_ATF_TRUE@ ns_name_unittest$(EXEEXT)
am__EXEEXT_2 = $(am__EXEEXT_1)
am__alloc_unittest_SOURCES_DIST = test_alloc.c \
$(top_srcdir)/tests/t_api_dhcp.c
@@ -124,6 +125,16 @@ misc_unittest_OBJECTS = $(am_misc_unittest_OBJECTS)
@HAVE_ATF_TRUE@ ../../bind/lib/libirs.a ../../bind/lib/libdns.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisccfg.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisc.a
+am__ns_name_unittest_SOURCES_DIST = ns_name_test.c \
+ $(top_srcdir)/tests/t_api_dhcp.c
+@HAVE_ATF_TRUE@am_ns_name_unittest_OBJECTS = ns_name_test.$(OBJEXT) \
+@HAVE_ATF_TRUE@ t_api_dhcp.$(OBJEXT)
+ns_name_unittest_OBJECTS = $(am_ns_name_unittest_OBJECTS)
+@HAVE_ATF_TRUE@ns_name_unittest_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+@HAVE_ATF_TRUE@ ../libdhcp.a ../../omapip/libomapi.a \
+@HAVE_ATF_TRUE@ ../../bind/lib/libirs.a ../../bind/lib/libdns.a \
+@HAVE_ATF_TRUE@ ../../bind/lib/libisccfg.a \
+@HAVE_ATF_TRUE@ ../../bind/lib/libisc.a
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -157,10 +168,11 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(alloc_unittest_SOURCES) $(dns_unittest_SOURCES) \
- $(misc_unittest_SOURCES)
+ $(misc_unittest_SOURCES) $(ns_name_unittest_SOURCES)
DIST_SOURCES = $(am__alloc_unittest_SOURCES_DIST) \
$(am__dns_unittest_SOURCES_DIST) \
- $(am__misc_unittest_SOURCES_DIST)
+ $(am__misc_unittest_SOURCES_DIST) \
+ $(am__ns_name_unittest_SOURCES_DIST)
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
@@ -352,6 +364,12 @@ ATF_TESTS = $(am__append_1)
@HAVE_ATF_TRUE@ ../../bind/lib/libdns.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisccfg.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisc.a
+@HAVE_ATF_TRUE@ns_name_unittest_SOURCES = ns_name_test.c $(top_srcdir)/tests/t_api_dhcp.c
+@HAVE_ATF_TRUE@ns_name_unittest_LDADD = $(ATF_LDFLAGS) ../libdhcp.a \
+@HAVE_ATF_TRUE@ ../../omapip/libomapi.a ../../bind/lib/libirs.a \
+@HAVE_ATF_TRUE@ ../../bind/lib/libdns.a \
+@HAVE_ATF_TRUE@ ../../bind/lib/libisccfg.a \
+@HAVE_ATF_TRUE@ ../../bind/lib/libisc.a
all: all-recursive
.SUFFIXES:
@@ -402,6 +420,10 @@ misc_unittest$(EXEEXT): $(misc_unittest_OBJECTS) $(misc_unittest_DEPENDENCIES) $
@rm -f misc_unittest$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(misc_unittest_OBJECTS) $(misc_unittest_LDADD) $(LIBS)
+ns_name_unittest$(EXEEXT): $(ns_name_unittest_OBJECTS) $(ns_name_unittest_DEPENDENCIES) $(EXTRA_ns_name_unittest_DEPENDENCIES)
+ @rm -f ns_name_unittest$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(ns_name_unittest_OBJECTS) $(ns_name_unittest_LDADD) $(LIBS)
+
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -410,6 +432,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ns_name_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_api_dhcp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_alloc.Po@am__quote@
diff --git a/common/tests/ns_name_test.c b/common/tests/ns_name_test.c
index adbae602..93ffa761 100644
--- a/common/tests/ns_name_test.c
+++ b/common/tests/ns_name_test.c
@@ -20,6 +20,9 @@ ATF_TC_HEAD(MRns_name_list_funcs, tc) {
"compress from text, decompress to text");
}
+void concat_lists (const char* label, struct data_string* list1,
+ struct data_string* list2, const char *refbuf, size_t reflen);
+
ATF_TC_BODY(MRns_name_list_funcs, tc) {
const char text_list[] = "one.two.com,three.two.com,four.two.com";
@@ -56,9 +59,102 @@ ATF_TC_BODY(MRns_name_list_funcs, tc) {
"uncompressed buffer content wrong");
}
+ATF_TC(concat_dclists);
+
+ATF_TC_HEAD(concat_dclists, tc) {
+ atf_tc_set_md_var(tc, "descr", "concat_dclists function test, "
+ "permutate concating empty and non-empty lists");
+}
+
+ATF_TC_BODY(concat_dclists, tc) {
+ /* Compressed list version of "booya.com" */
+ const char data[] =
+ {0x05, 0x62, 0x6f, 0x6f, 0x79, 0x61, 0x03, 0x63, 0x6f, 0x6d, 0x00 };
+
+ /* Concatenation of data with itself */
+ const char data2[] =
+ {0x05, 0x62, 0x6f, 0x6f, 0x79, 0x61, 0x03, 0x63, 0x6f, 0x6d, 0x00,
+ 0xc0, 0x00 };
+
+ struct data_string nonempty;
+ struct data_string empty;
+
+ /* Make a non-empty compressed list from data[] */
+ nonempty.len = sizeof(data);
+ buffer_allocate(&(nonempty.buffer), nonempty.len, MDL);
+ memcpy(nonempty.buffer->data, data, nonempty.len);
+ nonempty.data = nonempty.buffer->data;
+
+ /* Permutate NULL with non-empty list */
+ concat_lists("null + null", NULL, NULL, "", 1);
+ concat_lists("null + nonempty", NULL, &nonempty, data, sizeof(data));
+ concat_lists("nonempty + null", &nonempty, NULL, data, sizeof(data));
+
+ /* Permutate zeroed-out list with non-empty list */
+ memset (&empty, 0x00, sizeof(struct data_string));
+ concat_lists("zero-list + zero-list", &empty, &empty, "", 1);
+ concat_lists("zero-list + nonempty", &empty, &nonempty, data, sizeof(data));
+ concat_lists("nonempty + zero-list", &nonempty, &empty, data, sizeof(data));
+
+ /* Create an empty list which is a buffer with 1 null in it */
+ /* Make sure those work the same as zeroed out data_strings */
+ buffer_allocate (&empty.buffer, 1, MDL);
+ empty.len = 1;
+ empty.data = empty.buffer->data;
+
+ /* Permutate with empty list */
+ concat_lists("empty + empty", &empty, &empty, "", 1);
+ concat_lists("empty + nonempty", &empty, &nonempty, data, sizeof(data));
+ concat_lists("nonempty + empty", &nonempty, &empty, data, sizeof(data));
+
+ /* Permutate with list len of 0 */
+ empty.len = 0;
+ concat_lists("zero-len + zero-len", &empty, &empty, "", 1);
+ concat_lists("zero-len + nonempty", &empty, &nonempty, data, sizeof(data));
+ concat_lists("nonempty + zero-len", &nonempty, &empty, data, sizeof(data));
+
+ /* Lastly, make sure two non-empty lists concat correctly */
+ concat_lists("nonempty + nonempty", &nonempty, &nonempty,
+ data2, sizeof(data2));
+
+ data_string_forget(&empty, MDL);
+ data_string_forget(&nonempty, MDL);
+}
+
+/* Helper function which tests concatenating two compressed lists
+*
+* \param label text to print in error message
+* \param list1 data_string containing first list
+* \param list2 data_string containing second list
+* \param refbuf buffer containing the expected concatentated data
+* \param reflen length of the expected data
+*/
+void concat_lists (const char* label, struct data_string* list1,
+ struct data_string* list2, const char *refbuf, size_t reflen)
+{
+ struct data_string result;
+ int rc;
+
+ memset (&result, 0x00, sizeof(struct data_string));
+ rc = concat_dclists (&result, list1, list2);
+ ATF_REQUIRE_MSG((rc >= 0), "%s concat_dclists call failed %d",
+ label, rc);
+
+ ATF_REQUIRE_MSG(result.len == reflen, "%s result len: %d incorrect",
+ label, result.len);
+
+ if (refbuf != NULL) {
+ ATF_REQUIRE_MSG((memcmp(result.data, refbuf, reflen) == 0),
+ "%s content is incorrect", label);
+ }
+
+ data_string_forget(&result, MDL);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, MRns_name_list_funcs);
+ ATF_TP_ADD_TC(tp, concat_dclists);
return (atf_no_error());
}
diff --git a/common/tree.c b/common/tree.c
index 03089b21..3e244994 100644
--- a/common/tree.c
+++ b/common/tree.c
@@ -4175,7 +4175,7 @@ int concat_dclists (struct data_string* result,
int i;
/* If not empty, uncompress first list into the uncompressed buffer */
- if ((list1->data) && (list1->len)) {
+ if (list1 && (list1->data) && (list1->len)) {
list_len = MRns_name_uncompress_list(list1->data,
list1->len, uncomp,
sizeof(uncompbuf));
@@ -4190,7 +4190,7 @@ int concat_dclists (struct data_string* result,
}
/* If not empty, uncompress second list into the uncompressed buffer */
- if ((list2->data) && (list2->len)) {
+ if (list2 && (list2->data) && (list2->len)) {
/* If first list wasn't empty, add a comma */
if (uncomp_len > 0) {
*uncomp++ = ',';