summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTomek Mrugalski <tomasz@isc.org>2012-08-14 16:52:39 +0200
committerTomek Mrugalski <tomasz@isc.org>2012-08-14 16:52:39 +0200
commit0a41861a4649698b71933dd921e186c2cc7de2c4 (patch)
tree5e6f1540d175702c82295eebe38f4ac5382f9d0a /common
parent818bc75a90885a7f0598daac9d09ecd6002d1f2b (diff)
downloadisc-dhcp-0a41861a4649698b71933dd921e186c2cc7de2c4.tar.gz
[v4_2] ATF unit-test support added (rt25901_atf merge)
Diffstat (limited to 'common')
-rw-r--r--common/Makefile.am6
-rw-r--r--common/Makefile.in9
-rw-r--r--common/tests/Atffile5
-rw-r--r--common/tests/Makefile.am21
-rw-r--r--common/tests/Makefile.in312
-rw-r--r--common/tests/test_alloc.c824
6 files changed, 587 insertions, 590 deletions
diff --git a/common/Makefile.am b/common/Makefile.am
index e4d4f9c8..eddef058 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -10,4 +10,8 @@ libdhcp_a_SOURCES = alloc.c bpf.c comapi.c conflex.c ctrace.c discover.c \
man_MANS = dhcp-eval.5 dhcp-options.5
EXTRA_DIST = $(man_MANS)
-SUBDIRS = tests
+# We want to build this directory first, before descending into tests subdir.
+# The reason is that ideally the tests should link existing objects from this
+# directory. That eliminates any discrepancies between tested code and
+# production code. Sadly, we are not there yet.
+SUBDIRS = . tests
diff --git a/common/Makefile.in b/common/Makefile.in
index 3c39008f..3f990a76 100644
--- a/common/Makefile.in
+++ b/common/Makefile.in
@@ -82,6 +82,8 @@ DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
+ATF_CFLAGS = @ATF_CFLAGS@
+ATF_LDFLAGS = @ATF_LDFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@@ -182,7 +184,12 @@ libdhcp_a_SOURCES = alloc.c bpf.c comapi.c conflex.c ctrace.c discover.c \
man_MANS = dhcp-eval.5 dhcp-options.5
EXTRA_DIST = $(man_MANS)
-SUBDIRS = tests
+
+# We want to build this directory first, before descending into tests subdir.
+# The reason is that ideally the tests should link existing objects from this
+# directory. That eliminates any discrepancies between tested code and
+# production code. Sadly, we are not there yet.
+SUBDIRS = . tests
all: all-recursive
.SUFFIXES:
diff --git a/common/tests/Atffile b/common/tests/Atffile
new file mode 100644
index 00000000..10402ce7
--- /dev/null
+++ b/common/tests/Atffile
@@ -0,0 +1,5 @@
+Content-Type: application/X-atf-atffile; version="1"
+
+prop: test-suite = dhcp4
+
+tp-glob: *_unittest
diff --git a/common/tests/Makefile.am b/common/tests/Makefile.am
index 70eb50ad..85808271 100644
--- a/common/tests/Makefile.am
+++ b/common/tests/Makefile.am
@@ -1,11 +1,22 @@
-AM_CPPFLAGS = -I../..
+SUBDIRS = .
-check_PROGRAMS = test_alloc
+AM_CPPFLAGS = $(ATF_CFLAGS) -std=c99 -I$(top_srcdir)/includes
-TESTS = test_alloc
+ATF_TESTS =
-test_alloc_SOURCES = test_alloc.c
-test_alloc_LDADD = ../libdhcp.a ../../tests/libt_api.a \
+if HAVE_ATF
+
+ATF_TESTS += alloc_unittest
+
+alloc_unittest_SOURCES = test_alloc.c $(top_srcdir)/tests/t_api_dhcp.c
+alloc_unittest_LDADD = $(ATF_LDFLAGS)
+alloc_unittest_LDADD += ../libdhcp.a \
../../omapip/libomapi.a ../../bind/lib/libdns.a \
../../bind/lib/libisc.a
+check: $(ATF_TESTS)
+ atf-run | atf-report
+
+endif
+
+check_PROGRAMS = $(ATF_TESTS)
diff --git a/common/tests/Makefile.in b/common/tests/Makefile.in
index 43a477ef..78cadfc7 100644
--- a/common/tests/Makefile.in
+++ b/common/tests/Makefile.in
@@ -29,8 +29,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
-check_PROGRAMS = test_alloc$(EXEEXT)
-TESTS = test_alloc$(EXEEXT)
+@HAVE_ATF_TRUE@am__append_1 = alloc_unittest
+check_PROGRAMS = $(am__EXEEXT_2)
subdir = common/tests
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -40,11 +40,17 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/includes/config.h
CONFIG_CLEAN_FILES =
-am_test_alloc_OBJECTS = test_alloc.$(OBJEXT)
-test_alloc_OBJECTS = $(am_test_alloc_OBJECTS)
-test_alloc_DEPENDENCIES = ../libdhcp.a ../../tests/libt_api.a \
- ../../omapip/libomapi.a ../../bind/lib/libdns.a \
- ../../bind/lib/libisc.a
+@HAVE_ATF_TRUE@am__EXEEXT_1 = alloc_unittest$(EXEEXT)
+am__EXEEXT_2 = $(am__EXEEXT_1)
+am__alloc_unittest_SOURCES_DIST = test_alloc.c \
+ $(top_srcdir)/tests/t_api_dhcp.c
+@HAVE_ATF_TRUE@am_alloc_unittest_OBJECTS = test_alloc.$(OBJEXT) \
+@HAVE_ATF_TRUE@ t_api_dhcp.$(OBJEXT)
+alloc_unittest_OBJECTS = $(am_alloc_unittest_OBJECTS)
+am__DEPENDENCIES_1 =
+@HAVE_ATF_TRUE@alloc_unittest_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+@HAVE_ATF_TRUE@ ../libdhcp.a ../../omapip/libomapi.a \
+@HAVE_ATF_TRUE@ ../../bind/lib/libdns.a ../../bind/lib/libisc.a
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/includes
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -52,13 +58,25 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(test_alloc_SOURCES)
-DIST_SOURCES = $(test_alloc_SOURCES)
+SOURCES = $(alloc_unittest_SOURCES)
+DIST_SOURCES = $(am__alloc_unittest_SOURCES_DIST)
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
ETAGS = etags
CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
+ATF_CFLAGS = @ATF_CFLAGS@
+ATF_LDFLAGS = @ATF_LDFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@@ -148,13 +166,14 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-AM_CPPFLAGS = -I../..
-test_alloc_SOURCES = test_alloc.c
-test_alloc_LDADD = ../libdhcp.a ../../tests/libt_api.a \
- ../../omapip/libomapi.a ../../bind/lib/libdns.a \
- ../../bind/lib/libisc.a
-
-all: all-am
+SUBDIRS = .
+AM_CPPFLAGS = $(ATF_CFLAGS) -std=c99 -I$(top_srcdir)/includes
+ATF_TESTS = $(am__append_1)
+@HAVE_ATF_TRUE@alloc_unittest_SOURCES = test_alloc.c $(top_srcdir)/tests/t_api_dhcp.c
+@HAVE_ATF_TRUE@alloc_unittest_LDADD = $(ATF_LDFLAGS) ../libdhcp.a \
+@HAVE_ATF_TRUE@ ../../omapip/libomapi.a ../../bind/lib/libdns.a \
+@HAVE_ATF_TRUE@ ../../bind/lib/libisc.a
+all: all-recursive
.SUFFIXES:
.SUFFIXES: .c .o .obj
@@ -190,9 +209,9 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
clean-checkPROGRAMS:
-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
-test_alloc$(EXEEXT): $(test_alloc_OBJECTS) $(test_alloc_DEPENDENCIES)
- @rm -f test_alloc$(EXEEXT)
- $(LINK) $(test_alloc_OBJECTS) $(test_alloc_LDADD) $(LIBS)
+alloc_unittest$(EXEEXT): $(alloc_unittest_OBJECTS) $(alloc_unittest_DEPENDENCIES)
+ @rm -f alloc_unittest$(EXEEXT)
+ $(LINK) $(alloc_unittest_OBJECTS) $(alloc_unittest_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -200,6 +219,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@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@
.c.o:
@@ -216,6 +236,90 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+t_api_dhcp.o: $(top_srcdir)/tests/t_api_dhcp.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT t_api_dhcp.o -MD -MP -MF $(DEPDIR)/t_api_dhcp.Tpo -c -o t_api_dhcp.o `test -f '$(top_srcdir)/tests/t_api_dhcp.c' || echo '$(srcdir)/'`$(top_srcdir)/tests/t_api_dhcp.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/t_api_dhcp.Tpo $(DEPDIR)/t_api_dhcp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/tests/t_api_dhcp.c' object='t_api_dhcp.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o t_api_dhcp.o `test -f '$(top_srcdir)/tests/t_api_dhcp.c' || echo '$(srcdir)/'`$(top_srcdir)/tests/t_api_dhcp.c
+
+t_api_dhcp.obj: $(top_srcdir)/tests/t_api_dhcp.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT t_api_dhcp.obj -MD -MP -MF $(DEPDIR)/t_api_dhcp.Tpo -c -o t_api_dhcp.obj `if test -f '$(top_srcdir)/tests/t_api_dhcp.c'; then $(CYGPATH_W) '$(top_srcdir)/tests/t_api_dhcp.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/tests/t_api_dhcp.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/t_api_dhcp.Tpo $(DEPDIR)/t_api_dhcp.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/tests/t_api_dhcp.c' object='t_api_dhcp.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o t_api_dhcp.obj `if test -f '$(top_srcdir)/tests/t_api_dhcp.c'; then $(CYGPATH_W) '$(top_srcdir)/tests/t_api_dhcp.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/tests/t_api_dhcp.c'; fi`
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
@@ -226,10 +330,23 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
mkid -fID $$unique
tags: TAGS
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
@@ -242,7 +359,7 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$$tags $$unique; \
fi
ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
@@ -263,79 +380,6 @@ GTAGS:
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-check-TESTS: $(TESTS)
- @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \
- srcdir=$(srcdir); export srcdir; \
- list=' $(TESTS) '; \
- if test -n "$$list"; then \
- for tst in $$list; do \
- if test -f ./$$tst; then dir=./; \
- elif test -f $$tst; then dir=; \
- else dir="$(srcdir)/"; fi; \
- if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
- all=`expr $$all + 1`; \
- case " $(XFAIL_TESTS) " in \
- *$$ws$$tst$$ws*) \
- xpass=`expr $$xpass + 1`; \
- failed=`expr $$failed + 1`; \
- echo "XPASS: $$tst"; \
- ;; \
- *) \
- echo "PASS: $$tst"; \
- ;; \
- esac; \
- elif test $$? -ne 77; then \
- all=`expr $$all + 1`; \
- case " $(XFAIL_TESTS) " in \
- *$$ws$$tst$$ws*) \
- xfail=`expr $$xfail + 1`; \
- echo "XFAIL: $$tst"; \
- ;; \
- *) \
- failed=`expr $$failed + 1`; \
- echo "FAIL: $$tst"; \
- ;; \
- esac; \
- else \
- skip=`expr $$skip + 1`; \
- echo "SKIP: $$tst"; \
- fi; \
- done; \
- if test "$$failed" -eq 0; then \
- if test "$$xfail" -eq 0; then \
- banner="All $$all tests passed"; \
- else \
- banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
- fi; \
- else \
- if test "$$xpass" -eq 0; then \
- banner="$$failed of $$all tests failed"; \
- else \
- banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
- fi; \
- fi; \
- dashes="$$banner"; \
- skipped=""; \
- if test "$$skip" -ne 0; then \
- skipped="($$skip tests were not run)"; \
- test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
- dashes="$$skipped"; \
- fi; \
- report=""; \
- if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
- report="Please report to $(PACKAGE_BUGREPORT)"; \
- test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
- dashes="$$report"; \
- fi; \
- dashes=`echo "$$dashes" | sed s/./=/g`; \
- echo "$$dashes"; \
- echo "$$banner"; \
- test -z "$$skipped" || echo "$$skipped"; \
- test -z "$$report" || echo "$$report"; \
- echo "$$dashes"; \
- test "$$failed" -eq 0; \
- else :; fi
-
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -362,21 +406,38 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
+ list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ distdir=`$(am__cd) $(distdir) && pwd`; \
+ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
+ (cd $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$top_distdir" \
+ distdir="$$distdir/$$subdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
- $(MAKE) $(AM_MAKEFLAGS) check-TESTS
-check: check-am
+check: check-recursive
all-am: Makefile
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-installcheck: installcheck-am
+installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
@@ -392,78 +453,83 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
+clean: clean-recursive
clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am
-distclean: distclean-am
+distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
-dvi: dvi-am
+dvi: dvi-recursive
dvi-am:
-html: html-am
+html: html-recursive
-info: info-am
+info: info-recursive
info-am:
install-data-am:
-install-dvi: install-dvi-am
+install-dvi: install-dvi-recursive
install-exec-am:
-install-html: install-html-am
+install-html: install-html-recursive
-install-info: install-info-am
+install-info: install-info-recursive
install-man:
-install-pdf: install-pdf-am
+install-pdf: install-pdf-recursive
-install-ps: install-ps-am
+install-ps: install-ps-recursive
installcheck-am:
-maintainer-clean: maintainer-clean-am
+maintainer-clean: maintainer-clean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
-mostlyclean: mostlyclean-am
+mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic
-pdf: pdf-am
+pdf: pdf-recursive
pdf-am:
-ps: ps-am
+ps: ps-recursive
ps-am:
uninstall-am:
-.MAKE: install-am install-strip
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+ install-strip
-.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
- clean-checkPROGRAMS clean-generic ctags distclean \
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+ all all-am check check-am clean clean-checkPROGRAMS \
+ clean-generic ctags ctags-recursive distclean \
distclean-compile distclean-generic distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
- installcheck installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-compile \
- mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
- uninstall-am
+ installcheck installcheck-am installdirs installdirs-am \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+ tags tags-recursive uninstall uninstall-am
+
+@HAVE_ATF_TRUE@check: $(ATF_TESTS)
+@HAVE_ATF_TRUE@ atf-run | atf-report
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/common/tests/test_alloc.c b/common/tests/test_alloc.c
index c0e1b9af..d941c8fb 100644
--- a/common/tests/test_alloc.c
+++ b/common/tests/test_alloc.c
@@ -1,5 +1,7 @@
/*
- * We test the functions provided in alloc.c here. These are very
+ * Copyright (c) 2007,2009,2012 by Internet Systems Consortium, Inc. ("ISC")
+ *
+ * We test the functions provided in alloc.c here. These are very
* basic functions, and it is very important that they work correctly.
*
* You can see two different styles of testing:
@@ -16,482 +18,384 @@
* tests, and less duplicated and extra code. The advantage of having
* a separate test is that each test is simpler. Plus if you need to
* allow certain tests to fail for some reason (known bugs that are
- * hard to fix for example), then
+ * hard to fix for example), then
*/
-/* TODO: dmalloc() test */
+/** @TODO: dmalloc() test */
#include "config.h"
-#include "t_api.h"
-
+#include <atf-c.h>
#include "dhcpd.h"
-static void test_buffer_allocate(void);
-static void test_buffer_reference(void);
-static void test_buffer_dereference(void);
-static void test_data_string_forget(void);
-static void test_data_string_forget_nobuf(void);
-static void test_data_string_copy(void);
-static void test_data_string_copy_nobuf(void);
+ATF_TC(buffer_allocate);
-/*
- * T_testlist is a list of tests that are invoked.
- */
-testspec_t T_testlist[] = {
- { test_buffer_allocate,
- "buffer_allocate()" },
- { test_buffer_reference,
- "buffer_reference()" },
- { test_buffer_dereference,
- "buffer_dereference()" },
- { test_data_string_forget,
- "data_string_forget()" },
- { test_data_string_forget_nobuf,
- "data_string_forget(), no buffer" },
- { test_data_string_copy,
- "data_string_copy()" },
- { test_data_string_copy_nobuf,
- "data_string_copy(), no buffer" },
- { NULL, NULL }
-};
-
-static void
-test_buffer_allocate(void) {
- static const char *test_desc =
- "buffer_allocate basic test";
-
- struct buffer *buf;
-
- t_assert("buffer_allocate", 1, T_REQUIRED, "%s", test_desc);
-
- /*
- * Check a 0-length buffer.
- */
- buf = NULL;
- if (!buffer_allocate(&buf, 0, MDL)) {
- t_info("failed on 0-len buffer\n");
- t_result(T_FAIL);
- return;
- }
- if (!buffer_dereference(&buf, MDL)) {
- t_info("buffer_dereference() failed\n");
- t_result(T_FAIL);
- return;
- }
- if (buf != NULL) {
- t_info("buffer_dereference() did not NULL-out buffer\n");
- t_result(T_FAIL);
- return;
- }
-
- /*
- * Check an actual buffer.
- */
- buf = NULL;
- if (!buffer_allocate(&buf, 100, MDL)) {
- t_info("failed on allocate\n");
- t_result(T_FAIL);
- return;
- }
- if (!buffer_dereference(&buf, MDL)) {
- t_info("buffer_dereference() failed\n");
- t_result(T_FAIL);
- return;
- }
- if (buf != NULL) {
- t_info("buffer_dereference() did not NULL-out buffer\n");
- t_result(T_FAIL);
- return;
- }
-
- /*
- * Okay, we're happy.
- */
- t_result(T_PASS);
+ATF_TC_HEAD(buffer_allocate, tc) {
+ atf_tc_set_md_var(tc, "descr", "buffer_allocate basic test");
}
-static void
-test_buffer_reference(void) {
- static const char *test_desc =
- "buffer_reference basic test";
- int result = T_PASS;
-
- struct buffer *a, *b;
-
- t_assert("buffer_reference", 1, T_REQUIRED, "%s", test_desc);
-
- /*
- * Create a buffer.
- */
- a = NULL;
- if (!buffer_allocate(&a, 100, MDL)) {
- t_info("failed on allocate\n");
- t_result(T_FAIL);
- return;
- }
-
- /*
- * Confirm buffer_reference() doesn't work if we pass in NULL.
- *
- * TODO: we should confirm we get an error message here.
- */
- if (buffer_reference(NULL, a, MDL)) {
- t_info("succeeded on an error input\n");
- t_result(T_FAIL);
- return;
- }
-
- /*
- * TODO: we should confirm we get an error message if we pass
- * a non-NULL target.
- */
-
- /*
- * Confirm we work under normal circumstances.
- */
- b = NULL;
- if (!buffer_reference(&b, a, MDL)) {
- t_info("buffer_reference() failed\n");
- t_result(T_FAIL);
- return;
- }
-
- if (b != a) {
- t_info("incorrect pointer\n");
- result = T_FAIL;
- }
- if (b->refcnt != 2) {
- t_info("incorrect refcnt\n");
- result = T_FAIL;
- }
-
- /*
- * Clean up.
- */
- if (!buffer_dereference(&b, MDL)) {
- t_info("buffer_dereference() failed\n");
- t_result(T_FAIL);
- return;
- }
- if (!buffer_dereference(&a, MDL)) {
- t_info("buffer_dereference() failed\n");
- t_result(T_FAIL);
- return;
- }
-
- t_result(result);
+ATF_TC_BODY(buffer_allocate, tc) {
+ struct buffer *buf = 0;
+
+ /*
+ * Check a 0-length buffer.
+ */
+ buf = NULL;
+ if (!buffer_allocate(&buf, 0, MDL)) {
+ atf_tc_fail("failed on 0-len buffer");
+ }
+ if (!buffer_dereference(&buf, MDL)) {
+ atf_tc_fail("buffer_dereference() failed");
+ }
+ if (buf != NULL) {
+ atf_tc_fail("buffer_dereference() did not NULL-out buffer");
+ }
+
+ /*
+ * Check an actual buffer.
+ */
+ buf = NULL;
+ if (!buffer_allocate(&buf, 100, MDL)) {
+ atf_tc_fail("failed on allocate 100 bytes\n");
+ }
+ if (!buffer_dereference(&buf, MDL)) {
+ atf_tc_fail("buffer_dereference() failed");
+ }
+ if (buf != NULL) {
+ atf_tc_fail("buffer_dereference() did not NULL-out buffer");
+ }
+
+ /*
+ * Okay, we're happy.
+ */
+ atf_tc_pass();
}
-static void
-test_buffer_dereference(void) {
- static const char *test_desc =
- "buffer_dereference basic test";
-
- struct buffer *a, *b;
-
- t_assert("buffer_dereference", 1, T_REQUIRED, "%s", test_desc);
-
- /*
- * Confirm buffer_dereference() doesn't work if we pass in NULL.
- *
- * TODO: we should confirm we get an error message here.
- */
- if (buffer_dereference(NULL, MDL)) {
- t_info("succeeded on an error input\n");
- t_result(T_FAIL);
- return;
- }
-
- /*
- * Confirm buffer_dereference() doesn't work if we pass in
- * a pointer to NULL.
- *
- * TODO: we should confirm we get an error message here.
- */
- a = NULL;
- if (buffer_dereference(&a, MDL)) {
- t_info("succeeded on an error input\n");
- t_result(T_FAIL);
- return;
- }
-
- /*
- * Confirm we work under normal circumstances.
- */
- a = NULL;
- if (!buffer_allocate(&a, 100, MDL)) {
- t_info("failed on allocate\n");
- t_result(T_FAIL);
- return;
- }
- if (!buffer_dereference(&a, MDL)) {
- t_info("buffer_dereference() failed\n");
- t_result(T_FAIL);
- return;
- }
- if (a != NULL) {
- t_info("non-null buffer after buffer_dereference()\n");
- t_result(T_FAIL);
- return;
- }
-
- /*
- * Confirm we get an error from negative refcnt.
- *
- * TODO: we should confirm we get an error message here.
- */
- a = NULL;
- if (!buffer_allocate(&a, 100, MDL)) {
- t_info("failed on allocate\n");
- t_result(T_FAIL);
- return;
- }
- b = NULL;
- if (!buffer_reference(&b, a, MDL)) {
- t_info("buffer_reference() failed\n");
- t_result(T_FAIL);
- return;
- }
- a->refcnt = 0; /* purposely set to invalid value */
- if (buffer_dereference(&a, MDL)) {
- t_info("buffer_dereference() succeeded on error input\n");
- t_result(T_FAIL);
- return;
- }
- a->refcnt = 2;
- if (!buffer_dereference(&b, MDL)) {
- t_info("buffer_dereference() failed\n");
- t_result(T_FAIL);
- return;
- }
- if (!buffer_dereference(&a, MDL)) {
- t_info("buffer_dereference() failed\n");
- t_result(T_FAIL);
- return;
- }
-
- t_result(T_PASS);
+ATF_TC(buffer_reference);
+
+ATF_TC_HEAD(buffer_reference, tc) {
+ atf_tc_set_md_var(tc, "descr", "buffer_reference basic test");
+}
+
+ATF_TC_BODY(buffer_reference, tc) {
+
+ struct buffer *a, *b;
+
+ /*
+ * Create a buffer.
+ */
+ a = NULL;
+ if (!buffer_allocate(&a, 100, MDL)) {
+ atf_tc_fail("failed on allocate 100 bytes");
+ }
+
+ /**
+ * Confirm buffer_reference() doesn't work if we pass in NULL.
+ *
+ * @TODO: we should confirm we get an error message here.
+ */
+ if (buffer_reference(NULL, a, MDL)) {
+ atf_tc_fail("succeeded on an error input");
+ }
+
+ /**
+ * @TODO: we should confirm we get an error message if we pass
+ * a non-NULL target.
+ */
+
+ /*
+ * Confirm we work under normal circumstances.
+ */
+ b = NULL;
+ if (!buffer_reference(&b, a, MDL)) {
+ atf_tc_fail("buffer_reference() failed");
+ }
+
+ if (b != a) {
+ atf_tc_fail("incorrect pointer returned");
+ }
+
+ if (b->refcnt != 2) {
+ atf_tc_fail("incorrect refcnt");
+ }
+
+ /*
+ * Clean up.
+ */
+ if (!buffer_dereference(&b, MDL)) {
+ atf_tc_fail("buffer_dereference() failed");
+ }
+ if (!buffer_dereference(&a, MDL)) {
+ atf_tc_fail("buffer_dereference() failed");
+ }
+
}
-static void
-test_data_string_forget(void) {
- static const char *test_desc =
- "data_string_forget basic test";
- int result = T_PASS;
-
- struct buffer *buf;
- struct data_string a;
- const char *str = "Lorem ipsum dolor sit amet turpis duis.";
-
- t_assert("data_string_forget", 1, T_REQUIRED, "%s", test_desc);
-
- /*
- * Create the string we want to forget.
- */
- memset(&a, 0, sizeof(a));
- a.len = strlen(str);
- buf = NULL;
- if (!buffer_allocate(&buf, a.len, MDL)) {
- t_info("out of memory\n");
- t_result(T_FAIL);
- return;
- }
- if (!buffer_reference(&a.buffer, buf, MDL)) {
- t_info("buffer_reference() failed\n");
- t_result(T_FAIL);
- return;
- }
- a.data = a.buffer->data;
- memcpy(a.buffer->data, str, a.len);
-
- /*
- * Forget and confirm we've forgotten.
- */
- data_string_forget(&a, MDL);
-
- if (a.len != 0) {
- t_info("incorrect length\n");
- result = T_FAIL;
- }
- if (a.data != NULL) {
- t_info("incorrect data\n");
- result = T_FAIL;
- }
- if (a.terminated) {
- t_info("incorrect terminated\n");
- result = T_FAIL;
- }
- if (a.buffer != NULL) {
- t_info("incorrect buffer\n");
- result = T_FAIL;
- }
- if (buf->refcnt != 1) {
- t_info("too many references to buf\n");
- result = T_FAIL;
- }
-
- /*
- * Clean up buffer.
- */
- if (!buffer_dereference(&buf, MDL)) {
- t_info("buffer_reference() failed\n");
- t_result(T_FAIL);
- return;
- }
-
- t_result(result);
+
+ATF_TC(buffer_dereference);
+
+ATF_TC_HEAD(buffer_dereference, tc) {
+ atf_tc_set_md_var(tc, "descr", "buffer_dereference basic test");
+}
+
+ATF_TC_BODY(buffer_dereference, tc) {
+ struct buffer *a, *b;
+
+ /**
+ * Confirm buffer_dereference() doesn't work if we pass in NULL.
+ *
+ * TODO: we should confirm we get an error message here.
+ */
+ if (buffer_dereference(NULL, MDL)) {
+ atf_tc_fail("succeeded on an error input");
+ }
+
+ /**
+ * Confirm buffer_dereference() doesn't work if we pass in
+ * a pointer to NULL.
+ *
+ * @TODO: we should confirm we get an error message here.
+ */
+ a = NULL;
+ if (buffer_dereference(&a, MDL)) {
+ atf_tc_fail("succeeded on an error input");
+ }
+
+ /*
+ * Confirm we work under normal circumstances.
+ */
+ a = NULL;
+ if (!buffer_allocate(&a, 100, MDL)) {
+ atf_tc_fail("failed on allocate");
+ }
+ if (!buffer_dereference(&a, MDL)) {
+ atf_tc_fail("buffer_dereference() failed");
+ }
+ if (a != NULL) {
+ atf_tc_fail("non-null buffer after buffer_dereference()");
+ }
+
+ /**
+ * Confirm we get an error from negative refcnt.
+ *
+ * @TODO: we should confirm we get an error message here.
+ */
+ a = NULL;
+ if (!buffer_allocate(&a, 100, MDL)) {
+ atf_tc_fail("failed on allocate");
+ }
+ b = NULL;
+ if (!buffer_reference(&b, a, MDL)) {
+ atf_tc_fail("buffer_reference() failed");
+ }
+ a->refcnt = 0; /* purposely set to invalid value */
+ if (buffer_dereference(&a, MDL)) {
+ atf_tc_fail("buffer_dereference() succeeded on error input");
+ }
+ a->refcnt = 2;
+ if (!buffer_dereference(&b, MDL)) {
+ atf_tc_fail("buffer_dereference() failed");
+ }
+ if (!buffer_dereference(&a, MDL)) {
+ atf_tc_fail("buffer_dereference() failed");
+ }
+}
+
+ATF_TC(data_string_forget);
+
+ATF_TC_HEAD(data_string_forget, tc) {
+ atf_tc_set_md_var(tc, "descr", "data_string_forget basic test");
}
-static void
-test_data_string_forget_nobuf(void) {
- static const char *test_desc =
- "data_string_forget test, data_string without buffer";
- int result = T_PASS;
-
- struct data_string a;
- const char *str = "Lorem ipsum dolor sit amet massa nunc.";
-
- t_assert("data_string_forget, no buffer", 1, T_REQUIRED, "%s", test_desc);
-
- /*
- * Create the string we want to forget.
- */
- memset(&a, 0, sizeof(a));
- a.len = strlen(str);
- a.data = (const unsigned char *)str;
- a.terminated = 1;
-
- /*
- * Forget and confirm we've forgotten.
- */
- data_string_forget(&a, MDL);
-
- if (a.len != 0) {
- t_info("incorrect length\n");
- result = T_FAIL;
- }
- if (a.data != NULL) {
- t_info("incorrect data\n");
- result = T_FAIL;
- }
- if (a.terminated) {
- t_info("incorrect terminated\n");
- result = T_FAIL;
- }
- if (a.buffer != NULL) {
- t_info("incorrect buffer\n");
- result = T_FAIL;
- }
-
- t_result(result);
+ATF_TC_BODY(data_string_forget, tc) {
+ struct buffer *buf;
+ struct data_string a;
+ const char *str = "Lorem ipsum dolor sit amet turpis duis.";
+
+ /*
+ * Create the string we want to forget.
+ */
+ memset(&a, 0, sizeof(a));
+ a.len = strlen(str);
+ buf = NULL;
+ if (!buffer_allocate(&buf, a.len, MDL)) {
+ atf_tc_fail("out of memory");
+ }
+ if (!buffer_reference(&a.buffer, buf, MDL)) {
+ atf_tc_fail("buffer_reference() failed");
+ }
+ a.data = a.buffer->data;
+ memcpy(a.buffer->data, str, a.len);
+
+ /*
+ * Forget and confirm we've forgotten.
+ */
+ data_string_forget(&a, MDL);
+
+ if (a.len != 0) {
+ atf_tc_fail("incorrect length");
+ }
+
+ if (a.data != NULL) {
+ atf_tc_fail("incorrect data");
+ }
+ if (a.terminated) {
+ atf_tc_fail("incorrect terminated");
+ }
+ if (a.buffer != NULL) {
+ atf_tc_fail("incorrect buffer");
+ }
+ if (buf->refcnt != 1) {
+ atf_tc_fail("too many references to buf");
+ }
+
+ /*
+ * Clean up buffer.
+ */
+ if (!buffer_dereference(&buf, MDL)) {
+ atf_tc_fail("buffer_reference() failed");
+ }
}
-static void
-test_data_string_copy(void) {
- static const char *test_desc =
- "data_string_copy basic test";
- int result = T_PASS;
-
- struct data_string a, b;
- const char *str = "Lorem ipsum dolor sit amet orci aliquam.";
-
- t_assert("data_string_copy", 1, T_REQUIRED, "%s", test_desc);
-
-
- /*
- * Create the string we want to copy.
- */
- memset(&a, 0, sizeof(a));
- a.len = strlen(str);
- if (!buffer_allocate(&a.buffer, a.len, MDL)) {
- t_info("out of memory\n");
- t_result(T_FAIL);
- return;
- }
- a.data = a.buffer->data;
- memcpy(a.buffer->data, str, a.len);
-
- /*
- * Copy the string, and confirm it works.
- */
- memset(&b, 0, sizeof(b));
- data_string_copy(&b, &a, MDL);
-
- if (b.len != a.len) {
- t_info("incorrect length\n");
- result = T_FAIL;
- }
- if (b.data != a.data) {
- t_info("incorrect data\n");
- result = T_FAIL;
- }
- if (b.terminated != a.terminated) {
- t_info("incorrect terminated\n");
- result = T_FAIL;
- }
- if (b.buffer != a.buffer) {
- t_info("incorrect buffer\n");
- result = T_FAIL;
- }
-
- /*
- * Clean up.
- */
- data_string_forget(&b, MDL);
- data_string_forget(&a, MDL);
-
- t_result(result);
+ATF_TC(data_string_forget_nobuf);
+
+ATF_TC_HEAD(data_string_forget_nobuf, tc) {
+ atf_tc_set_md_var(tc, "descr", "data_string_forget test, "
+ "data_string without buffer");
+}
+
+ATF_TC_BODY(data_string_forget_nobuf, tc) {
+ struct data_string a;
+ const char *str = "Lorem ipsum dolor sit amet massa nunc.";
+
+ /*
+ * Create the string we want to forget.
+ */
+ memset(&a, 0, sizeof(a));
+ a.len = strlen(str);
+ a.data = (const unsigned char *)str;
+ a.terminated = 1;
+
+ /*
+ * Forget and confirm we've forgotten.
+ */
+ data_string_forget(&a, MDL);
+
+ if (a.len != 0) {
+ atf_tc_fail("incorrect length");
+ }
+ if (a.data != NULL) {
+ atf_tc_fail("incorrect data");
+ }
+ if (a.terminated) {
+ atf_tc_fail("incorrect terminated");
+ }
+ if (a.buffer != NULL) {
+ atf_tc_fail("incorrect buffer");
+ }
+}
+
+ATF_TC(data_string_copy);
+
+ATF_TC_HEAD(data_string_copy, tc) {
+ atf_tc_set_md_var(tc, "descr", "data_string_copy basic test");
+}
+
+ATF_TC_BODY(data_string_copy, tc) {
+ struct data_string a, b;
+ const char *str = "Lorem ipsum dolor sit amet orci aliquam.";
+
+ /*
+ * Create the string we want to copy.
+ */
+ memset(&a, 0, sizeof(a));
+ a.len = strlen(str);
+ if (!buffer_allocate(&a.buffer, a.len, MDL)) {
+ atf_tc_fail("out of memory");
+ }
+ a.data = a.buffer->data;
+ memcpy(a.buffer->data, str, a.len);
+
+ /*
+ * Copy the string, and confirm it works.
+ */
+ memset(&b, 0, sizeof(b));
+ data_string_copy(&b, &a, MDL);
+
+ if (b.len != a.len) {
+ atf_tc_fail("incorrect length");
+ }
+ if (b.data != a.data) {
+ atf_tc_fail("incorrect data");
+ }
+ if (b.terminated != a.terminated) {
+ atf_tc_fail("incorrect terminated");
+ }
+ if (b.buffer != a.buffer) {
+ atf_tc_fail("incorrect buffer");
+ }
+
+ /*
+ * Clean up.
+ */
+ data_string_forget(&b, MDL);
+ data_string_forget(&a, MDL);
+}
+
+ATF_TC(data_string_copy_nobuf);
+
+ATF_TC_HEAD(data_string_copy_nobuf, tc) {
+ atf_tc_set_md_var(tc, "descr", "data_string_copy test, "
+ "data_string without buffer");
+}
+
+ATF_TC_BODY(data_string_copy_nobuf, tc) {
+ struct data_string a, b;
+ const char *str = "Lorem ipsum dolor sit amet cras amet.";
+
+ /*
+ * Create the string we want to copy.
+ */
+ memset(&a, 0, sizeof(a));
+ a.len = strlen(str);
+ a.data = (const unsigned char *)str;
+ a.terminated = 1;
+
+ /*
+ * Copy the string, and confirm it works.
+ */
+ memset(&b, 0, sizeof(b));
+ data_string_copy(&b, &a, MDL);
+
+ if (b.len != a.len) {
+ atf_tc_fail("incorrect length");
+ }
+ if (b.data != a.data) {
+ atf_tc_fail("incorrect data");
+ }
+ if (b.terminated != a.terminated) {
+ atf_tc_fail("incorrect terminated");
+ }
+ if (b.buffer != a.buffer) {
+ atf_tc_fail("incorrect buffer");
+ }
+
+ /*
+ * Clean up.
+ */
+ data_string_forget(&b, MDL);
+ data_string_forget(&a, MDL);
+
}
-static void
-test_data_string_copy_nobuf(void) {
- static const char *test_desc =
- "data_string_copy test, data_string without buffer";
- int result = T_PASS;
-
- struct data_string a, b;
- const char *str = "Lorem ipsum dolor sit amet cras amet.";
-
- t_assert("data_string_copy, no buffer", 1, T_REQUIRED, "%s",
- test_desc);
-
-
- /*
- * Create the string we want to copy.
- */
- memset(&a, 0, sizeof(a));
- a.len = strlen(str);
- a.data = (const unsigned char *)str;
- a.terminated = 1;
-
- /*
- * Copy the string, and confirm it works.
- */
- memset(&b, 0, sizeof(b));
- data_string_copy(&b, &a, MDL);
-
- if (b.len != a.len) {
- t_info("incorrect length\n");
- result = T_FAIL;
- }
- if (b.data != a.data) {
- t_info("incorrect data\n");
- result = T_FAIL;
- }
- if (b.terminated != a.terminated) {
- t_info("incorrect terminated\n");
- result = T_FAIL;
- }
- if (b.buffer != a.buffer) {
- t_info("incorrect buffer\n");
- result = T_FAIL;
- }
-
- /*
- * Clean up.
- */
- data_string_forget(&b, MDL);
- data_string_forget(&a, MDL);
-
- t_result(result);
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, buffer_allocate);
+ ATF_TP_ADD_TC(tp, buffer_reference);
+ ATF_TP_ADD_TC(tp, buffer_dereference);
+ ATF_TP_ADD_TC(tp, data_string_forget);
+ ATF_TP_ADD_TC(tp, data_string_forget_nobuf);
+ ATF_TP_ADD_TC(tp, data_string_copy);
+ ATF_TP_ADD_TC(tp, data_string_copy_nobuf);
+
+ return (atf_no_error());
}