blob: cf28718bfc4b45522432566466aae8033ed51049 [file] [log] [blame]
Alexander Afanasyev613e2a92014-04-15 13:36:58 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyev613e2a92014-04-15 13:36:58 -07002"""
Davide Pesavento17521592020-05-14 19:01:32 -04003Copyright (c) 2014-2020, Regents of the University of California,
Junxiao Shi9f5b01d2016-08-05 03:54:28 +00004 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 Afanasyev613e2a92014-04-15 13:36:58 -070010
11This file is part of NFD (Named Data Networking Forwarding Daemon).
12See AUTHORS.md for complete list of NFD authors and contributors.
13
14NFD is free software: you can redistribute it and/or modify it under the terms
15of the GNU General Public License as published by the Free Software Foundation,
16either version 3 of the License, or (at your option) any later version.
17
18NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20PURPOSE. See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License along with
23NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24"""
25
26top = '..'
27
28def build(bld):
29 # Unit tests
Davide Pesavento0064c1d2018-03-03 18:43:53 -050030 if bld.env.WITH_TESTS:
Davide Pesavento21353752020-11-20 00:43:44 -050031 tmpdir = 'UNIT_TESTS_TMPDIR="%s"' % bld.bldnode.make_node('tmp-files')
Alexander Afanasyev58ea4582014-05-30 08:38:56 +030032
Davide Pesavento0064c1d2018-03-03 18:43:53 -050033 # common test objects
34 bld.objects(
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040035 target='tests-common',
Davide Pesavento0064c1d2018-03-03 18:43:53 -050036 features='pch',
37 source=bld.path.ant_glob('*.cpp', excl='main.cpp'),
Alexander Afanasyev58ea4582014-05-30 08:38:56 +030038 use='core-objects',
Junxiao Shi9f5b01d2016-08-05 03:54:28 +000039 headers='../core/common.hpp boost-test.hpp',
Davide Pesavento21353752020-11-20 00:43:44 -050040 defines=[tmpdir])
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070041
Davide Pesavento17521592020-05-14 19:01:32 -040042 for module in ['core', 'daemon', 'rib', 'tools']:
Davide Pesavento0064c1d2018-03-03 18:43:53 -050043 # main() for the module
44 bld.objects(target='unit-tests-%s-main' % module,
45 source='main.cpp',
46 use='BOOST',
Davide Pesavento17521592020-05-14 19:01:32 -040047 defines=['BOOST_TEST_MODULE=NFD %s' % module.capitalize()])
Davide Pesavento0064c1d2018-03-03 18:43:53 -050048
Davide Pesavento1b077f62019-02-19 19:19:44 -050049 subdir = 'daemon/rib' if module == 'rib' else module
50 node = bld.path.find_dir(subdir)
Davide Pesavento0064c1d2018-03-03 18:43:53 -050051 src = node.ant_glob('**/*.cpp', excl=['face/*ethernet*.cpp',
52 'face/pcap*.cpp',
53 'face/unix*.cpp',
54 'face/websocket*.cpp'])
55 if bld.env.HAVE_LIBPCAP:
56 src += node.ant_glob('face/*ethernet*.cpp')
57 src += node.ant_glob('face/pcap*.cpp')
58 if bld.env.HAVE_UNIX_SOCKETS:
59 src += node.ant_glob('face/unix*.cpp')
60 if bld.env.HAVE_WEBSOCKET:
61 src += node.ant_glob('face/websocket*.cpp')
Davide Pesavento3dade002019-03-19 11:29:56 -060062 if module == 'rib':
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040063 src += ['daemon/global-io-fixture.cpp',
64 'daemon/limited-io.cpp',
65 'daemon/rib-io-fixture.cpp']
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070066
Davide Pesavento1b077f62019-02-19 19:19:44 -050067 objmod = 'daemon' if module == 'rib' else module
68 # unit-tests binary for the module
69 bld.program(name='unit-tests-%s' % module,
70 target='../unit-tests-%s' % module,
71 source=src,
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040072 use='%s-objects tests-common unit-tests-%s-main' % (objmod, module),
Davide Pesavento21353752020-11-20 00:43:44 -050073 defines=[tmpdir],
Davide Pesavento1b077f62019-02-19 19:19:44 -050074 install_path=None)
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070075
Davide Pesavento0064c1d2018-03-03 18:43:53 -050076 # Other tests (e.g., stress tests and benchmarks that can be enabled even if unit tests are disabled)
77 if bld.env.WITH_TESTS or bld.env.WITH_OTHER_TESTS:
78 bld.recurse('other')