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; -*- |
| 2 | |
| 3 | """ |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 4 | Copyright (c) 2014-2016, 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 | The University of Memphis. |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 11 | |
| 12 | This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 13 | See AUTHORS.md for complete list of NFD authors and contributors. |
| 14 | |
| 15 | NFD is free software: you can redistribute it and/or modify it under the terms |
| 16 | of the GNU General Public License as published by the Free Software Foundation, |
| 17 | either version 3 of the License, or (at your option) any later version. |
| 18 | |
| 19 | NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 20 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 21 | PURPOSE. See the GNU General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License along with |
| 24 | NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 25 | """ |
| 26 | |
| 27 | top = '..' |
| 28 | |
| 29 | def build(bld): |
| 30 | # Unit tests |
| 31 | if bld.env['WITH_TESTS']: |
Alexander Afanasyev | 58ea458 | 2014-05-30 08:38:56 +0300 | [diff] [blame] | 32 | |
| 33 | # common test modules |
| 34 | unit_test_base = bld( |
| 35 | target='unit-tests-base', |
| 36 | name='unit-tests-base', |
| 37 | features='cxx pch', |
| 38 | source=bld.path.ant_glob(['*.cpp'], excl='main.cpp'), |
| 39 | use='core-objects', |
Junxiao Shi | 9f5b01d | 2016-08-05 03:54:28 +0000 | [diff] [blame] | 40 | headers='../core/common.hpp boost-test.hpp', |
Alexander Afanasyev | bc9ed49 | 2016-01-26 11:38:11 -0800 | [diff] [blame] | 41 | defines='UNIT_TEST_CONFIG_PATH=\"%s/tmp-files/\"' % bld.bldnode, |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 42 | ) |
| 43 | |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 44 | for module, name in {"core": "Core Tests", |
| 45 | "daemon": "Daemon Tests", |
| 46 | "rib": "RIB Tests", |
| 47 | "tools": "Tools Tests"}.items(): |
Alexander Afanasyev | f22ebaf | 2015-12-17 21:23:05 -0800 | [diff] [blame] | 48 | # main() |
| 49 | bld(target='unit-tests-%s-main' % module, |
| 50 | name='unit-tests-%s-main' % module, |
| 51 | features='cxx', |
| 52 | use='BOOST', |
| 53 | source='main.cpp', |
| 54 | defines=['BOOST_TEST_MODULE=%s' % name] |
| 55 | ) |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 56 | |
Alexander Afanasyev | f22ebaf | 2015-12-17 21:23:05 -0800 | [diff] [blame] | 57 | # unit-tests-%module |
| 58 | unit_tests = bld.program( |
| 59 | target='../unit-tests-%s' % module, |
| 60 | features='cxx cxxprogram', |
| 61 | source=bld.path.ant_glob(['%s/**/*.cpp' % module], |
| 62 | excl=['%s/**/ethernet*.cpp' % module, |
| 63 | '%s/**/unix*.cpp' % module, |
| 64 | '%s/**/websocket*.cpp' % module]), |
| 65 | use='%s-objects unit-tests-base unit-tests-%s-main' % (module, module), |
| 66 | includes='.', |
| 67 | install_path=None, |
Alexander Afanasyev | bc9ed49 | 2016-01-26 11:38:11 -0800 | [diff] [blame] | 68 | defines='UNIT_TEST_CONFIG_PATH=\"%s/tmp-files/\"' % bld.bldnode, |
Alexander Afanasyev | f22ebaf | 2015-12-17 21:23:05 -0800 | [diff] [blame] | 69 | ) |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 70 | |
Alexander Afanasyev | f22ebaf | 2015-12-17 21:23:05 -0800 | [diff] [blame] | 71 | if bld.env['HAVE_LIBPCAP']: |
| 72 | unit_tests.source += bld.path.ant_glob('%s/**/ethernet*.cpp' % module) |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 73 | |
Alexander Afanasyev | f22ebaf | 2015-12-17 21:23:05 -0800 | [diff] [blame] | 74 | if bld.env['HAVE_UNIX_SOCKETS']: |
| 75 | unit_tests.source += bld.path.ant_glob('%s/**/unix*.cpp' % module) |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 76 | |
Alexander Afanasyev | f22ebaf | 2015-12-17 21:23:05 -0800 | [diff] [blame] | 77 | if bld.env['HAVE_WEBSOCKET']: |
| 78 | unit_tests.source += bld.path.ant_glob('%s/**/websocket*.cpp' % module) |
Alexander Afanasyev | 3ecec50 | 2014-04-16 13:42:44 -0700 | [diff] [blame] | 79 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 80 | # Other tests (e.g., stress tests that can be enabled even if unit tests are disabled) |
| 81 | if bld.env['WITH_TESTS'] or bld.env['WITH_OTHER_TESTS']: |
| 82 | bld.recurse("other") |