# HG changeset patch # User Mitch Watrous # Date 1304564577 25200 # Node ID 40b3cffdda9953ef83f22e7415fb731d650f4943 # Parent db7061624ae68f800913bd1800622ab2dd6db36b Create a template module diff -r db7061624ae6 -r 40b3cffdda99 src/template/examples/wscript --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/template/examples/wscript Wed May 04 20:02:57 2011 -0700 @@ -0,0 +1,5 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + if not bld.env['ENABLE_EXAMPLES']: + return; diff -r db7061624ae6 -r 40b3cffdda99 src/template/test/examples-to-run.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/template/test/examples-to-run.py Wed May 04 20:02:57 2011 -0700 @@ -0,0 +1,18 @@ +#! /usr/bin/env python +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +# A list of C++ examples to run in order to ensure that they remain +# buildable and runnable over time. Each tuple in the list contains +# +# (example_name, do_run, do_valgrind_run). +# +# See test.py for more information. +cpp_examples = [] + +# A list of Python examples to run in order to ensure that they remain +# runnable over time. Each tuple in the list contains +# +# (example_name, do_run). +# +# See test.py for more information. +python_examples = [] diff -r db7061624ae6 -r 40b3cffdda99 src/template/test/sample-test-suite.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/template/test/sample-test-suite.cc Wed May 04 20:02:57 2011 -0700 @@ -0,0 +1,63 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ + +// An essential include is test.h +#include "ns3/test.h" + +// Do not put your test classes in namespace ns3. You may find it useful +// to use the using directive to access the ns3 namespace directly +using namespace ns3; + +// This is an example TestCase. +class SampleTestCase1 : public TestCase +{ +public: + SampleTestCase1 (); + virtual ~SampleTestCase1 (); + +private: + virtual void DoRun (void); +}; + +// Add some help text to this case to describe what it is intended to test +SampleTestCase1::SampleTestCase1 () + : TestCase ("Sample test case (does nothing)") +{ +} + +// This destructor does nothing but we include it as a reminder that +// the test case should clean up after itself +SampleTestCase1::~SampleTestCase1 () +{ +} + +// +// This method is the pure virtual method from class TestCase that every +// TestCase must implement +// +void +SampleTestCase1::DoRun (void) +{ + // A wide variety of test macros are available in src/core/test.h + NS_TEST_ASSERT_MSG_EQ (true, true, "true doesn't equal true for some reason"); + // Use this one for floating point comparisons + NS_TEST_ASSERT_MSG_EQ_TOL (0.01, 0.01, 0.001, "Numbers are not equal within tolerance"); +} + +// The TestSuite class names the TestSuite, identifies what type of TestSuite, +// and enables the TestCases to be run. Typically, only the constructor for +// this class must be defined +// +class SampleTestSuite : public TestSuite +{ +public: + SampleTestSuite (); +}; + +SampleTestSuite::SampleTestSuite () + : TestSuite ("sample", UNIT) +{ + AddTestCase (new SampleTestCase1); +} + +// Do not forget to allocate an instance of this TestSuite +static SampleTestSuite sampleTestSuite; diff -r db7061624ae6 -r 40b3cffdda99 src/template/wscript --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/template/wscript Wed May 04 20:02:57 2011 -0700 @@ -0,0 +1,19 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + module = bld.create_ns3_module('template', ['core']) + module.source = [ + ] + + test_library = bld.create_ns3_module_test_library('template') + test_library.source = [ + 'test/sample-test-suite.cc', + ] + + headers = bld.new_task_gen('ns3header') + headers.module = 'template' + headers.source = [ + ] + + if (bld.env['ENABLE_EXAMPLES']): + bld.add_subdirs('examples') diff -r db7061624ae6 -r 40b3cffdda99 src/test/sample-test-suite.cc --- a/src/test/sample-test-suite.cc Wed May 04 15:11:58 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ - -// An essential include is test.h -#include "ns3/test.h" - -// Do not put your test classes in namespace ns3. You may find it useful -// to use the using directive to access the ns3 namespace directly -using namespace ns3; - -// This is an example TestCase. -class SampleTestCase1 : public TestCase -{ -public: - SampleTestCase1 (); - virtual ~SampleTestCase1 (); - -private: - virtual void DoRun (void); -}; - -// Add some help text to this case to describe what it is intended to test -SampleTestCase1::SampleTestCase1 () - : TestCase ("Sample test case (does nothing)") -{ -} - -// This destructor does nothing but we include it as a reminder that -// the test case should clean up after itself -SampleTestCase1::~SampleTestCase1 () -{ -} - -// -// This method is the pure virtual method from class TestCase that every -// TestCase must implement -// -void -SampleTestCase1::DoRun (void) -{ - // A wide variety of test macros are available in src/core/test.h - NS_TEST_ASSERT_MSG_EQ (true, true, "true doesn't equal true for some reason"); - // Use this one for floating point comparisons - NS_TEST_ASSERT_MSG_EQ_TOL (0.01, 0.01, 0.001, "Numbers are not equal within tolerance"); -} - -// The TestSuite class names the TestSuite, identifies what type of TestSuite, -// and enables the TestCases to be run. Typically, only the constructor for -// this class must be defined -// -class SampleTestSuite : public TestSuite -{ -public: - SampleTestSuite (); -}; - -SampleTestSuite::SampleTestSuite () - : TestSuite ("sample", UNIT) -{ - AddTestCase (new SampleTestCase1); -} - -// Do not forget to allocate an instance of this TestSuite -static SampleTestSuite sampleTestSuite; diff -r db7061624ae6 -r 40b3cffdda99 src/test/wscript --- a/src/test/wscript Wed May 04 15:11:58 2011 -0700 +++ b/src/test/wscript Wed May 04 20:02:57 2011 -0700 @@ -12,7 +12,6 @@ test_test.source = [ 'csma-system-test-suite.cc', 'global-routing-test-suite.cc', - 'sample-test-suite.cc', 'static-routing-test-suite.cc', 'error-model-test-suite.cc', 'mobility-test-suite.cc', diff -r db7061624ae6 -r 40b3cffdda99 src/wscript --- a/src/wscript Wed May 04 15:11:58 2011 -0700 +++ b/src/wscript Wed May 04 20:02:57 2011 -0700 @@ -59,6 +59,7 @@ 'visualizer', 'point-to-point-layout', 'csma-layout', + 'template', ) def set_options(opt):