diff options
author | Tomek Mrugalski <tomasz@isc.org> | 2012-08-09 15:52:10 +0200 |
---|---|---|
committer | Tomek Mrugalski <tomasz@isc.org> | 2012-08-09 15:52:10 +0200 |
commit | e71e3d8248b5c05d561862bb1d8be529896063d6 (patch) | |
tree | f068903f305268e2b0dd3c42628e374d82f9bd40 /tests | |
parent | 0b6c9c0dc30954736695f6d469c6c9a7facb179b (diff) | |
download | isc-dhcp-e71e3d8248b5c05d561862bb1d8be529896063d6.tar.gz |
[rt25901_atf] tests/HOWTO-unit-test mostly moved to Devel Guide
- moved major parts of HOWTO to Developer's Guide, leaving only
brief notes and pointers to new location
- described Valgrind
Diffstat (limited to 'tests')
-rw-r--r-- | tests/HOWTO-unit-test | 87 |
1 files changed, 17 insertions, 70 deletions
diff --git a/tests/HOWTO-unit-test b/tests/HOWTO-unit-test index 1b6cf521..b84beba3 100644 --- a/tests/HOWTO-unit-test +++ b/tests/HOWTO-unit-test @@ -1,6 +1,18 @@ Introduction ------------ +That is only a brief overview of tests in ISC DHCP. For more thorough +description, see ISC DHCP Developer's Guide. You can generate it, by +having Doxygen installed and doing: + + cd doc + make devel + +and then opening doc/html/index.html + +Tests Overview +-------------- + 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. @@ -13,21 +25,16 @@ So, we (will eventually) have: And so on. -Ideally each function would be invoked with every possible type of -input, and each branch of every function would be checked. In practice -we try to be a bit more pragmatic, and target the most basic -operations, as well tricky code, and areas we have seen bugs in the -past. - We are using ATF (Automated Test Framework) as a framework to run our -unittests. +unittests. See ISC DHCP Developer's Guide for much more thorough +description of unit-test and ATF framework in general. Running Unit Tests ------------------ In order to run the unit tests for DHCP, enable ATF support during configure: -$ ./configure --enable-atf +$ ./configure --with-atf And then use: @@ -48,69 +55,9 @@ test. See atf-run and atf-report documentation. Adding a New Unit Test ---------------------- -To add an additional test to an existing test program, you must create -a function for the new test in the C source file. You can extend existing -test suite or create a new one. For introductory example, see -server/tests/simple_unittest.c. It is a skeleton example of ATF test. - -Tests in specified directory must be registered in Atffile. See -server/tests/Atffile for example. Currently every executable with name -that falls into *_unittest pattern will be executed automatically. +See ISC DHCP Developer's Guide. Adding a New Unit Test Program ------------------------------ -To add a new program, such as when a new module is added, you can copy -the "simple_unittest.c" file (in this directory) to a new name, add -the new file as a target in Makefile.am, and begin adding tests. Do -not forget to add it to CVS via "cvs add". - -If there is no "tests" directory for a given subdirectory, then one -must be created. This can be done by: - -1. Creating the directory: - - $ mkdir $subdir/tests - $ cvs add tests - -2. Adding the subdirectory to the build system: - - Add to $subdir/Makefile.am: - - SUBDIRS = tests - - Add to the AC_OUTPUT macro in configure.ac: - - $subdir/tests/Makefile - -3. Create a Makefile.am in the new directory, something like this: - - AM_CPPFLAGS = -I../.. - - check_PROGRAMS = test_foo - - TESTS = test_foo - - test_foo_SOURCES = test_foo.c - test_foo_LDADD = ../../tests/libt_api.a # plus others... - - -See existing Makefile.am for examples, and the Automake documentation: - - http://www.gnu.org/software/automake/manual/html_node/Tests.html - - -Support Functions ------------------ - -See http://www.netbsd.org/~jmmv/atf/index.html for details about ATF. Note -that although ATF was originally used for NetBSD validation, it is used -on many different platforms and is not NetBSD specific. - -Additional Testing ------------------- - -Other static or runtime testing is always an option. For instance, you -can use valgrind to check for memory leaks. - -$Id: HOWTO-unit-test,v 1.2.570.1 2012/01/31 15:50:15 tomasz Exp $ +See ISC DHCP Developer's Guide. |