blob: 84d5c58b7658db976830454555aafc811565d582 [file] [log] [blame] [view]
Davide Pesavento2840dbc2019-04-16 23:14:21 -04001# Notes for NFD developers
Alexander Afanasyev2aa39622014-01-22 11:51:11 -08002
Nick Gordon3257af22017-12-21 14:15:55 -06003If you are new to the NDN software community, please read the
Davide Pesavento17521592020-05-14 19:01:32 -04004[Contributor's Guide](https://github.com/named-data/.github/blob/master/CONTRIBUTING.md).
Nick Gordon3257af22017-12-21 14:15:55 -06005
Davide Pesavento2840dbc2019-04-16 23:14:21 -04006## Code style
Alexander Afanasyev284257b2014-04-11 14:16:51 -07007
Davide Pesavento08b91c82019-04-13 19:42:10 -04008NFD code is subject to [NFD code style](https://redmine.named-data.net/projects/nfd/wiki/CodeStyle).
9
Davide Pesavento2840dbc2019-04-16 23:14:21 -040010## Licensing
Davide Pesavento08b91c82019-04-13 19:42:10 -040011
12Contributions to NFD must be licensed under the GPL 3.0 or compatible license. If you
13are choosing GPL 3.0, please use the following license boilerplate in all `.hpp` and
14`.cpp` files:
Alexander Afanasyev319f2c82015-01-07 14:56:53 -080015
Alexander Afanasyev284257b2014-04-11 14:16:51 -070016Include the following license boilerplate into all `.hpp` and `.cpp` files:
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080017
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070018 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento84c65c02017-07-05 18:40:34 +000019 /*
Davide Pesavento08b91c82019-04-13 19:42:10 -040020 * Copyright (c) [Year(s)], [Copyright Holder(s)].
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070021 *
22 * This file is part of NFD (Named Data Networking Forwarding Daemon).
23 * See AUTHORS.md for complete list of NFD authors and contributors.
24 *
25 * NFD is free software: you can redistribute it and/or modify it under the terms
26 * of the GNU General Public License as published by the Free Software Foundation,
27 * either version 3 of the License, or (at your option) any later version.
28 *
29 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
30 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31 * PURPOSE. See the GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License along with
34 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Alexander Afanasyev4a771362014-04-24 21:29:33 -070035 */
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080036
Alexander Afanasyev319f2c82015-01-07 14:56:53 -080037If you are affiliated to an NSF-supported NDN project institution, please use the [NDN Team License
Eric Newberry81a9a862016-12-27 22:59:27 -070038Boilerplate](https://redmine.named-data.net/projects/nfd/wiki/NDN_Team_License_Boilerplate_(NFD)).
Alexander Afanasyev319f2c82015-01-07 14:56:53 -080039
Davide Pesavento2840dbc2019-04-16 23:14:21 -040040## Logging
41
42Fine-grained per-module logging can be configured via the `NDN_LOG` environment variable.
43This is especially useful when running unit tests or tools such as `nfdc` that do not
44have a configuration file. See `ndn-log(7)` manual page for syntax and examples.
45
46## Unit tests
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080047
48To run unit tests, NFD needs to be configured and build with unit test support:
49
Davide Pesavento08b91c82019-04-13 19:42:10 -040050 ./waf configure --with-tests # --debug is also strongly recommended while developing
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080051 ./waf
52
Davide Pesavento08b91c82019-04-13 19:42:10 -040053The simplest way to run the tests is to launch the compiled binary without any parameters:
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080054
Alexander Afanasyev284257b2014-04-11 14:16:51 -070055 # Run core tests
56 ./build/unit-tests-core
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080057
Davide Pesavento08b91c82019-04-13 19:42:10 -040058 # Run NFD daemon tests
Alexander Afanasyev284257b2014-04-11 14:16:51 -070059 ./build/unit-tests-daemon
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080060
Alexander Afanasyev284257b2014-04-11 14:16:51 -070061 # Run NFD RIB management tests
62 ./build/unit-tests-rib
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080063
Davide Pesavento17521592020-05-14 19:01:32 -040064The [Boost.Test framework](https://www.boost.org/doc/libs/1_65_1/libs/test/doc/html/index.html)
Alexander Afanasyev284257b2014-04-11 14:16:51 -070065is very flexible and allows a number of run-time customization of what tests should be run.
66For example, it is possible to choose to run only a specific test suite, only a specific
67test case within a suite, or specific test cases within specific test suites:
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080068
Davide Pesavento17521592020-05-14 19:01:32 -040069 # Run only the TCP Face test suite of NFD daemon tests
Alexander Afanasyev284257b2014-04-11 14:16:51 -070070 ./build/unit-tests-daemon -t FaceTcp
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080071
Alexander Afanasyev284257b2014-04-11 14:16:51 -070072 # Run only test case EndToEnd4 from the same test suite
73 ./build/unit-tests-daemon -t FaceTcp/EndToEnd4
74
75 # Run Basic test case from all core test suites
76 ./build/unit-tests-core -t */Basic
77
78By default, Boost.Test framework will produce verbose output only when a test case fails.
79If it is desired to see verbose output (result of each test assertion), add `-l all`
Davide Pesavento08b91c82019-04-13 19:42:10 -040080option to `./build/unit-tests` command. To see test progress, you can use `-l test_suite`,
81or `-p` to show a progress bar:
Alexander Afanasyev284257b2014-04-11 14:16:51 -070082
83 # Show report all log messages including the passed test notification
84 ./build/unit-tests-daemon -l all
85
86 # Show test suite messages
87 ./build/unit-tests-daemon -l test_suite
88
89 # Show nothing
90 ./build/unit-tests-daemon -l nothing
91
92 # Show progress bar
93 ./build/unit-tests-core -p
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080094
Davide Pesavento08b91c82019-04-13 19:42:10 -040095There are many more command line options available, information about which can be obtained
Davide Pesavento17521592020-05-14 19:01:32 -040096either from the command line using the `--help` switch, or online on the
97[Boost.Test website](https://www.boost.org/doc/libs/1_65_1/libs/test/doc/html/index.html).