xref: /netbsd-src/external/mpl/dhcp/dist/tests/HOWTO-unit-test (revision 5f2f42719cd62ff11fd913b40b7ce19f07c4fd25)
1Introduction
2------------
3
4That is only a brief overview of tests in ISC DHCP. For more thorough
5description, see ISC DHCP Developer's Guide. You can generate it, by
6having Doxygen installed and doing:
7
8 cd doc
9 make devel
10
11and then opening doc/html/index.html
12
13Tests Overview
14--------------
15
16In DHCP, a unit test exercises a particular piece of code in
17isolation. There is a separate unit test per module or API. Each unit
18test lives in a directory beneath the code it is designed to exercise.
19So, we (will eventually) have:
20
21    server/tests/
22    client/tests/
23    common/tests/
24    dhcpctl/tests/
25
26And so on.
27
28We are using ATF (Automated Test Framework) as a framework to run our
29unit tests. See ISC DHCP Developer's Guide for much more thorough
30description of unit-test and ATF framework in general.
31
32Installing ATF
33--------------
34ATF sources can be downloaded from https://github.com/jmmv/kyua. ATF
35must be configured, compiled and then installed to be available during
36the DHCP configure procedure. Please follow INSTALL file supplied with
37ATF sources (it's essentially the typical ./configure && make &&
38make install procedure).
39
40Beginning with ATF version 0.16, it is necessary to include the following
41options --enable-tools and --disable-shared when configuring ATF:
42
43    configure --prefix=<prefix> --enable-tools --disable-shared
44
45ISC DHCP unittests will run with ATF releases upto 0.19.  Beginning with
46ATF 0.20, the tools, atf-run and atf-report required by ISC DHCP, were
47deprecated and are no longer included with ATF.
48
49Running Unit Tests
50------------------
51
52In order to run the unit tests for DHCP, enable ATF support during configure:
53
54$ ./configure --with-atf{=<atf-path>}
55
56    where <atf-path> is the path into which ATF was installed.  This would
57    be same value used for --prefix when ATF was configured (default is
58    /usr/local).
59
60And then build ISC_DHCP with:
61
62$ make
63
64Finally build and run unit tests with:
65
66$ make check
67
68This will traverse the source tree running the unit tests in each unit test
69subdirectory.  Note that if one or more tests in a unit test subdirectory fail
70the make process will stop.  To run all of the tests regardless of outcome,
71use:
72
73$ make -k check
74
75You can run a single test by going to the appropriate test directory
76and invoking the test directly:
77
78$ cd server/tests
79$ make check
80
81Adding a New Unit Test
82----------------------
83
84See ISC DHCP Developer's Guide.
85
86Adding a New Unit Test Program
87------------------------------
88
89See ISC DHCP Developer's Guide.
90