blob: bda38c0050431b953a736895907675c0ea978908 [file] [log] [blame] [view]
Davide Pesaventof3e84872024-03-15 15:30:06 -04001# Notes for ndn-cxx developers
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07002
Davide Pesaventoae39daf2023-02-14 23:46:46 -05003If you are new to the NDN software community, please read our
4[Contributor's Guide](https://github.com/named-data/.github/blob/main/CONTRIBUTING.md).
Nick Gordonfe13f562017-12-21 14:12:37 -06005
Davide Pesaventof3e84872024-03-15 15:30:06 -04006## Code style
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07007
Davide Pesavento02ed3322023-02-23 19:40:22 -05008ndn-cxx code is subject to [ndn-cxx code style](https://docs.named-data.net/ndn-cxx/current/code-style.html).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07009
Davide Pesaventof3e84872024-03-15 15:30:06 -040010## Licensing
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070011
Davide Pesaventoae39daf2023-02-14 23:46:46 -050012Contributions to ndn-cxx must be licensed under the LGPL v3 or a compatible license.
13If you choose the LGPL v3, please use the following license boilerplate in all `.hpp`
14and `.cpp` files:
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070015
Davide Pesaventof3e84872024-03-15 15:30:06 -040016```cpp
17/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
18/*
19 * Copyright (c) [Year(s)], [Copyright Holder(s)].
20 *
21 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
22 *
23 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
24 * terms of the GNU Lesser General Public License as published by the Free Software
25 * Foundation, either version 3 of the License, or (at your option) any later version.
26 *
27 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
28 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
29 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
30 *
31 * You should have received copies of the GNU General Public License and GNU Lesser
32 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
33 * <http://www.gnu.org/licenses/>.
34 *
35 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
36 */
37```
Alexander Afanasyevaf99f462015-01-19 21:43:09 -080038
39If you are affiliated to an NSF-supported NDN project institution, please use the [NDN Team License
Davide Pesavento0530b5b2016-11-07 03:23:58 +010040Boilerplate](https://redmine.named-data.net/projects/ndn-cxx/wiki/NDN_Team_License_Boilerplate_(ndn-cxx)).
Alexander Afanasyevcf490552016-06-27 22:51:36 -070041
Davide Pesaventof3e84872024-03-15 15:30:06 -040042## Unit tests
Alexander Afanasyevcf490552016-06-27 22:51:36 -070043
Davide Pesavento534b8412018-12-08 19:19:09 -050044To run the unit tests, ndn-cxx needs to be built with unit test support and installed
Alexander Afanasyevcf490552016-06-27 22:51:36 -070045into the configured location. For example:
46
Davide Pesaventof3e84872024-03-15 15:30:06 -040047```shell
48./waf configure --with-tests # --debug is also strongly recommended while developing
49./waf
50sudo ./waf install
51```
Alexander Afanasyevcf490552016-06-27 22:51:36 -070052
Davide Pesaventof3e84872024-03-15 15:30:06 -040053> [!TIP]
54> On Linux you may also need to run `sudo ldconfig` to reconfigure the dynamic linker bindings.
Alexander Afanasyevcf490552016-06-27 22:51:36 -070055
Davide Pesavento534b8412018-12-08 19:19:09 -050056The simplest way to run the tests is to launch the compiled binary without any parameters:
Alexander Afanasyevcf490552016-06-27 22:51:36 -070057
Davide Pesaventof3e84872024-03-15 15:30:06 -040058```shell
59./build/unit-tests
60```
Alexander Afanasyevcf490552016-06-27 22:51:36 -070061
Davide Pesavento550d8c92023-11-05 01:30:01 -040062The [Boost.Test framework](https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/index.html)
Alexander Afanasyevcf490552016-06-27 22:51:36 -070063is very flexible and allows a number of run-time customization of what tests should be run.
64For example, it is possible to choose to run only a specific test suite, only a specific
Davide Pesaventof3e84872024-03-15 15:30:06 -040065test case within a suite, specific test cases across multiple test suites, and so on:
Alexander Afanasyevcf490552016-06-27 22:51:36 -070066
Davide Pesaventof3e84872024-03-15 15:30:06 -040067```shell
68# Run all the test cases inside the Face test suite (tests/unit/face.t.cpp)
69./build/unit-tests -t TestFace
Alexander Afanasyevcf490552016-06-27 22:51:36 -070070
Davide Pesaventof3e84872024-03-15 15:30:06 -040071# Run only the test case "ExpressInterestData" from the previous test suite
72./build/unit-tests -t TestFace/ExpressInterestData
Alexander Afanasyevcf490552016-06-27 22:51:36 -070073
Davide Pesaventof3e84872024-03-15 15:30:06 -040074# Run the "Basic" test case from all test suites
75./build/unit-tests -t */Basic
76```
Alexander Afanasyevcf490552016-06-27 22:51:36 -070077
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 Pesavento534b8412018-12-08 19:19:09 -050080option to `./build/unit-tests` command. To see test progress, you can use `-l test_suite`,
81or `-p` to show a progress bar:
Alexander Afanasyevcf490552016-06-27 22:51:36 -070082
Davide Pesaventof3e84872024-03-15 15:30:06 -040083```shell
84# Show report all log messages including the passed test notification
85./build/unit-tests -l all
Alexander Afanasyevcf490552016-06-27 22:51:36 -070086
Davide Pesaventof3e84872024-03-15 15:30:06 -040087# Show test suite messages
88./build/unit-tests -l test_suite
Alexander Afanasyevcf490552016-06-27 22:51:36 -070089
Davide Pesaventof3e84872024-03-15 15:30:06 -040090# Show nothing
91./build/unit-tests -l nothing
Alexander Afanasyevcf490552016-06-27 22:51:36 -070092
Davide Pesaventof3e84872024-03-15 15:30:06 -040093# Show progress bar
94./build/unit-tests -p
95```
Alexander Afanasyevcf490552016-06-27 22:51:36 -070096
97There are many more command line options available, information about which can be obtained
Davide Pesavento78338c52020-04-20 23:00:02 -040098either from the command line using the `--help` switch, or online on the
Davide Pesavento550d8c92023-11-05 01:30:01 -040099[Boost.Test website](https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/runtime_config.html).
Alexander Afanasyevcf490552016-06-27 22:51:36 -0700100
Davide Pesaventof3e84872024-03-15 15:30:06 -0400101> [!WARNING]
102> If you have a customized `client.conf` in `~/.ndn`, `/etc/ndn`, or `/usr/local/etc/ndn`
103> (or any other `SYSCONFDIR/ndn` if you passed `--sysconfdir` to `./waf configure`),
104> Face-related test cases may fail.