blob: 3b9e628baef83bbc98af1789845ade32c413be2d [file] [log] [blame]
Alexander Afanasyev613e2a92014-04-15 13:36:58 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
3"""
4Copyright (c) 2014 Regents of the University of California,
5 Arizona Board of Regents,
6 Colorado State University,
7 University Pierre & Marie Curie, Sorbonne University,
8 Washington University in St. Louis,
9 Beijing Institute of Technology
10
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
30 if bld.env['WITH_TESTS']:
Alexander Afanasyev58ea4582014-05-30 08:38:56 +030031
32 # common test modules
33 unit_test_base = bld(
34 target='unit-tests-base',
35 name='unit-tests-base',
36 features='cxx pch',
37 source=bld.path.ant_glob(['*.cpp'], excl='main.cpp'),
38 use='core-objects',
39 headers='../common.hpp boost-test.hpp',
Alexander Afanasyevbc9ed492016-01-26 11:38:11 -080040 defines='UNIT_TEST_CONFIG_PATH=\"%s/tmp-files/\"' % bld.bldnode,
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070041 )
42
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -080043 for module, name in {"core": "NFD Core Tests",
44 "daemon": "NFD Daemon Tests",
45 "rib": "NFD RIB Tests"}.iteritems():
46 # main()
47 bld(target='unit-tests-%s-main' % module,
48 name='unit-tests-%s-main' % module,
49 features='cxx',
50 use='BOOST',
51 source='main.cpp',
52 defines=['BOOST_TEST_MODULE=%s' % name]
53 )
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070054
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -080055 # unit-tests-%module
56 unit_tests = bld.program(
57 target='../unit-tests-%s' % module,
58 features='cxx cxxprogram',
59 source=bld.path.ant_glob(['%s/**/*.cpp' % module],
60 excl=['%s/**/ethernet*.cpp' % module,
61 '%s/**/unix*.cpp' % module,
62 '%s/**/websocket*.cpp' % module]),
63 use='%s-objects unit-tests-base unit-tests-%s-main' % (module, module),
64 includes='.',
65 install_path=None,
Alexander Afanasyevbc9ed492016-01-26 11:38:11 -080066 defines='UNIT_TEST_CONFIG_PATH=\"%s/tmp-files/\"' % bld.bldnode,
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -080067 )
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070068
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -080069 if bld.env['HAVE_LIBPCAP']:
70 unit_tests.source += bld.path.ant_glob('%s/**/ethernet*.cpp' % module)
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070071
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -080072 if bld.env['HAVE_UNIX_SOCKETS']:
73 unit_tests.source += bld.path.ant_glob('%s/**/unix*.cpp' % module)
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070074
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -080075 if bld.env['HAVE_WEBSOCKET']:
76 unit_tests.source += bld.path.ant_glob('%s/**/websocket*.cpp' % module)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070077
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070078 # Other tests (e.g., stress tests that can be enabled even if unit tests are disabled)
79 if bld.env['WITH_TESTS'] or bld.env['WITH_OTHER_TESTS']:
80 bld.recurse("other")