build: (fixes #217) Guard compilation of example used as a test

* Added documentation to ExampleAsTestSuite on the need for this guarding
* Updated with Peter's patch for examples-as-test placeholders in wscripts
This commit is contained in:
Steven Smith
2020-06-01 08:36:35 -07:00
committed by Tom Henderson
parent 6b830f9457
commit dded72e02e
36 changed files with 218 additions and 5 deletions

View File

@@ -164,7 +164,13 @@ and command line arguments for the example. In the preceding code the
same example is run twice with different arguments.
You then need to add that newly created test suite file to the list of
test sources in ``mymodule/wscript``.
test sources in ``mymodule/wscript``. Building of examples
is an option so you need to guard the inclusion of the test suite:
.. sourcecode:: python
if (bld.env['ENABLE_EXAMPLES']):
module.source.append('model/mymodule-examples-test-suite.cc')
Since you modified a wscript file you need to reconfigure and rebuild
everything.

View File

@@ -22,6 +22,12 @@ def build(bld):
'test/test-parabolic-antenna.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/antenna-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'antenna'
headers.source = [

View File

@@ -23,6 +23,12 @@ def build(bld):
'test/loopback.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
aodv_test.source.extend([
# 'test/aodv-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'aodv'
headers.source = [

View File

@@ -33,6 +33,12 @@ def build(bld):
'test/udp-client-server-test.cc'
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
applications_test.source.extend([
# 'test/applications-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'applications'
headers.source = [

View File

@@ -92,6 +92,12 @@ def build(bld):
module_test.source = [
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/brite-examples-test-suite.cc',
])
if bld.env['BRITE'] and bld.env['DL']:
module.use.extend(['BRITE', 'DL'])
module_test.use.extend(['BRITE', 'DL'])

View File

@@ -27,6 +27,12 @@ def build(bld):
'test/buildings-channel-condition-model-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/buildings-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'buildings'
headers.source = [

View File

@@ -113,6 +113,12 @@ def build(bld):
'test/ipv4-click-routing-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/click-examples-test-suite.cc',
])
if bld.env['NSCLICK'] and bld.env['DL']:
module.use.extend(['NSCLICK', 'DL'])
module_test.use.extend(['NSCLICK', 'DL'])

View File

@@ -148,7 +148,13 @@ protected:
* the same example is run twice with different arguments.
*
* You then need to add that newly created test suite file to the list
* of test sources in `mymodule/wscript`.
* of test sources in `mymodule/wscript`. Building of examples
* is an option so you need to guard the inclusion of the test suite:
*
* \code{.py}
* if (bld.env['ENABLE_EXAMPLES']):
* module.source.append('model/mymodule-examples-test-suite.cc')
* \endcode
*
* Since you modified a wscript file you need to reconfigure and
* rebuild everything.

View File

@@ -246,7 +246,9 @@ def build(bld):
]
if (bld.env['ENABLE_EXAMPLES']):
core_test.source.append('test/examples-as-tests-test-suite.cc')
core_test.source.extend([
'test/examples-as-tests-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'core'

View File

@@ -16,6 +16,12 @@ def build(bld):
'test/dsdv-testcase.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/dsdv-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'dsdv'
headers.source = [

View File

@@ -25,6 +25,12 @@ def build(bld):
'test/dsr-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/dsr-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'dsr'
headers.source = [

View File

@@ -28,6 +28,12 @@ def build(bld):
'test/basic-energy-harvester-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
obj_test.source.extend([
# 'test/energy-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'energy'
headers.source = [

View File

@@ -19,6 +19,12 @@ def build(bld):
'test/histogram-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/flow-monitor-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'flow-monitor'
headers.source = ["model/%s" % s for s in [

View File

@@ -30,6 +30,12 @@ def build(bld):
'test/dhcp-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
applications_test.source.extend([
# 'test/internet-apps-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'internet-apps'
headers.source = [

View File

@@ -303,6 +303,12 @@ def build(bld):
'test/tcp-dctcp-test.cc',
'test/tcp-syn-connection-failed-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
internet_test.source.extend([
# 'test/internet-examples-test-suite.cc',
])
privateheaders = bld(features='ns3privateheader')
privateheaders.module = 'internet'
privateheaders.source = [

View File

@@ -33,6 +33,12 @@ def build(bld):
'test/lr-wpan-slotted-csmaca-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/lr-wpan-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'lr-wpan'
headers.source = [

View File

@@ -197,6 +197,12 @@ def build(bld):
'test/lte-test-radio-link-failure.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/lte-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'lte'
headers.source = [

View File

@@ -54,6 +54,12 @@ def build(bld):
'test/flame/regression.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
obj_test.source.extend([
# 'test/mesh-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'mesh'
headers.source = [

View File

@@ -36,6 +36,12 @@ def build(bld):
'test/box-line-intersection-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
mobility_test.source.extend([
# 'test/mobility-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'mobility'
headers.source = [

View File

@@ -11,6 +11,12 @@ def build (bld) :
module.source = [ 'model/animation-interface.cc', ]
netanim_test = bld.create_ns3_module_test_library('netanim')
netanim_test.source = ['test/netanim-test.cc', ]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
netanim_test.source.extend([
# 'test/netanim-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'netanim'
headers.source = ['model/animation-interface.h', ]

View File

@@ -86,6 +86,12 @@ def build(bld):
'test/packet-socket-apps-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
network_test.source.extend([
# 'test/network-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'network'
headers.source = [

View File

@@ -20,6 +20,12 @@ def build(bld):
'test/tc-regression-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/olsr-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'olsr'
headers.source = [

View File

@@ -160,6 +160,12 @@ def build(bld):
obj_test.source = [
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
obj_test.source.extend([
# 'test/openflow-examples-test-suite.cc',
])
if bld.env['OPENFLOW'] and bld.env['DL'] and bld.env['XML2']:
obj.use.extend('OPENFLOW DL XML2'.split())
obj_test.use.extend('OPENFLOW DL XML2'.split())

View File

@@ -20,6 +20,12 @@ def build(bld):
'test/point-to-point-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/point-to-point-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'point-to-point'
headers.source = [

View File

@@ -28,6 +28,12 @@ def build(bld):
'test/three-gpp-propagation-loss-model-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/propagation-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'propagation'
headers.source = [

View File

@@ -14,9 +14,15 @@ def build(bld):
'test/sixlowpan-hc1-test.cc',
'test/sixlowpan-iphc-test.cc',
'test/sixlowpan-fragmentation-test.cc',
'test/sixlowpan-examples-test-suite.cc',
]
# This suite runs an example, only include if examples are built
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
'test/sixlowpan-examples-test-suite.cc',
])
headers = bld(features=['ns3header'])
headers.module = 'sixlowpan'
headers.source = [
@@ -29,4 +35,4 @@ def build(bld):
if (bld.env['ENABLE_EXAMPLES']):
bld.recurse('examples')
bld.ns3_python_bindings()
bld.ns3_python_bindings()

View File

@@ -51,6 +51,12 @@ def build(bld):
'test/three-gpp-channel-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/spectrum-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'spectrum'
headers.source = [

View File

@@ -45,6 +45,12 @@ def build(bld):
'test/double-probe-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/stats-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'stats'
headers.source = [

View File

@@ -46,3 +46,10 @@ def build(bld):
'traced/traced-value-callback-typedef-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
test_test.source.extend([
# 'test/test-examples-test-suite.cc',
])

View File

@@ -15,6 +15,12 @@ def build(bld):
'test/rocketfuel-topology-reader-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/topology-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'topology-read'
headers.source = [

View File

@@ -40,6 +40,12 @@ def build(bld):
'test/cobalt-queue-disc-test-suite.cc'
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/traffic-control-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'traffic-control'
headers.source = [

View File

@@ -33,6 +33,13 @@ def build(bld):
'test/uan-test.cc',
'test/uan-energy-model-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/uan-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'uan'
headers.source = [

View File

@@ -33,6 +33,12 @@ def build(bld):
'test/ocb-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/wave-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'wave'
headers.source = [

View File

@@ -125,6 +125,12 @@ def build(bld):
'test/inter-bss-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
obj_test.source.extend([
# 'test/wifi-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'wifi'
headers.source = [

View File

@@ -64,6 +64,12 @@ def build(bld):
'test/wimax-fragmentation-test.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
obj_test.source.extend([
# 'test/wimax-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = 'wimax'
headers.source = [

View File

@@ -26,6 +26,11 @@ def build(bld):
module_test.source = [
'test/{MODULE}-test-suite.cc',
]
# Tests encapsulating example programs should be listed here
if (bld.env['ENABLE_EXAMPLES']):
module_test.source.extend([
# 'test/{MODULE}-examples-test-suite.cc',
])
headers = bld(features='ns3header')
headers.module = {MODULE!r}