diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.in | 1 | ||||
-rw-r--r-- | RELNOTES | 95 | ||||
-rw-r--r-- | aclocal.m4 | 37 | ||||
-rw-r--r-- | client/Makefile.in | 1 | ||||
-rw-r--r-- | client/tests/Makefile.am | 9 | ||||
-rw-r--r-- | client/tests/Makefile.in | 397 | ||||
-rw-r--r-- | common/Makefile.in | 1 | ||||
-rw-r--r-- | common/tests/Makefile.am | 2 | ||||
-rw-r--r-- | common/tests/Makefile.in | 3 | ||||
-rwxr-xr-x | configure | 30 | ||||
-rw-r--r-- | configure.ac | 20 | ||||
-rw-r--r-- | dhcpctl/Makefile.in | 1 | ||||
-rw-r--r-- | doc/devel/atf.dox | 26 | ||||
-rw-r--r-- | dst/Makefile.in | 1 | ||||
-rw-r--r-- | includes/Makefile.in | 1 | ||||
-rw-r--r-- | includes/config.h.in | 3 | ||||
-rw-r--r-- | omapip/Makefile.in | 1 | ||||
-rw-r--r-- | relay/Makefile.in | 1 | ||||
-rw-r--r-- | server/Makefile.in | 1 | ||||
-rw-r--r-- | server/tests/Makefile.am | 10 | ||||
-rw-r--r-- | server/tests/Makefile.in | 397 | ||||
-rw-r--r-- | tests/HOWTO-unit-test | 48 | ||||
-rw-r--r-- | tests/Makefile.in | 7 | ||||
-rwxr-xr-x | tests/unittest.sh.in | 79 |
25 files changed, 337 insertions, 836 deletions
@@ -28,3 +28,4 @@ server/tests/legacy_unittests server/tests/load_bal_unittests server/tests/test-suite.log tests/libt_api.a +tests/unittest.sh diff --git a/Makefile.in b/Makefile.in index 78cd1e20..b273fc17 100644 --- a/Makefile.in +++ b/Makefile.in @@ -224,6 +224,7 @@ distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ @@ -60,6 +60,21 @@ by Eric Young (eay@cryptsoft.com). the issue. [ISC-Bugs #37780] +- Unit test execution now uses a path augmented during configuration + processing of the --with-atf option to locate ATF runtime tools, atf-run + and atf-report. For most installations of ATF, this should alleviate the + need to manually include them in the PATH, as was formerly required. + If the configure script cannot locate the tools it will emit a warning, + informing the user that the tools must be in the PATH when running unit + tests. + Secondly, please note that "make check" will now exit with a failure status + code (non-zero) if one or more unit tests fail. This means that invoking + "make check" from an upper level directory will cause the make process to + STOP after the first test subdirectory with failed test(s). To force all + tests in all subdirectories to run, regardless of individual test outcome, + use the command "make -k check". + [ISC-Bugs #38619] + Changes since 4.3.1 - Corrected parser's right brace matching when a statement contains an error. @@ -281,7 +296,7 @@ by Eric Young (eay@cryptsoft.com). - Tidy up several small tickets. Correct parsing of DUID from config file, previously the LL type was put in the wrong place in the DUID string. - [ISC-Bugs #20962] + [ISC-Bugs #20962] Add code to parse "do-forward-updates" as well as "do-forward-update" Thanks to Jiri Popelka at Red Hat. [ISC-Bugs #31328] @@ -655,7 +670,7 @@ by Eric Young (eay@cryptsoft.com). in dhcpd - based on a patch from David Cantrell at Red Hat. [ISC-Bugs #20039] Correct some error messages in dhcpd.c [ISC-Bugs #20070] Better range check on values when creating a DHCID. - [ISC-Bugs #20198] Avoid writing past the end of the field when adding + [ISC-Bugs #20198] Avoid writing past the end of the field when adding overly long file or server names to a packet and add a log message if the configuration supplied overly long names for these fields. Thanks to Martin Pala. @@ -732,7 +747,7 @@ by Eric Young (eay@cryptsoft.com). listed as a failover peer would cause the server to become non-responsive. Thanks to a report from Brad Bendily, brad@bendily.com. [ISC-Bugs #22679] - CERT: VU#159528 CVE: CVE-2010-3616 + CERT: VU#159528 CVE: CVE-2010-3616 - Don't pass the ISC_R_INPROGRESS status to the omapi signal handlers. Passing it through to the handlers caused the omshell program to fail @@ -764,7 +779,7 @@ by Eric Young (eay@cryptsoft.com). crashing on an assert failure. Also retag the lease as active and reset its timeout value. [ISC-Bugs #21921] - + - Removed the restriction on using IPv6 addresses in IPv4 mode. This allows IPv4 options which contain IPv6 addresses to be specified. For example the 6rd option can be specified and used like this: @@ -776,7 +791,7 @@ by Eric Young (eay@cryptsoft.com). - Handle some DDNS corner cases better. Maintain the DDNS transaction information when updating a lease and cancel any existing transactions - when removing the ddns information. + when removing the ddns information. [ISC-Bugs #23103] - Some fixes for LDAP @@ -806,12 +821,12 @@ by Eric Young (eay@cryptsoft.com). - 'dhclient' no longer waits a random interval after first starting up to begin in the INIT state. This conforms to RFC 2131, but elects not to - implement a 'SHOULD' direction in section 4.1. The goal of this change + implement a 'SHOULD' direction in section 4.1. The goal of this change is to start up faster. [ISC-Bugs #19660] - -- Added 'initial-delay' parameter that specifies maximum amount of time - before client goes to the INIT state. The default value is 0. In previous - versions of the code client could wait up to 5 seconds. The old behavior + +- Added 'initial-delay' parameter that specifies maximum amount of time + before client goes to the INIT state. The default value is 0. In previous + versions of the code client could wait up to 5 seconds. The old behavior may be restored by using 'initial-delay 5;' in the client config file. [ISC-Bugs #19660] @@ -851,7 +866,7 @@ by Eric Young (eay@cryptsoft.com). configuration parameter, in the case of an agent not covered by a configured subnet the root configuration area is examined. Server now also returns vendor-class-id option, if client sent it. [ISC-Bugs #21094] - + - Documentation fixes [ISC-Bugs #17959] add text to AIX section describing how to have it send responses to the all-ones address. @@ -866,8 +881,8 @@ by Eric Young (eay@cryptsoft.com). - Relay now properly logs that packet was received over interface without global IPv6 address [ISC-Bugs #24070] -- Linux Packet Filter interface improvement. sockaddr_pkt structure is used, - rather than sockaddr. Packet ethertype is now forced to ETH_P_IP. +- Linux Packet Filter interface improvement. sockaddr_pkt structure is used, + rather than sockaddr. Packet ethertype is now forced to ETH_P_IP. [ISC-Bugs #18975] - Minor code cleanups - but note port change for #23196 @@ -883,7 +898,7 @@ by Eric Young (eay@cryptsoft.com). [ISC-Bugs #19368] - Tidy up variable types in validate_port. - Code cleanup: remove obsolete PROTO, KandR, INLINE and ANSI_DECL macros - [ISC-Bugs #13151] + [ISC-Bugs #13151] - Compilation problem with gcc4.5 and omshell.c resolved. [ISC-Bugs #23831] @@ -898,7 +913,7 @@ by Eric Young (eay@cryptsoft.com). - Documentation cleanup [ISC-Bugs #23326] Updated References document, several man page updates -- Server no longer complains about NULL pointer when configured +- Server no longer complains about NULL pointer when configured server-identifier expression fails to evaluate. [ISC-Bugs #24547] - Convert ISC_R_INPROGRESS status to ISC_R_SUCCESS when called from other @@ -913,9 +928,9 @@ by Eric Young (eay@cryptsoft.com). - In Solaris 11 switch to using sockets instead of DLPI, thanks to a patch form Oracle. [ISC-Bugs #24634]. -- Strict checks for content of domain-name DHCPv4 option can now be - configured during compilation time. Even though RFC2132 does not allow - to store more than one domain in domain-name option, such behavior is +- Strict checks for content of domain-name DHCPv4 option can now be + configured during compilation time. Even though RFC2132 does not allow + to store more than one domain in domain-name option, such behavior is now enabled by default, but this may change some time in the future. See ACCEPT_LIST_IN_DOMAIN_NAME define in includes/site.h. [ISC-Bugs #24167] @@ -983,7 +998,7 @@ by Eric Young (eay@cryptsoft.com). - Tidy up the receive calls and eliminate the need for found_pkt. [ISC-Bugs #25066] - + - Add support for Infiniband over sockets to the server and relay code. We've tested this on Solaris and hope to expand support for Infiniband in the future. This patch also corrects @@ -1078,14 +1093,14 @@ by Eric Young (eay@cryptsoft.com). minimize disruption. The restriction will likely be tightened in the future to disallow ids with a length of 1. Thanks to Markus Hietava of Codenomicon CROSS project for the - finding this issue and CERT-FI for vulnerability coordination. + finding this issue and CERT-FI for vulnerability coordination. [ISC-Bugs #29851] CVE: CVE-2012-3571 ! When attempting to convert a DUID from a client id option into a hardware address handle unexpected client ids properly. Thanks to Markus Hietava of Codenomicon CROSS project for the - finding this issue and CERT-FI for vulnerability coordination. + finding this issue and CERT-FI for vulnerability coordination. [ISC-Bugs #29852] CVE: CVE-2012-3570 @@ -1139,7 +1154,7 @@ by Eric Young (eay@cryptsoft.com). and patches. [ISC-Bugs #23833] -- Parsing unquoted base64 strings improved. Parser now properly handles +- Parsing unquoted base64 strings improved. Parser now properly handles strings that contain reserved names. [ISC-Bugs #23048] - Modify the nak_lease function to make some attempts to find a @@ -1422,7 +1437,7 @@ by Eric Young (eay@cryptsoft.com). - Clean up to allow compilation with gcc 2.95.4 on FreeBSD. Remove an extra semi-colon from common/dns.c and moved setting a variable to NULL in server/dhcpv6.c to allow the compiler to decide that the variable - was always properly set. + was always properly set. Changes since 4.1.0b1 @@ -1581,7 +1596,7 @@ by Eric Young (eay@cryptsoft.com). This is useful if you want not only to release a lease, but also make it available for reuse right away. Hat tip to Christof Chen. -- Fixed definition of the iaaddr hash functions to use the correct +- Fixed definition of the iaaddr hash functions to use the correct functions when referencing and dereferencing memory. - Some definitions not in phase with the IANA registry were updated. @@ -1664,7 +1679,7 @@ by Eric Young (eay@cryptsoft.com). - When server is configured with options that it overrides, a warning is issued when the configuration file is read, rather than at the time the option is overridden. This was important, because the warning was given - every time the option was overridden, which could create a lot of + every time the option was overridden, which could create a lot of unnecessary logging. - Fixed a compilation problems on platforms that define a value for FDDI, @@ -1680,7 +1695,7 @@ by Eric Young (eay@cryptsoft.com). - Fix startup error messages to report a missing "subnet6 declaration", rather than a missing "subnet declaration", when running as a DHCPv6 server. -- DHCPv6 client timestamp in DUID was based on the year 1970 rather +- DHCPv6 client timestamp in DUID was based on the year 1970 rather than the year 2000. - Warn when attempting to use a hardware parameter in DHCPv6. @@ -1698,12 +1713,12 @@ by Eric Young (eay@cryptsoft.com). - dhc6_lease_destroy() and dhc6_ia_destroy() now set lease and IA pointers to NULL after freeing, to prevent subsequent accesses to freed memory. -- The DHCPv6 server would not send the preference option unless the +- The DHCPv6 server would not send the preference option unless the client requested it, via the ORO. This has been fixed, so the DHCPv6 server will always send the preference value if it is configured. -- When addresses were passed as hints to the server in an IA, they were - incorrectly handled, sometimes being treated as an error. Now the +- When addresses were passed as hints to the server in an IA, they were + incorrectly handled, sometimes being treated as an error. Now the server will treat these as hints and ignore them if it cannot supply a requested address. @@ -1741,8 +1756,8 @@ by Eric Young (eay@cryptsoft.com). to put dhcpd.leases and dhclient.leases in /usr/local/var/db, which no one ever has. -- Regression fix for bug where server advertised a IPv6 address in - response to a SOLICIT but would not return the address in response +- Regression fix for bug where server advertised a IPv6 address in + response to a SOLICIT but would not return the address in response to a REQUEST. - A bug was fixed where the DHCPv6 server puts the NoAddrsAvail status @@ -1774,7 +1789,7 @@ by Eric Young (eay@cryptsoft.com). - Eliminated a spurious error message from the client -- A number of bugs with the internal handling of lease state on the +- A number of bugs with the internal handling of lease state on the server have been fixed. Some of these could cause server crashes. - The peer_wants_leases() changes pulled up from 3.1.0 were corrected, @@ -1789,13 +1804,13 @@ by Eric Young (eay@cryptsoft.com). Changes since 4.0.0a3 -- The DHCP server no longer requires a "ddns-update-style" statement, +- The DHCP server no longer requires a "ddns-update-style" statement, and now defaults to "none", which means DNS updates are disabled. - Log messages when failover peer names mismatch have been improved to point out the problem. -- Bug where server advertised a IPv6 address in response to a SOLICIT +- Bug where server advertised a IPv6 address in response to a SOLICIT but would not return the address in response to a REQUEST. Thanks to Dennis Kou for finding the bug. @@ -1808,7 +1823,7 @@ by Eric Young (eay@cryptsoft.com). - Compilation with DLPI and -Werror has been repaired. -- Error in decoding IA_NA option if multiple interfaces are present +- Error in decoding IA_NA option if multiple interfaces are present fixed by Marcus Goller. - DHCPv6 server Confirm message processing has been enhanced - it no @@ -1834,7 +1849,7 @@ by Eric Young (eay@cryptsoft.com). - Fixed file descriptor leak on listen failure. Thanks to Tom Clark. - Bug in server configuration parser caused server to get stuck on - startup for certain bad pool declarations. Thanks to Guillaume + startup for certain bad pool declarations. Thanks to Guillaume Knispel for the bug report and fix. - Code cleaned to remove warnings reported by "gcc -Wall". @@ -1850,8 +1865,8 @@ by Eric Young (eay@cryptsoft.com). the DHCPv6 client configuration. 'send dhcp6.oro' is no longer necessary. -- Bug fixed where configuration file parsing did not work with - zero-length options; this made it impossible to set the +- Bug fixed where configuration file parsing did not work with + zero-length options; this made it impossible to set the rapid-commit option. - Bogus messages about host records with IPv4 fixed-addresses being of @@ -3235,7 +3250,7 @@ by Eric Young (eay@cryptsoft.com). had been done for a client with no name, even though no update had been done, and then when the client's lease expired the deletion of that nonexistant record would time out because the name was the null - string. + string. - Clean up the omshell, dhcpctl and omapi man pages a bit. @@ -3758,7 +3773,7 @@ by Eric Young (eay@cryptsoft.com). - When we get a bogus state lease binding state transition, don't do the transition. - + Changes since 3.0 Beta 2 Patchlevel 12 @@ -109,6 +109,43 @@ AC_PREREQ([2.50])dnl am_aux_dir=`cd $ac_aux_dir && pwd` ]) +# AM_COND_IF -*- Autoconf -*- + +# Copyright (C) 2008-2013 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_COND_IF +# _AM_COND_ELSE +# _AM_COND_ENDIF +# -------------- +# These macros are only used for tracing. +m4_define([_AM_COND_IF]) +m4_define([_AM_COND_ELSE]) +m4_define([_AM_COND_ENDIF]) + +# AM_COND_IF(COND, [IF-TRUE], [IF-FALSE]) +# --------------------------------------- +# If the shell condition COND is true, execute IF-TRUE, otherwise execute +# IF-FALSE. Allow automake to learn about conditional instantiating macros +# (the AC_CONFIG_FOOS). +AC_DEFUN([AM_COND_IF], +[m4_ifndef([_AM_COND_VALUE_$1], + [m4_fatal([$0: no such condition "$1"])])dnl +_AM_COND_IF([$1])dnl +if test -z "$$1_TRUE"; then : + m4_n([$2])[]dnl +m4_ifval([$3], +[_AM_COND_ELSE([$1])dnl +else + $3 +])dnl +_AM_COND_ENDIF([$1])dnl +fi[]dnl +]) + # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. diff --git a/client/Makefile.in b/client/Makefile.in index 066c698e..7b7d6067 100644 --- a/client/Makefile.in +++ b/client/Makefile.in @@ -232,6 +232,7 @@ am__relativize = \ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ diff --git a/client/tests/Makefile.am b/client/tests/Makefile.am index 484318b0..a16d5891 100644 --- a/client/tests/Makefile.am +++ b/client/tests/Makefile.am @@ -21,12 +21,8 @@ DHCPLIBS = $(top_builddir)/common/libdhcp.a $(top_builddir)/omapip/libomapi.a $(top_builddir)/bind/lib/libisc.a ATF_TESTS = -TESTS = if HAVE_ATF -check: $(ATF_TESTS) - atf-run | atf-report - ATF_TESTS += duid_unittests duid_unittests_SOURCES = $(DHCPSRC) @@ -35,6 +31,9 @@ duid_unittests_SOURCES += duid_unittest.c duid_unittests_LDADD = $(ATF_LDFLAGS) duid_unittests_LDADD += $(DHCPLIBS) +check: $(ATF_TESTS) + sh ${top_srcdir}/tests/unittest.sh + endif -check_PROGRAMS = $(ATF_TESTS) $(TESTS) +check_PROGRAMS = $(ATF_TESTS) diff --git a/client/tests/Makefile.in b/client/tests/Makefile.in index e7b8f5ca..d724a1e3 100644 --- a/client/tests/Makefile.in +++ b/client/tests/Makefile.in @@ -77,12 +77,11 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -TESTS = @HAVE_ATF_TRUE@am__append_1 = duid_unittests -check_PROGRAMS = $(am__EXEEXT_2) $(am__EXEEXT_3) +check_PROGRAMS = $(am__EXEEXT_2) subdir = client/tests DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp $(top_srcdir)/test-driver + $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -93,7 +92,6 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @HAVE_ATF_TRUE@am__EXEEXT_1 = duid_unittests$(EXEEXT) am__EXEEXT_2 = $(am__EXEEXT_1) -am__EXEEXT_3 = am__duid_unittests_SOURCES_DIST = ../clparse.c ../dhc6.c ../dhclient.c \ duid_unittest.c am__objects_1 = clparse.$(OBJEXT) dhc6.$(OBJEXT) dhclient.$(OBJEXT) @@ -157,7 +155,7 @@ am__recursive_targets = \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - check recheck distdir + distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -177,207 +175,6 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red='[0;31m'; \ - grn='[0;32m'; \ - lgn='[1;32m'; \ - blu='[1;34m'; \ - mgn='[0;35m'; \ - brg='[1m'; \ - std='[m'; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ @@ -408,6 +205,7 @@ am__relativize = \ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ @@ -524,7 +322,7 @@ ATF_TESTS = $(am__append_1) all: all-recursive .SUFFIXES: -.SUFFIXES: .c .log .o .obj .test .test$(EXEEXT) .trs +.SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -729,162 +527,6 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - else \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all $(check_PROGRAMS) - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -942,7 +584,6 @@ distdir: $(DISTFILES) done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive all-am: Makefile installdirs: installdirs-recursive @@ -967,9 +608,6 @@ install-strip: "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: @@ -1050,18 +688,17 @@ uninstall-am: .MAKE: $(am__recursive_targets) check-am install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-TESTS check-am clean clean-checkPROGRAMS clean-generic \ - cscopelist-am ctags ctags-am 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 installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am recheck tags tags-am \ - uninstall uninstall-am + check-am clean clean-checkPROGRAMS clean-generic cscopelist-am \ + ctags ctags-am 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 \ + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ + ps ps-am tags tags-am uninstall uninstall-am # for autotools debugging only @@ -1071,7 +708,7 @@ info: @echo "ATF_LIBS=$(ATF_LIBS)" @HAVE_ATF_TRUE@check: $(ATF_TESTS) -@HAVE_ATF_TRUE@ atf-run | atf-report +@HAVE_ATF_TRUE@ sh ${top_srcdir}/tests/unittest.sh # 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. diff --git a/common/Makefile.in b/common/Makefile.in index d98f53f1..51e78184 100644 --- a/common/Makefile.in +++ b/common/Makefile.in @@ -239,6 +239,7 @@ am__relativize = \ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ diff --git a/common/tests/Makefile.am b/common/tests/Makefile.am index b9b11219..32e055c1 100644 --- a/common/tests/Makefile.am +++ b/common/tests/Makefile.am @@ -35,7 +35,7 @@ ns_name_unittest_LDADD += ../libdhcp.a \ ../../bind/lib/libdns.a ../../bind/lib/libisccfg.a ../../bind/lib/libisc.a check: $(ATF_TESTS) - atf-run | atf-report + sh ${top_srcdir}/tests/unittest.sh endif diff --git a/common/tests/Makefile.in b/common/tests/Makefile.in index c9148eea..a7ebb057 100644 --- a/common/tests/Makefile.in +++ b/common/tests/Makefile.in @@ -243,6 +243,7 @@ am__relativize = \ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ @@ -740,7 +741,7 @@ uninstall-am: @HAVE_ATF_TRUE@check: $(ATF_TESTS) -@HAVE_ATF_TRUE@ atf-run | atf-report +@HAVE_ATF_TRUE@ sh ${top_srcdir}/tests/unittest.sh # 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. @@ -629,6 +629,7 @@ LDAP_CFLAGS ac_prefix_program HAVE_ATF_FALSE HAVE_ATF_TRUE +ATF_BIN ATF_LDFLAGS ATF_CFLAGS byte_order @@ -5243,7 +5244,7 @@ if test "${enable_debug+set}" = set; then : $as_echo "#define DEBUG 1" >>confdefs.h - # Just override CFLAGS to totally to remove optimization. + # Just override CFLAGS totally to remove optimization. CFLAGS="-g";; no) enable_debug=no ;; *) as_fn_error $? "bad value ${enableval} for --enable-debug" "$LINENO" 5 ;; @@ -5443,16 +5444,32 @@ if test "$atf_path" != "no" ; then do if test -f $d/lib/pkgconfig/atf-c.pc ; then atf_pcp=$d/lib/pkgconfig + atf_path=$d elif test -f $d/lib64/pkgconfig/atf-c.pc ; then atf_pcp=$d/lib64/pkgconfig + atf_path=$d fi done fi + if test "$atf_pcp" = "" ; then as_fn_error $? "Unable to find atf files in location specified" "$LINENO" 5 else ATF_CFLAGS="`PKG_CONFIG_PATH=$atf_pcp pkg-config --cflags atf-c` -DUNIT_TEST" ATF_LDFLAGS="`PKG_CONFIG_PATH=$atf_pcp pkg-config --libs atf-c`" + if test -f $atf_pcp/atf-sh.pc ; then + ATF_BIN="`PKG_CONFIG_PATH=$atf_pcp pkg-config --variable=exec_prefix atf-sh`/bin" + else + # older versions don't have atf-sh, try usual place + ATF_BIN=$atf_path/bin + fi + + if test ! -x $ATF_BIN/atf-run -o ! -x $ATF_BIN/atf-report ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: atf-run,atf-report not found, assuming they are in your path" >&5 +$as_echo "$as_me: WARNING: atf-run,atf-report not found, assuming they are in your path" >&2;} + fi + + fi @@ -5466,8 +5483,11 @@ else HAVE_ATF_FALSE= fi -### Uncomment this once docs.lab.isc.org upgrades to automake 1.11 -### AM_COND_IF([HAVE_ATF], [AC_DEFINE([HAVE_ATF], [1], [ATF framework specified?])]) +if test -z "$HAVE_ATF_TRUE"; then : + +$as_echo "#define HAVE_ATF 1" >>confdefs.h + +fi ### ### Path fun. Older versions of DHCP were installed in /usr/sbin, so we @@ -6782,7 +6802,7 @@ $as_echo "#define FLEXIBLE_ARRAY_MEMBER /**/" >>confdefs.h fi -ac_config_files="$ac_config_files Makefile client/Makefile client/tests/Makefile common/Makefile common/tests/Makefile dhcpctl/Makefile dst/Makefile includes/Makefile omapip/Makefile relay/Makefile server/Makefile tests/Makefile server/tests/Makefile doc/devel/doxyfile" +ac_config_files="$ac_config_files Makefile client/Makefile client/tests/Makefile common/Makefile common/tests/Makefile dhcpctl/Makefile dst/Makefile includes/Makefile omapip/Makefile relay/Makefile server/Makefile tests/Makefile tests/unittest.sh server/tests/Makefile doc/devel/doxyfile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -7532,6 +7552,7 @@ do "relay/Makefile") CONFIG_FILES="$CONFIG_FILES relay/Makefile" ;; "server/Makefile") CONFIG_FILES="$CONFIG_FILES server/Makefile" ;; "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; + "tests/unittest.sh") CONFIG_FILES="$CONFIG_FILES tests/unittest.sh" ;; "server/tests/Makefile") CONFIG_FILES="$CONFIG_FILES server/tests/Makefile" ;; "doc/devel/doxyfile") CONFIG_FILES="$CONFIG_FILES doc/devel/doxyfile" ;; @@ -8254,6 +8275,7 @@ if test "$atf_path" != "no" then echo "ATF_CFLAGS : $ATF_CFLAGS" >> config.report echo "ATF_LDFLAGS : $ATF_LDFLAGS" >> config.report +echo "ATF_BIN : $ATF_BIN" >> config.report echo fi diff --git a/configure.ac b/configure.ac index 5f7c25f5..12bd2be0 100644 --- a/configure.ac +++ b/configure.ac @@ -205,24 +205,38 @@ if test "$atf_path" != "no" ; then do if test -f $d/lib/pkgconfig/atf-c.pc ; then atf_pcp=$d/lib/pkgconfig + atf_path=$d elif test -f $d/lib64/pkgconfig/atf-c.pc ; then atf_pcp=$d/lib64/pkgconfig + atf_path=$d fi done fi + if test "$atf_pcp" = "" ; then AC_MSG_ERROR([Unable to find atf files in location specified]) else ATF_CFLAGS="`PKG_CONFIG_PATH=$atf_pcp pkg-config --cflags atf-c` -DUNIT_TEST" ATF_LDFLAGS="`PKG_CONFIG_PATH=$atf_pcp pkg-config --libs atf-c`" + if test -f $atf_pcp/atf-sh.pc ; then + ATF_BIN="`PKG_CONFIG_PATH=$atf_pcp pkg-config --variable=exec_prefix atf-sh`/bin" + else + # older versions don't have atf-sh, try usual place + ATF_BIN=$atf_path/bin + fi + + if test ! -x $ATF_BIN/atf-run -o ! -x $ATF_BIN/atf-report ; then + AC_MSG_WARN([atf-run,atf-report not found, assuming they are in your path]) + fi + AC_SUBST(ATF_CFLAGS) AC_SUBST(ATF_LDFLAGS) + AC_SUBST(ATF_BIN) fi fi AM_CONDITIONAL(HAVE_ATF, test "$atf_pcp" != "") -### Uncomment this once docs.lab.isc.org upgrades to automake 1.11 -### AM_COND_IF([HAVE_ATF], [AC_DEFINE([HAVE_ATF], [1], [ATF framework specified?])]) +AM_COND_IF([HAVE_ATF], [AC_DEFINE([HAVE_ATF], [1], [ATF framework specified?])]) ### ### Path fun. Older versions of DHCP were installed in /usr/sbin, so we @@ -634,6 +648,7 @@ AC_CONFIG_FILES([ relay/Makefile server/Makefile tests/Makefile + tests/unittest.sh server/tests/Makefile doc/devel/doxyfile ]) @@ -671,6 +686,7 @@ if test "$atf_path" != "no" then echo "ATF_CFLAGS : $ATF_CFLAGS" >> config.report echo "ATF_LDFLAGS : $ATF_LDFLAGS" >> config.report +echo "ATF_BIN : $ATF_BIN" >> config.report echo fi diff --git a/dhcpctl/Makefile.in b/dhcpctl/Makefile.in index 61cfcf12..105ceb69 100644 --- a/dhcpctl/Makefile.in +++ b/dhcpctl/Makefile.in @@ -207,6 +207,7 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ diff --git a/doc/devel/atf.dox b/doc/devel/atf.dox index 1f3d7912..dd596841 100644 --- a/doc/devel/atf.dox +++ b/doc/devel/atf.dox @@ -30,18 +30,28 @@ Test Framework)</a> as a framework to run our unittests. ATF stands for Automated Test Framework, and is the framework used for unit tests in ISC DHCP and BIND9. ATF sources can be downloaded from -http://code.google.com/p/kyua/wiki/ATF . ATF itself must be configured, compiled +https://github.com/jmmv/kyua . ATF itself must be configured, compiled and then installed to be available during the DHCP configure procedure. Please follow INSTALL file supplied with ATF sources (it's essentially the typical ./configure && make && make install procedure). +Beginning with ATF version 0.16, it is necessary to include the following +options --enable-tools and --disable-shared when configuring ATF: + +@verbatim + configure --prefix=<prefix> --enable-tools --disable-shared +@endverbatim + +ISC DHCP unittests will run with ATF releases upto 0.19. Beginning with +ATF 0.20, the tools, atf-run and atf-report required by ISC DHCP, were +deprecated and are no longer included with ATF. + The ATF successor, called Kyua, is being developed. As of August 2012, the latest available release of Kyua is 0.5. It claims to offer feature parity with ATF. Migration to Kyua may be planned some time in the future, but DHCP uses ATF -for now. Such an upgrade should be done in coordination with BIND. The latest -tested version of ATF that DHCP's unittests were run against is 0.15. +for now. Such an upgrade should be done in coordination with BIND. -To build the unit-tests, use the following: +To build and run the unit-tests, use the following: @verbatim $ ./configure --with-atf @@ -49,6 +59,11 @@ $ make $ make check @endverbatim +This will traverse the source tree running the unit tests in each unit test +subdirectory. Note that if one or more tests in a unit test subdirectory fail +the make process will stop. To run all of the tests regardless of outcome, +use "make -k check" + The following syntax is supported as well: @verbatim $ ./configure --with-atf=/path/to/your/atf/install @@ -66,6 +81,9 @@ executable. The typical way to run tests is: @verbatim $ atf-run | atf-report +(This assumes atf-run and atf-report are in your path) +or +$ sh ../../tests/unittests.sh @endverbatim atf-run will read the Atffile in the current directory and execute all the tests diff --git a/dst/Makefile.in b/dst/Makefile.in index fd29aaee..ff12ff95 100644 --- a/dst/Makefile.in +++ b/dst/Makefile.in @@ -188,6 +188,7 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ diff --git a/includes/Makefile.in b/includes/Makefile.in index 3e302f75..b453cddb 100644 --- a/includes/Makefile.in +++ b/includes/Makefile.in @@ -161,6 +161,7 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ diff --git a/includes/config.h.in b/includes/config.h.in index 3124b85c..6d07e9f0 100644 --- a/includes/config.h.in +++ b/includes/config.h.in @@ -34,6 +34,9 @@ MSVC and with C++ compilers. */ #undef FLEXIBLE_ARRAY_MEMBER +/* ATF framework specified? */ +#undef HAVE_ATF + /* Define to 1 to use the Berkeley Packet Filter interface code. */ #undef HAVE_BPF diff --git a/omapip/Makefile.in b/omapip/Makefile.in index c7fff53c..35e2f7f3 100644 --- a/omapip/Makefile.in +++ b/omapip/Makefile.in @@ -204,6 +204,7 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ diff --git a/relay/Makefile.in b/relay/Makefile.in index be95fb71..2fc955d7 100644 --- a/relay/Makefile.in +++ b/relay/Makefile.in @@ -185,6 +185,7 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ diff --git a/server/Makefile.in b/server/Makefile.in index b7e74146..80652313 100644 --- a/server/Makefile.in +++ b/server/Makefile.in @@ -246,6 +246,7 @@ am__relativize = \ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am index 984881bb..fb345c54 100644 --- a/server/tests/Makefile.am +++ b/server/tests/Makefile.am @@ -23,12 +23,8 @@ DHCPLIBS = $(top_builddir)/common/libdhcp.a $(top_builddir)/omapip/libomapi.a $(top_builddir)/bind/lib/libisc.a ATF_TESTS = -TESTS = if HAVE_ATF -check: $(ATF_TESTS) - atf-run | atf-report - ATF_TESTS += dhcpd_unittests legacy_unittests hash_unittests load_bal_unittests dhcpd_unittests_SOURCES = $(DHCPSRC) @@ -42,7 +38,6 @@ dhcpd_unittests_LDFLAGS = $(AM_LDFLAGS) $(ATF_LDFLAGS) hash_unittests_SOURCES = $(DHCPSRC) hash_unittest.c hash_unittests_LDADD = $(DHCPLIBS) $(ATF_LDFLAGS) - # This is a legacy unittest. It replaces main() with something that was in mdb6.c legacy_unittests_SOURCES = $(DHCPSRC) mdb6_unittest.c legacy_unittests_LDADD = $(DHCPLIBS) $(ATF_LDFLAGS) @@ -50,6 +45,9 @@ legacy_unittests_LDADD = $(DHCPLIBS) $(ATF_LDFLAGS) load_bal_unittests_SOURCES = $(DHCPSRC) load_bal_unittest.c load_bal_unittests_LDADD = $(DHCPLIBS) $(ATF_LDFLAGS) +check: $(ATF_TESTS) + sh ${top_srcdir}/tests/unittest.sh + endif -check_PROGRAMS = $(ATF_TESTS) $(TESTS) +check_PROGRAMS = $(ATF_TESTS) diff --git a/server/tests/Makefile.in b/server/tests/Makefile.in index 4f8ae73e..33669fe5 100644 --- a/server/tests/Makefile.in +++ b/server/tests/Makefile.in @@ -77,12 +77,11 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -TESTS = @HAVE_ATF_TRUE@am__append_1 = dhcpd_unittests legacy_unittests hash_unittests load_bal_unittests -check_PROGRAMS = $(am__EXEEXT_2) $(am__EXEEXT_3) +check_PROGRAMS = $(am__EXEEXT_2) subdir = server/tests DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp $(top_srcdir)/test-driver + $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -96,7 +95,6 @@ CONFIG_CLEAN_VPATH_FILES = @HAVE_ATF_TRUE@ hash_unittests$(EXEEXT) \ @HAVE_ATF_TRUE@ load_bal_unittests$(EXEEXT) am__EXEEXT_2 = $(am__EXEEXT_1) -am__EXEEXT_3 = am__dhcpd_unittests_SOURCES_DIST = ../dhcp.c ../bootp.c ../confpars.c \ ../db.c ../class.c ../failover.c ../omapi.c ../mdb.c \ ../stables.c ../salloc.c ../ddns.c ../dhcpleasequery.c \ @@ -204,7 +202,7 @@ am__recursive_targets = \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - check recheck distdir + distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -224,207 +222,6 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red='[0;31m'; \ - grn='[0;32m'; \ - lgn='[1;32m'; \ - blu='[1;34m'; \ - mgn='[0;35m'; \ - brg='[1m'; \ - std='[m'; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ @@ -455,6 +252,7 @@ am__relativize = \ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ @@ -584,7 +382,7 @@ ATF_TESTS = $(am__append_1) all: all-recursive .SUFFIXES: -.SUFFIXES: .c .log .o .obj .test .test$(EXEEXT) .trs +.SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -1014,162 +812,6 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - else \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all $(check_PROGRAMS) - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -1227,7 +869,6 @@ distdir: $(DISTFILES) done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive all-am: Makefile installdirs: installdirs-recursive @@ -1252,9 +893,6 @@ install-strip: "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: @@ -1335,18 +973,17 @@ uninstall-am: .MAKE: $(am__recursive_targets) check-am install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-TESTS check-am clean clean-checkPROGRAMS clean-generic \ - cscopelist-am ctags ctags-am 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 installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am recheck tags tags-am \ - uninstall uninstall-am + check-am clean clean-checkPROGRAMS clean-generic cscopelist-am \ + ctags ctags-am 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 \ + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ + ps ps-am tags tags-am uninstall uninstall-am # for autotools debugging only @@ -1356,7 +993,7 @@ info: @echo "ATF_LIBS=$(ATF_LIBS)" @HAVE_ATF_TRUE@check: $(ATF_TESTS) -@HAVE_ATF_TRUE@ atf-run | atf-report +@HAVE_ATF_TRUE@ sh ${top_srcdir}/tests/unittest.sh # 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. diff --git a/tests/HOWTO-unit-test b/tests/HOWTO-unit-test index b84beba3..e00b7d58 100644 --- a/tests/HOWTO-unit-test +++ b/tests/HOWTO-unit-test @@ -13,7 +13,7 @@ and then opening doc/html/index.html Tests Overview -------------- -In DHCP, a unit test exercises a particular piece of code in +In DHCP, a unit test exercises a particular piece of code in isolation. There is a separate unit test per module or API. Each unit test lives in a directory beneath the code it is designed to exercise. So, we (will eventually) have: @@ -26,31 +26,57 @@ So, we (will eventually) have: And so on. We are using ATF (Automated Test Framework) as a framework to run our -unittests. See ISC DHCP Developer's Guide for much more thorough +unit tests. See ISC DHCP Developer's Guide for much more thorough description of unit-test and ATF framework in general. +Installing ATF +-------------- +ATF sources can be downloaded from https://github.com/jmmv/kyua. ATF +must be configured, compiled and then installed to be available during +the DHCP configure procedure. Please follow INSTALL file supplied with +ATF sources (it's essentially the typical ./configure && make && +make install procedure). + +Beginning with ATF version 0.16, it is necessary to include the following +options --enable-tools and --disable-shared when configuring ATF: + + configure --prefix=<prefix> --enable-tools --disable-shared + +ISC DHCP unittests will run with ATF releases upto 0.19. Beginning with +ATF 0.20, the tools, atf-run and atf-report required by ISC DHCP, were +deprecated and are no longer included with ATF. + Running Unit Tests ------------------ In order to run the unit tests for DHCP, enable ATF support during configure: -$ ./configure --with-atf +$ ./configure --with-atf{=<atf-path>} + + where <atf-path> is the path into which ATF was installed. This would + be same value used for --prefix when ATF was configured (default is + /usr/local). -And then use: +And then build ISC_DHCP with: + +$ make + +Finally build and run unit tests with: $ make check -This will run all of the unit tests. Make sure that ATF is actually -installed and that you have atf-run and atf-report tool in your PATH. +This will traverse the source tree running the unit tests in each unit test +subdirectory. Note that if one or more tests in a unit test subdirectory fail +the make process will stop. To run all of the tests regardless of outcome, +use: + +$ make -k check -You can run a single test by going to the appropriate test directory +You can run a single test by going to the appropriate test directory and invoking the test directly: $ cd server/tests -$ atf-run | atf-report - -There are also a number of options that you can use when running a -test. See atf-run and atf-report documentation. +$ make check Adding a New Unit Test ---------------------- diff --git a/tests/Makefile.in b/tests/Makefile.in index 79477b7b..629339d7 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -79,14 +79,14 @@ build_triplet = @build@ host_triplet = @host@ subdir = tests DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp + $(srcdir)/unittest.sh.in $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/includes/config.h -CONFIG_CLEAN_FILES = +CONFIG_CLEAN_FILES = unittest.sh CONFIG_CLEAN_VPATH_FILES = AR = ar ARFLAGS = cru @@ -156,6 +156,7 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ATF_BIN = @ATF_BIN@ ATF_CFLAGS = @ATF_CFLAGS@ ATF_LDFLAGS = @ATF_LDFLAGS@ AUTOCONF = @AUTOCONF@ @@ -320,6 +321,8 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): +unittest.sh: $(top_builddir)/config.status $(srcdir)/unittest.sh.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ clean-checkLIBRARIES: -test -z "$(check_LIBRARIES)" || rm -f $(check_LIBRARIES) diff --git a/tests/unittest.sh.in b/tests/unittest.sh.in new file mode 100755 index 00000000..0ee7ab70 --- /dev/null +++ b/tests/unittest.sh.in @@ -0,0 +1,79 @@ +#!/bin/sh +# +# Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. +# +# Script used to execute unit tests described by the Atffile in the current +# directory. It exits with return value of atf-run, which will be 0 if all +# tests passed, non-zero otherwise. +# + +# Add configured path to ATF tools, atf-run and atf-report +PATH="@ATF_BIN@:${PATH}" +export PATH + +# colors if not outputting to a dumb terminal and stdout is a tty +if test "$TERM" != dumb && { test -t 1; } 2>/dev/null; then \ + red='\033[0;31m' + green='\033[0;32m' + noclr='\033[0m' + + # if echo supports -e, we must use it to set colors + # (output will be "" if its supported) + if [ -z "`echo -e`" ] + then + dash_e="-e" + fi +fi; + +header="====================================================" + +status=0 +if [ -n "@ATF_BIN@" -a -f Atffile ] +then + # run the tests + echo "Running unit tests..." + atf-run > atf.out + status=$? + + # set color based on success/failure + if [ $status -eq 0 ] + then + color=$green + else + color=$red + fi + + # spit out the test report + # We print everything upto the summary in + # "no color". Print the summary in our + # result color. + cat atf.out | atf-report | while read line + do + cnt=`echo $line | grep -c "Summary"` + if [ $cnt -eq 1 ] + then + echo $dash_e $color$header + fi + echo $line; + done + echo $dash_e $header$noclr + + # clean up unless there were test failures + if [ $status -eq 0 ] + then + rm -f atf.out + fi +fi +exit $status |