1.1 --- a/src/core/callback-test-suite.cc Thu Oct 01 15:21:21 2009 +0400
1.2 +++ b/src/core/callback-test-suite.cc Thu Oct 01 13:17:24 2009 +0200
1.3 @@ -22,18 +22,6 @@
1.4
1.5 namespace ns3 {
1.6
1.7 -class X : public ns3::Test
1.8 -{
1.9 -public:
1.10 - X () : Test ("Callback") {}
1.11 - void PublicParent (void) {}
1.12 -protected:
1.13 - static void StaticProtectedParent (void) {}
1.14 - void ProtectedParent (void) {}
1.15 -private:
1.16 - void PrivateParent (void) {}
1.17 -};
1.18 -
1.19 // ===========================================================================
1.20 // Test the basic Callback mechanism
1.21 // ===========================================================================
2.1 --- a/src/core/test.cc Thu Oct 01 15:21:21 2009 +0400
2.2 +++ b/src/core/test.cc Thu Oct 01 13:17:24 2009 +0200
2.3 @@ -693,148 +693,4 @@
2.4 return TestRunnerImpl::Instance ()->GetTestSuite (n);
2.5 }
2.6
2.7 -}; // namespace ns3
2.8 -
2.9 -#ifdef RUN_SELF_TESTS
2.10 -
2.11 -namespace ns3 {
2.12 -
2.13 -TestManager *
2.14 -TestManager::Get (void)
2.15 -{
2.16 - static TestManager manager;
2.17 - return &manager;
2.18 -}
2.19 -
2.20 -TestManager::TestManager ()
2.21 - : m_verbose (false)
2.22 -{}
2.23 -
2.24 -TestManager::~TestManager ()
2.25 -{
2.26 - TestsI i = m_tests.begin ();
2.27 - while (i != m_tests.end ())
2.28 - {
2.29 - delete (*i).second;
2.30 - i = m_tests.erase (i);
2.31 - }
2.32 -}
2.33 -void
2.34 -TestManager::Add (Test *test, char const *name)
2.35 -{
2.36 - Get ()->m_tests.push_back (std::make_pair (test, new std::string (name)));
2.37 -}
2.38 -void
2.39 -TestManager::EnableVerbose (void)
2.40 -{
2.41 - Get ()->m_verbose = true;
2.42 -}
2.43 -
2.44 -void
2.45 -TestManager::PrintTestNames (std::ostream &os)
2.46 -{
2.47 - for (TestsCI i = Get ()->m_tests.begin (); i != Get ()->m_tests.end (); i++)
2.48 - {
2.49 - std::string *testName = (*i).second;
2.50 - os << *testName << std::endl;
2.51 - }
2.52 -}
2.53 -
2.54 -std::ostream &
2.55 -TestManager::Failure (void)
2.56 -{
2.57 - return std::cerr;
2.58 -}
2.59 -bool
2.60 -TestManager::RunTests (void)
2.61 -{
2.62 - return Get ()->RealRunTests ();
2.63 -}
2.64 -bool
2.65 -TestManager::RealRunTests (void)
2.66 -{
2.67 - bool isSuccess = true;
2.68 - for (TestsCI i = m_tests.begin (); i != m_tests.end (); i++)
2.69 - {
2.70 - std::string *testName = (*i).second;
2.71 - if (!(*i).first->RunTests ())
2.72 - {
2.73 - isSuccess = false;
2.74 - if (m_verbose)
2.75 - {
2.76 - std::cerr << "FAIL " << *testName << std::endl;
2.77 - }
2.78 - }
2.79 - else
2.80 - {
2.81 - if (m_verbose)
2.82 - {
2.83 - std::cerr << "PASS "<<*testName << std::endl;
2.84 - }
2.85 - }
2.86 - }
2.87 - if (!isSuccess)
2.88 - {
2.89 - std::cerr << "FAIL" << std::endl;
2.90 - }
2.91 - return isSuccess;
2.92 -}
2.93 -
2.94 -bool
2.95 -TestManager::RunTest (std::string name)
2.96 -{
2.97 - return Get ()->RealRunTest (name);
2.98 -}
2.99 -bool
2.100 -TestManager::RealRunTest (std::string name)
2.101 -{
2.102 - TestsCI i;
2.103 -
2.104 - for (i = m_tests.begin (); i != m_tests.end (); i++)
2.105 - {
2.106 - std::string *testName = (*i).second;
2.107 - if (*testName == name)
2.108 - {
2.109 - break;
2.110 - }
2.111 - }
2.112 - if (i == m_tests.end ())
2.113 - {
2.114 - std::cerr << "Test with name " << name << " not found." << std::endl;
2.115 - }
2.116 -
2.117 - if (!(*i).first->RunTests ())
2.118 - {
2.119 - if (m_verbose)
2.120 - {
2.121 - std::cerr << "FAIL " << name << std::endl;
2.122 - }
2.123 - return false;
2.124 - }
2.125 - else
2.126 - {
2.127 - if (m_verbose)
2.128 - {
2.129 - std::cerr << "PASS "<< name << std::endl;
2.130 - }
2.131 - return true;
2.132 - }
2.133 -}
2.134 -
2.135 -Test::Test (char const *name)
2.136 -{
2.137 - TestManager::Add (this, name);
2.138 -}
2.139 -
2.140 -Test::~Test ()
2.141 -{}
2.142 -
2.143 -std::ostream &
2.144 -Test::Failure (void)
2.145 -{
2.146 - return TestManager::Failure ();
2.147 -}
2.148 -
2.149 -}; // namespace ns3
2.150 -
2.151 -#endif /* RUN_SELF_TESTS */
2.152 +} // namespace ns3
3.1 --- a/src/core/test.h Thu Oct 01 15:21:21 2009 +0400
3.2 +++ b/src/core/test.h Thu Oct 01 13:17:24 2009 +0200
3.3 @@ -16,8 +16,8 @@
3.4 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3.5 */
3.6
3.7 -#ifndef TEST_H
3.8 -#define TEST_H
3.9 +#ifndef NS3_TEST_H
3.10 +#define NS3_TEST_H
3.11
3.12 #include <iostream>
3.13 #include <fstream>
3.14 @@ -1151,170 +1151,6 @@
3.15 return m_vectors[i];
3.16 }
3.17
3.18 -}; // namespace ns3
3.19 +} // namespace ns3
3.20
3.21 -//
3.22 -// Original ns-3 unit test code for compatibility
3.23 -//
3.24 -#ifdef RUN_SELF_TESTS
3.25 -
3.26 -namespace ns3 {
3.27 -
3.28 -class TestManager;
3.29 -
3.30 -/**
3.31 - * \ingroup core
3.32 - * \defgroup test Test
3.33 - */
3.34 -/**
3.35 - * \ingroup test
3.36 - *
3.37 - * \brief base class for new regressions tests
3.38 - *
3.39 - * To add a new regression test, you need to:
3.40 - * - create subclass of this abstract base class
3.41 - * - instantiate once this subclass through a static
3.42 - * variable.
3.43 - *
3.44 - * The following sample code shows you how to do this:
3.45 - * \include samples/main-test.cc
3.46 - */
3.47 -class Test {
3.48 -public:
3.49 - /**
3.50 - * \param name the name of the test
3.51 - */
3.52 - Test (char const *name);
3.53 - virtual ~Test ();
3.54 -
3.55 - /**
3.56 - * \returns true if the test was successful, false otherwise.
3.57 - */
3.58 - virtual bool RunTests (void) = 0;
3.59 -
3.60 -protected:
3.61 - /**
3.62 - * \returns an output stream which base classes can write to
3.63 - * to return extra information on test errors.
3.64 - */
3.65 - std::ostream &Failure (void);
3.66 -};
3.67 -
3.68 -/**
3.69 - * \ingroup test
3.70 - *
3.71 - * \brief gather and run all regression tests
3.72 - */
3.73 -class TestManager {
3.74 -public:
3.75 - /**
3.76 - * Enable verbose output. If you do not enable verbose output,
3.77 - * nothing is printed on screen during the test runs.
3.78 - */
3.79 - static void EnableVerbose (void);
3.80 - /**
3.81 - * \returns true if all tests passed, false otherwise.
3.82 - *
3.83 - * run all registered regression tests
3.84 - */
3.85 - static bool RunTests (void);
3.86 -
3.87 - static bool RunTest (std::string name);
3.88 -
3.89 - static void PrintTestNames (std::ostream &os);
3.90 -
3.91 -private:
3.92 - friend class Test;
3.93 - static void Add (Test *test, char const *name);
3.94 - static std::ostream &Failure (void);
3.95 - static TestManager *Get (void);
3.96 - bool RealRunTests (void);
3.97 - bool RealRunTest (std::string name);
3.98 -
3.99 - TestManager ();
3.100 - ~TestManager ();
3.101 -
3.102 - typedef std::list<std::pair<Test *,std::string *> > Tests;
3.103 - typedef std::list<std::pair<Test *,std::string *> >::iterator TestsI;
3.104 - typedef std::list<std::pair<Test *,std::string *> >::const_iterator TestsCI;
3.105 -
3.106 - Tests m_tests;
3.107 - bool m_verbose;
3.108 -};
3.109 -}; // namespace ns3
3.110 -
3.111 -#define NS_TEST_ASSERT_EQUAL_FILELINE(got, expected, file, line) \
3.112 - do { \
3.113 - if (! ((got) == (expected))) \
3.114 - { \
3.115 - Failure () << file << ":" <<line \
3.116 - << ": expected " << (expected) \
3.117 - << ", got " << (got) << std::endl; \
3.118 - result = false; \
3.119 - } \
3.120 - } while (false)
3.121 -
3.122 -#define NS_TEST_ASSERT_UNEQUAL_FILELINE(got, expected,file,line) \
3.123 - do { \
3.124 - if ((got) == (expected)) \
3.125 - { \
3.126 - Failure () << file << ":" <<line \
3.127 - << ": did not want " << (expected) \
3.128 - << ", got " << (got) << std::endl; \
3.129 - result = false; \
3.130 - } \
3.131 - } while (false)
3.132 -
3.133 -
3.134 -#define NS_TEST_ASSERT_FILELINE(assertion, file, line) \
3.135 - do { \
3.136 - if (!(assertion)) \
3.137 - { \
3.138 - Failure () << file << ":" <<line \
3.139 - << ": assertion `" << #assertion \
3.140 - << "' failed." << std::endl; \
3.141 - result = false; \
3.142 - } \
3.143 - } while (false)
3.144 -
3.145 -
3.146 -
3.147 -/**
3.148 - * Convenience macro to check that a value returned by a test is what
3.149 - * is expected. Note: this macro assumes a 'bool result = true'
3.150 - * declaration exists in the test function body, and that the function
3.151 - * returns that value.
3.152 - *
3.153 - * \param got value obtained from the test
3.154 - * \param expected value that the test is expected to return
3.155 - */
3.156 -#define NS_TEST_ASSERT_EQUAL(got, expected) \
3.157 - NS_TEST_ASSERT_EQUAL_FILELINE(got,expected,__FILE__,__LINE__)
3.158 -
3.159 -/**
3.160 - * Convenience macro to check that a value returned by a test is what
3.161 - * is expected. Note: this macro assumes a 'bool result = true'
3.162 - * declaration exists in the test function body, and that the function
3.163 - * returns that value.
3.164 - *
3.165 - * \param got value obtained from the test
3.166 - * \param expected value that the test is expected to return
3.167 - */
3.168 -#define NS_TEST_ASSERT_UNEQUAL(got, expected) \
3.169 - NS_TEST_ASSERT_UNEQUAL_FILELINE(got,expected,__FILE__,__LINE__)
3.170 -
3.171 -/**
3.172 - * Convenience macro to check an assertion is held during an unit
3.173 - * test. Note: this macro assumes a 'bool result = true' declaration
3.174 - * exists in the test function body, and that the function returns
3.175 - * that value.
3.176 - *
3.177 - * \param assertion expression that must be true if the test did not fail
3.178 - */
3.179 -#define NS_TEST_ASSERT(assertion) \
3.180 - NS_TEST_ASSERT_FILELINE (assertion, __FILE__,__LINE__)
3.181 -
3.182 -
3.183 -#endif /* RUN_SELF_TESTS */
3.184 -
3.185 -#endif /* TEST_H */
3.186 +#endif /* NS3_TEST_H */
4.1 --- a/utils/run-tests.cc Thu Oct 01 15:21:21 2009 +0400
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,66 +0,0 @@
4.4 -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
4.5 -/*
4.6 - * Copyright (c) 2005 INRIA
4.7 - *
4.8 - * This program is free software; you can redistribute it and/or modify
4.9 - * it under the terms of the GNU General Public License version 2 as
4.10 - * published by the Free Software Foundation;
4.11 - *
4.12 - * This program is distributed in the hope that it will be useful,
4.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.15 - * GNU General Public License for more details.
4.16 - *
4.17 - * You should have received a copy of the GNU General Public License
4.18 - * along with this program; if not, write to the Free Software
4.19 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4.20 - *
4.21 - * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
4.22 - */
4.23 -
4.24 -#include "ns3/test.h"
4.25 -#include "ns3/packet-metadata.h"
4.26 -#include "ns3/random-variable.h"
4.27 -
4.28 -
4.29 -int main (int argc, char *argv[])
4.30 -{
4.31 - if (argc > 1)
4.32 - {
4.33 - if (std::string (argv[1]) == "--ListTests")
4.34 - {
4.35 -#ifdef RUN_SELF_TESTS
4.36 - ns3::TestManager::PrintTestNames (std::cout);
4.37 -#endif
4.38 - }
4.39 - else
4.40 - {
4.41 - // run the test named by argv[1]
4.42 -#ifdef RUN_SELF_TESTS
4.43 - bool success = ns3::TestManager::RunTest (argv[1]);
4.44 - if (!success)
4.45 - {
4.46 - return 1;
4.47 - }
4.48 -#else
4.49 - std::cerr << "Unit tests not enabled" << std::endl;
4.50 - return 1;
4.51 -#endif
4.52 - }
4.53 - }
4.54 - else
4.55 - {
4.56 - // run all tests
4.57 -#ifdef RUN_SELF_TESTS
4.58 - ns3::PacketMetadata::Enable ();
4.59 - ns3::TestManager::EnableVerbose ();
4.60 - bool success = ns3::TestManager::RunTests ();
4.61 - if (!success)
4.62 - {
4.63 - return 1;
4.64 - }
4.65 -#endif /* RUN_SELF_TESTS */
4.66 - }
4.67 - return 0;
4.68 -}
4.69 -
5.1 --- a/utils/wscript Thu Oct 01 15:21:21 2009 +0400
5.2 +++ b/utils/wscript Thu Oct 01 13:17:24 2009 +0200
5.3 @@ -4,12 +4,6 @@
5.4 def build(bld):
5.5 env = bld.env
5.6
5.7 - unit_tests = bld.create_ns3_program('run-tests', ['common'])
5.8 - unit_tests.install_path = None # do not install
5.9 - unit_tests.source = 'run-tests.cc'
5.10 - ## link unit test program with all ns3 modules
5.11 - unit_tests.uselib_local = 'ns3'
5.12 -
5.13 test_runner = bld.create_ns3_program('test-runner', ['core'])
5.14 test_runner.install_path = None # do not install
5.15 test_runner.source = 'test-runner.cc'