Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 2 | """ |
Davide Pesavento | caa60cc | 2024-02-18 18:18:37 -0500 | [diff] [blame] | 3 | Copyright (c) 2014-2024, Regents of the University of California, |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 4 | Arizona Board of Regents, |
| 5 | Colorado State University, |
| 6 | University Pierre & Marie Curie, Sorbonne University, |
| 7 | Washington University in St. Louis, |
| 8 | Beijing Institute of Technology, |
| 9 | The University of Memphis. |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 10 | |
| 11 | This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | |
| 14 | NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | of the GNU General Public License as published by the Free Software Foundation, |
| 16 | either version 3 of the License, or (at your option) any later version. |
| 17 | |
| 18 | NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | PURPOSE. See the GNU General Public License for more details. |
| 21 | |
| 22 | You should have received a copy of the GNU General Public License along with |
| 23 | NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | """ |
| 25 | |
| 26 | top = '..' |
| 27 | |
| 28 | def build(bld): |
| 29 | # Unit tests |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 30 | if bld.env.WITH_TESTS: |
Davide Pesavento | 152874a | 2024-02-20 22:07:07 -0500 | [diff] [blame^] | 31 | tmpdir = 'UNIT_TESTS_TMPDIR="%s"' % bld.bldnode.make_node('tests-tmp') |
Alexander Afanasyev | 58ea458 | 2014-05-30 08:38:56 +0300 | [diff] [blame] | 32 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 33 | # common test objects |
| 34 | bld.objects( |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 35 | target='tests-common', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 36 | features='pch', |
| 37 | source=bld.path.ant_glob('*.cpp', excl='main.cpp'), |
Davide Pesavento | a9e1ab2 | 2023-10-02 22:10:45 -0400 | [diff] [blame] | 38 | use='BOOST_TESTS core-objects', |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 39 | headers='../core/common.hpp boost-test.hpp', |
Davide Pesavento | 2135375 | 2020-11-20 00:43:44 -0500 | [diff] [blame] | 40 | defines=[tmpdir]) |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 41 | |
Davide Pesavento | caa60cc | 2024-02-18 18:18:37 -0500 | [diff] [blame] | 42 | for module in ['core', 'daemon', 'tools']: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 43 | # main() for the module |
Davide Pesavento | caa60cc | 2024-02-18 18:18:37 -0500 | [diff] [blame] | 44 | bld.objects( |
| 45 | target=f'unit-tests-{module}-main', |
| 46 | source='main.cpp', |
| 47 | use='BOOST_TESTS', |
| 48 | defines=[f'BOOST_TEST_MODULE=NFD {module.capitalize()}']) |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 49 | |
Davide Pesavento | caa60cc | 2024-02-18 18:18:37 -0500 | [diff] [blame] | 50 | node = bld.path.find_dir(module) |
| 51 | src = node.ant_glob('**/*.cpp', |
| 52 | excl=['face/*ethernet*.cpp', |
| 53 | 'face/pcap*.cpp', |
| 54 | 'face/unix*.cpp', |
| 55 | 'face/websocket*.cpp']) |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 56 | if bld.env.HAVE_LIBPCAP: |
| 57 | src += node.ant_glob('face/*ethernet*.cpp') |
| 58 | src += node.ant_glob('face/pcap*.cpp') |
| 59 | if bld.env.HAVE_UNIX_SOCKETS: |
| 60 | src += node.ant_glob('face/unix*.cpp') |
| 61 | if bld.env.HAVE_WEBSOCKET: |
| 62 | src += node.ant_glob('face/websocket*.cpp') |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 63 | |
Davide Pesavento | 1b077f6 | 2019-02-19 19:19:44 -0500 | [diff] [blame] | 64 | # unit-tests binary for the module |
Davide Pesavento | caa60cc | 2024-02-18 18:18:37 -0500 | [diff] [blame] | 65 | bld.program( |
| 66 | name=f'unit-tests-{module}', |
| 67 | target=f'{top}/unit-tests-{module}', |
| 68 | source=src, |
| 69 | use=f'{module}-objects tests-common unit-tests-{module}-main', |
| 70 | defines=[tmpdir], |
| 71 | install_path=None) |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 72 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 73 | # Other tests (e.g., stress tests and benchmarks that can be enabled even if unit tests are disabled) |
| 74 | if bld.env.WITH_TESTS or bld.env.WITH_OTHER_TESTS: |
| 75 | bld.recurse('other') |