diff --git a/doc/manual/source/how-to-write-tests.rst b/doc/manual/source/how-to-write-tests.rst index 374c47831..091add68e 100644 --- a/doc/manual/source/how-to-write-tests.rst +++ b/doc/manual/source/how-to-write-tests.rst @@ -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. diff --git a/src/antenna/wscript b/src/antenna/wscript index 59a6ea0af..33f5c4f1f 100644 --- a/src/antenna/wscript +++ b/src/antenna/wscript @@ -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 = [ diff --git a/src/aodv/wscript b/src/aodv/wscript index 66062c1a9..a73f12693 100644 --- a/src/aodv/wscript +++ b/src/aodv/wscript @@ -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 = [ diff --git a/src/applications/wscript b/src/applications/wscript index 97edfd47c..68528ec8c 100644 --- a/src/applications/wscript +++ b/src/applications/wscript @@ -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 = [ diff --git a/src/brite/wscript b/src/brite/wscript index ea1da8f69..06a83ae6b 100644 --- a/src/brite/wscript +++ b/src/brite/wscript @@ -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']) diff --git a/src/buildings/wscript b/src/buildings/wscript index 6db8841ea..6a7c356b4 100644 --- a/src/buildings/wscript +++ b/src/buildings/wscript @@ -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 = [ diff --git a/src/click/wscript b/src/click/wscript index e945cc863..6740cce50 100644 --- a/src/click/wscript +++ b/src/click/wscript @@ -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']) diff --git a/src/core/model/example-as-test.h b/src/core/model/example-as-test.h index 2c2de0266..beb610463 100644 --- a/src/core/model/example-as-test.h +++ b/src/core/model/example-as-test.h @@ -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. diff --git a/src/core/wscript b/src/core/wscript index f33dfd679..3cb6b5e48 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -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' diff --git a/src/dsdv/wscript b/src/dsdv/wscript index bf01773f1..3279875eb 100644 --- a/src/dsdv/wscript +++ b/src/dsdv/wscript @@ -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 = [ diff --git a/src/dsr/wscript b/src/dsr/wscript index f3b374e76..00ce617e4 100644 --- a/src/dsr/wscript +++ b/src/dsr/wscript @@ -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 = [ diff --git a/src/energy/wscript b/src/energy/wscript index 7ae10207a..a77079556 100644 --- a/src/energy/wscript +++ b/src/energy/wscript @@ -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 = [ diff --git a/src/flow-monitor/wscript b/src/flow-monitor/wscript index 9d55766f0..2f3ed77ad 100644 --- a/src/flow-monitor/wscript +++ b/src/flow-monitor/wscript @@ -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 [ diff --git a/src/internet-apps/wscript b/src/internet-apps/wscript index 3224b048a..07128f9a9 100644 --- a/src/internet-apps/wscript +++ b/src/internet-apps/wscript @@ -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 = [ diff --git a/src/internet/wscript b/src/internet/wscript index c320e0fbc..8357fecbb 100644 --- a/src/internet/wscript +++ b/src/internet/wscript @@ -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 = [ diff --git a/src/lr-wpan/wscript b/src/lr-wpan/wscript index bd19b803f..c7834dd93 100644 --- a/src/lr-wpan/wscript +++ b/src/lr-wpan/wscript @@ -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 = [ diff --git a/src/lte/wscript b/src/lte/wscript index 13eac0081..fd861399e 100644 --- a/src/lte/wscript +++ b/src/lte/wscript @@ -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 = [ diff --git a/src/mesh/wscript b/src/mesh/wscript index 41e0be31e..8e41d34d8 100644 --- a/src/mesh/wscript +++ b/src/mesh/wscript @@ -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 = [ diff --git a/src/mobility/wscript b/src/mobility/wscript index c7acc5994..05a3b4ab6 100644 --- a/src/mobility/wscript +++ b/src/mobility/wscript @@ -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 = [ diff --git a/src/netanim/wscript b/src/netanim/wscript index d4ceba373..af3f6541e 100644 --- a/src/netanim/wscript +++ b/src/netanim/wscript @@ -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', ] diff --git a/src/network/wscript b/src/network/wscript index be77c6975..8edae37a2 100644 --- a/src/network/wscript +++ b/src/network/wscript @@ -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 = [ diff --git a/src/olsr/wscript b/src/olsr/wscript index 219fff1fa..999e39cea 100644 --- a/src/olsr/wscript +++ b/src/olsr/wscript @@ -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 = [ diff --git a/src/openflow/wscript b/src/openflow/wscript index add7a22d2..98b7ee65e 100644 --- a/src/openflow/wscript +++ b/src/openflow/wscript @@ -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()) diff --git a/src/point-to-point/wscript b/src/point-to-point/wscript index febc60243..014004ebd 100644 --- a/src/point-to-point/wscript +++ b/src/point-to-point/wscript @@ -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 = [ diff --git a/src/propagation/wscript b/src/propagation/wscript index d714ab30e..6c72422af 100644 --- a/src/propagation/wscript +++ b/src/propagation/wscript @@ -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 = [ diff --git a/src/sixlowpan/wscript b/src/sixlowpan/wscript index 99db4f979..b932992e0 100644 --- a/src/sixlowpan/wscript +++ b/src/sixlowpan/wscript @@ -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() \ No newline at end of file + bld.ns3_python_bindings() diff --git a/src/spectrum/wscript b/src/spectrum/wscript index ced7f1f81..bbf910457 100644 --- a/src/spectrum/wscript +++ b/src/spectrum/wscript @@ -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 = [ diff --git a/src/stats/wscript b/src/stats/wscript index 6a187e6a8..c4794ed52 100644 --- a/src/stats/wscript +++ b/src/stats/wscript @@ -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 = [ diff --git a/src/test/wscript b/src/test/wscript index 2008bc02a..118c388db 100644 --- a/src/test/wscript +++ b/src/test/wscript @@ -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', + ]) + + diff --git a/src/topology-read/wscript b/src/topology-read/wscript index d550e7f38..e915452af 100644 --- a/src/topology-read/wscript +++ b/src/topology-read/wscript @@ -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 = [ diff --git a/src/traffic-control/wscript b/src/traffic-control/wscript index 63f065e4f..0646addba 100644 --- a/src/traffic-control/wscript +++ b/src/traffic-control/wscript @@ -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 = [ diff --git a/src/uan/wscript b/src/uan/wscript index 8642c579a..b89b38bbc 100644 --- a/src/uan/wscript +++ b/src/uan/wscript @@ -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 = [ diff --git a/src/wave/wscript b/src/wave/wscript index 9e1152d96..b8d4d21ac 100644 --- a/src/wave/wscript +++ b/src/wave/wscript @@ -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 = [ diff --git a/src/wifi/wscript b/src/wifi/wscript index 3fd66f98d..220ab02d7 100644 --- a/src/wifi/wscript +++ b/src/wifi/wscript @@ -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 = [ diff --git a/src/wimax/wscript b/src/wimax/wscript index 975f619f7..5de9973fa 100644 --- a/src/wimax/wscript +++ b/src/wimax/wscript @@ -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 = [ diff --git a/utils/create-module.py b/utils/create-module.py index 385061228..bc464e7f2 100755 --- a/utils/create-module.py +++ b/utils/create-module.py @@ -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}