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