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