Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 1 | # Notes for ndn-cxx developers |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 2 | |
Davide Pesavento | ae39daf | 2023-02-14 23:46:46 -0500 | [diff] [blame] | 3 | If 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 Gordon | fe13f56 | 2017-12-21 14:12:37 -0600 | [diff] [blame] | 5 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 6 | ## Code style |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 7 | |
Davide Pesavento | 02ed332 | 2023-02-23 19:40:22 -0500 | [diff] [blame] | 8 | ndn-cxx code is subject to [ndn-cxx code style](https://docs.named-data.net/ndn-cxx/current/code-style.html). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 9 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 10 | ## Licensing |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 11 | |
Davide Pesavento | ae39daf | 2023-02-14 23:46:46 -0500 | [diff] [blame] | 12 | Contributions to ndn-cxx must be licensed under the LGPL v3 or a compatible license. |
| 13 | If you choose the LGPL v3, please use the following license boilerplate in all `.hpp` |
| 14 | and `.cpp` files: |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 15 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 16 | ```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 Afanasyev | af99f46 | 2015-01-19 21:43:09 -0800 | [diff] [blame] | 38 | |
| 39 | If you are affiliated to an NSF-supported NDN project institution, please use the [NDN Team License |
Davide Pesavento | 0530b5b | 2016-11-07 03:23:58 +0100 | [diff] [blame] | 40 | Boilerplate](https://redmine.named-data.net/projects/ndn-cxx/wiki/NDN_Team_License_Boilerplate_(ndn-cxx)). |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 41 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 42 | ## Unit tests |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 43 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 44 | To run the unit tests, ndn-cxx needs to be built with unit test support and installed |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 45 | into the configured location. For example: |
| 46 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 47 | ```shell |
| 48 | ./waf configure --with-tests # --debug is also strongly recommended while developing |
| 49 | ./waf |
| 50 | sudo ./waf install |
| 51 | ``` |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 52 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 53 | > [!TIP] |
| 54 | > On Linux you may also need to run `sudo ldconfig` to reconfigure the dynamic linker bindings. |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 55 | |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 56 | The simplest way to run the tests is to launch the compiled binary without any parameters: |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 57 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 58 | ```shell |
| 59 | ./build/unit-tests |
| 60 | ``` |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 61 | |
Davide Pesavento | 550d8c9 | 2023-11-05 01:30:01 -0400 | [diff] [blame] | 62 | The [Boost.Test framework](https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/index.html) |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 63 | is very flexible and allows a number of run-time customization of what tests should be run. |
| 64 | For example, it is possible to choose to run only a specific test suite, only a specific |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 65 | test case within a suite, specific test cases across multiple test suites, and so on: |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 66 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 67 | ```shell |
| 68 | # Run all the test cases inside the Face test suite (tests/unit/face.t.cpp) |
| 69 | ./build/unit-tests -t TestFace |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 70 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 71 | # Run only the test case "ExpressInterestData" from the previous test suite |
| 72 | ./build/unit-tests -t TestFace/ExpressInterestData |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 73 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 74 | # Run the "Basic" test case from all test suites |
| 75 | ./build/unit-tests -t */Basic |
| 76 | ``` |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 77 | |
| 78 | By default, Boost.Test framework will produce verbose output only when a test case fails. |
| 79 | If it is desired to see verbose output (result of each test assertion), add `-l all` |
Davide Pesavento | 534b841 | 2018-12-08 19:19:09 -0500 | [diff] [blame] | 80 | option to `./build/unit-tests` command. To see test progress, you can use `-l test_suite`, |
| 81 | or `-p` to show a progress bar: |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 82 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 83 | ```shell |
| 84 | # Show report all log messages including the passed test notification |
| 85 | ./build/unit-tests -l all |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 86 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 87 | # Show test suite messages |
| 88 | ./build/unit-tests -l test_suite |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 89 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 90 | # Show nothing |
| 91 | ./build/unit-tests -l nothing |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 92 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 93 | # Show progress bar |
| 94 | ./build/unit-tests -p |
| 95 | ``` |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 96 | |
| 97 | There are many more command line options available, information about which can be obtained |
Davide Pesavento | 78338c5 | 2020-04-20 23:00:02 -0400 | [diff] [blame] | 98 | either from the command line using the `--help` switch, or online on the |
Davide Pesavento | 550d8c9 | 2023-11-05 01:30:01 -0400 | [diff] [blame] | 99 | [Boost.Test website](https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/runtime_config.html). |
Alexander Afanasyev | cf49055 | 2016-06-27 22:51:36 -0700 | [diff] [blame] | 100 | |
Davide Pesavento | f3e8487 | 2024-03-15 15:30:06 -0400 | [diff] [blame] | 101 | > [!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. |