Bug 1284 - ./test.py performance tests do not exist

This commit is contained in:
Mitch Watrous
2012-09-10 17:15:07 -07:00
parent f75ccd609f
commit 5ef163d11a
5 changed files with 206 additions and 5 deletions

View File

@@ -727,6 +727,10 @@ TestRunnerImpl::Run (int argc, char *argv[])
{
testType = TestSuite::SYSTEM;
}
else if (testTypeString == "performance")
{
testType = TestSuite::PERFORMANCE;
}
else
{
std::cout << "Invalid test type specified: " << testTypeString << std::endl;

View File

@@ -0,0 +1,88 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2012 University of Washington
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mitch Watrous (watrous@u.washington.edu)
*/
#include "ns3/test.h"
#include "ns3/config.h"
#include "ns3/double.h"
#include "ns3/random-variable-stream.h"
#include <vector>
using namespace ns3;
// ===========================================================================
// Test case for many uniform distribution random variable stream generators
// ===========================================================================
class ManyUniformRandomVariablesOneGetValueCallTestCase : public TestCase
{
public:
ManyUniformRandomVariablesOneGetValueCallTestCase ();
virtual ~ManyUniformRandomVariablesOneGetValueCallTestCase ();
private:
virtual void DoRun (void);
};
ManyUniformRandomVariablesOneGetValueCallTestCase::ManyUniformRandomVariablesOneGetValueCallTestCase ()
: TestCase ("Many Uniform Random Variables with One GetValue() Call")
{
}
ManyUniformRandomVariablesOneGetValueCallTestCase::~ManyUniformRandomVariablesOneGetValueCallTestCase ()
{
}
void
ManyUniformRandomVariablesOneGetValueCallTestCase::DoRun (void)
{
double min = 0.0;
double max = 10.0;
Config::SetDefault ("ns3::UniformRandomVariable::Min", DoubleValue (min));
Config::SetDefault ("ns3::UniformRandomVariable::Max", DoubleValue (max));
// Get 1 value from many uniform random number generators.
double value;
int count = 1000000;
std::vector< Ptr<UniformRandomVariable> > uniformStreamVector (count);
for (int i = 0; i < count; i++)
{
uniformStreamVector.push_back (CreateObject<UniformRandomVariable> ());
value = uniformStreamVector.back ()->GetValue ();
NS_TEST_ASSERT_MSG_GT (value, min, "Value less than minimum.");
NS_TEST_ASSERT_MSG_LT (value, max, "Value greater than maximum.");
}
}
class ManyUniformRandomVariablesOneGetValueCallTestSuite : public TestSuite
{
public:
ManyUniformRandomVariablesOneGetValueCallTestSuite ();
};
ManyUniformRandomVariablesOneGetValueCallTestSuite::ManyUniformRandomVariablesOneGetValueCallTestSuite ()
: TestSuite ("many-uniform-random-variables-one-get-value-call", PERFORMANCE)
{
AddTestCase (new ManyUniformRandomVariablesOneGetValueCallTestCase);
}
static ManyUniformRandomVariablesOneGetValueCallTestSuite manyUniformRandomVariablesOneGetValueCallTestSuite;

View File

@@ -0,0 +1,88 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2012 University of Washington
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mitch Watrous (watrous@u.washington.edu)
*/
#include "ns3/test.h"
#include "ns3/config.h"
#include "ns3/double.h"
#include "ns3/random-variable-stream.h"
#include <vector>
using namespace ns3;
// ===========================================================================
// Test case for one uniform distribution random variable stream generator
// ===========================================================================
class OneUniformRandomVariableManyGetValueCallsTestCase : public TestCase
{
public:
OneUniformRandomVariableManyGetValueCallsTestCase ();
virtual ~OneUniformRandomVariableManyGetValueCallsTestCase ();
private:
virtual void DoRun (void);
};
OneUniformRandomVariableManyGetValueCallsTestCase::OneUniformRandomVariableManyGetValueCallsTestCase ()
: TestCase ("One Uniform Random Variable with Many GetValue() Calls")
{
}
OneUniformRandomVariableManyGetValueCallsTestCase::~OneUniformRandomVariableManyGetValueCallsTestCase ()
{
}
void
OneUniformRandomVariableManyGetValueCallsTestCase::DoRun (void)
{
double min = 0.0;
double max = 10.0;
Config::SetDefault ("ns3::UniformRandomVariable::Min", DoubleValue (min));
Config::SetDefault ("ns3::UniformRandomVariable::Max", DoubleValue (max));
Ptr<UniformRandomVariable> uniform = CreateObject<UniformRandomVariable> ();
// Get many values from 1 random number generator.
double value;
int count = 100000000;
for (int i = 0; i < count; i++)
{
value = uniform->GetValue ();
NS_TEST_ASSERT_MSG_GT (value, min, "Value less than minimum.");
NS_TEST_ASSERT_MSG_LT (value, max, "Value greater than maximum.");
}
}
class OneUniformRandomVariableManyGetValueCallsTestSuite : public TestSuite
{
public:
OneUniformRandomVariableManyGetValueCallsTestSuite ();
};
OneUniformRandomVariableManyGetValueCallsTestSuite::OneUniformRandomVariableManyGetValueCallsTestSuite ()
: TestSuite ("one-uniform-random-variable-many-get-value-calls", PERFORMANCE)
{
AddTestCase (new OneUniformRandomVariableManyGetValueCallsTestCase);
}
static OneUniformRandomVariableManyGetValueCallsTestSuite oneUniformRandomVariableManyGetValueCallsTestSuite;

View File

@@ -162,6 +162,8 @@ def build(bld):
'test/object-test-suite.cc',
'test/ptr-test-suite.cc',
'test/random-variable-test-suite.cc',
'test/many-uniform-random-variables-one-get-value-call-test-suite.cc',
'test/one-uniform-random-variable-many-get-value-calls-test-suite.cc',
'test/sample-test-suite.cc',
'test/simulator-test-suite.cc',
'test/time-test-suite.cc',

29
test.py
View File

@@ -82,7 +82,7 @@ test_runner_name = "test-runner"
# If the user has constrained us to run certain kinds of tests, we can tell waf
# to only build
#
core_kinds = ["bvt", "core", "system", "unit"]
core_kinds = ["bvt", "core", "performance", "system", "unit"]
#
# There are some special cases for test suites that kill valgrind. This is
@@ -1212,6 +1212,21 @@ def run_tests():
suite_list = suites.split('\n')
#
# Performance tests should only be run when they are requested,
# i.e. they are not run by default in test.py.
#
if options.constrain != 'performance':
# Get a list of all of the performance tests.
path_cmd = os.path.join("utils", test_runner_name + " --print-test-name-list --test-type=%s" % "performance")
(rc, performance_tests, standard_err, et) = run_job_synchronously(path_cmd, os.getcwd(), False, False)
performance_test_list = performance_tests.split('\n')
# Remove any performance tests from the suites list.
for performance_test in performance_test_list:
if performance_test in suite_list:
suite_list.remove(performance_test)
# We now have a possibly large number of test suites to run, so we want to
# run them in parallel. We're going to spin up a number of worker threads
# that will run our test jobs for us.
@@ -1326,15 +1341,13 @@ def run_tests():
# This translates into allowing the following options with respect to the
# suites
#
# ./test,py: run all of the examples
# ./test.py: run all of the examples
# ./test.py --constrain=unit run no examples
# ./test.py --constrain=example run all of the examples
# ./test.py --suite=some-test-suite: run no examples
# ./test.py --example=some-example: run the single example
# ./test.py --suite=some-suite --example=some-example: run the single example
#
# XXX could use constrain to separate out examples used for performance
# testing
#
if len(options.suite) == 0 and len(options.example) == 0 and len(options.pyexample) == 0:
if len(options.constrain) == 0 or options.constrain == "example":
@@ -1545,7 +1558,10 @@ def run_tests():
crashed_tests = crashed_tests + 1
status = "CRASH"
print "%s: %s %s" % (status, kind, job.display_name)
if options.duration or options.constrain == "performance":
print "%s (%.3f): %s %s" % (status, job.elapsed_time, kind, job.display_name)
else:
print "%s: %s %s" % (status, kind, job.display_name)
if job.is_example or job.is_pyexample:
#
@@ -1725,6 +1741,9 @@ def main(argv):
metavar="KIND",
help="constrain the test-runner by kind of test")
parser.add_option("-d", "--duration", action="store_true", dest="duration", default=False,
help="print the duration of each test suite and example")
parser.add_option("-e", "--example", action="store", type="string", dest="example", default="",
metavar="EXAMPLE",
help="specify a single example to run (with relative path)")