1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/regression/regression.py Tue Mar 25 23:17:24 2008 -0700
1.3 @@ -0,0 +1,123 @@
1.4 +#! /usr/bin/env python
1.5 +# regression.py adapted from python language regression scripts.
1.6 +
1.7 +"""Regression test.
1.8 +
1.9 +This will find all modules whose name is "test_*" in the tests
1.10 +directory, and run them.
1.11 +
1.12 +Command line options:
1.13 +
1.14 +-v: verbose -- run tests in verbose mode with output to stdout
1.15 +-g: generate -- write the output file for a test instead of comparing it
1.16 +
1.17 +If non-option arguments are present, they are names for tests to run.
1.18 +If no test names are given, all tests are run.
1.19 +
1.20 +"""
1.21 +
1.22 +import sys
1.23 +import os
1.24 +import getopt
1.25 +
1.26 +verbose = 0
1.27 +generate = 0
1.28 +
1.29 +def main(tests = None, testdir = None):
1.30 + """Execute regression tests.
1.31 +
1.32 + Arguments:
1.33 + tests -- a list of strings containing test names (optional)
1.34 + testdir -- the directory in which to look for tests (optional)
1.35 + """
1.36 +
1.37 + global verbose
1.38 + global generate
1.39 +
1.40 + try:
1.41 + opts, args = getopt.getopt(sys.argv[1:], 'vg')
1.42 + except getopt.error, msg:
1.43 + print msg
1.44 + print __doc__
1.45 + return 2
1.46 +
1.47 + for o, a in opts:
1.48 + if o == '-v': verbose = 1
1.49 + if o == '-g': generate = 1
1.50 +
1.51 + if not os.path.exists('./traces'):
1.52 + os.mkdir('./traces')
1.53 +
1.54 + bad = []
1.55 +
1.56 + if not testdir:
1.57 + testdir = os.path.join(os.curdir, "tests")
1.58 +
1.59 + if not os.path.exists(testdir):
1.60 + print "Tests directory does not exist"
1.61 + return 3
1.62 +
1.63 + if verbose:
1.64 + print "tests directory: ", testdir
1.65 +
1.66 + sys.path.append(testdir)
1.67 +
1.68 + for i in range(len(args)):
1.69 + if args[i][-3:] == '.py':
1.70 + args[i] = args[i][:-3]
1.71 +
1.72 + if not tests:
1.73 + tests = args
1.74 +
1.75 + if not tests:
1.76 + tests = findtests(testdir)
1.77 +
1.78 + for test in tests:
1.79 + if verbose:
1.80 + print "main(): running test", test
1.81 + result = runtest(test)
1.82 + if result == 0:
1.83 + print "PASS ", test
1.84 + else:
1.85 + bad.append(test)
1.86 + print "FAIL ", test
1.87 +
1.88 + return len(bad) > 0
1.89 +
1.90 +def findtests(testdir):
1.91 + """Return a list of test modules in the test directory
1.92 +
1.93 + Arguments:
1.94 + testdir -- the directory to look in for tests
1.95 + """
1.96 + if verbose:
1.97 + print "findtests(", testdir, ")"
1.98 + if verbose:
1.99 + print "findtests(): look in ", testdir
1.100 +
1.101 + names = os.listdir(testdir)
1.102 + if verbose:
1.103 + print "findtests(): found ", names
1.104 + tests = []
1.105 + for name in names:
1.106 + if name[:5] == "test_" and name[-3:] == ".py":
1.107 + testname = name[:-3]
1.108 + tests.append(testname)
1.109 + tests.sort()
1.110 + if verbose:
1.111 + print "findtests(): found tests ", tests
1.112 + return tests
1.113 +
1.114 +def runtest(test):
1.115 + """Run a single test.
1.116 +
1.117 + Arguments:
1.118 + test -- the name of the test
1.119 + """
1.120 + if verbose:
1.121 + print "runtest(): run ", test
1.122 + mod = __import__(test, globals(), locals(), [])
1.123 + return mod.run(verbose, generate)
1.124 +
1.125 +if __name__ == '__main__':
1.126 + sys.exit(main())
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/regression/tests/test_csma_one_subnet.py Tue Mar 25 23:17:24 2008 -0700
2.3 @@ -0,0 +1,10 @@
2.4 +#! /usr/bin/env python
2.5 +
2.6 +"""Regression test csma-one-subnet."""
2.7 +
2.8 +import os
2.9 +
2.10 +def run(verbose, generate):
2.11 + """Execute a test."""
2.12 + os.system("./waf --cwd regression/traces --run csma-one-subnet")
2.13 + return 0
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/regression/waf Tue Mar 25 23:17:24 2008 -0700
3.3 @@ -0,0 +1,1 @@
3.4 +exec "`dirname "$0"`"/../waf "$@"
3.5 \ No newline at end of file
4.1 --- a/wscript Tue Mar 25 14:17:35 2008 -0700
4.2 +++ b/wscript Tue Mar 25 23:17:24 2008 -0700
4.3 @@ -20,7 +20,6 @@
4.4 srcdir = '.'
4.5 blddir = 'build'
4.6
4.7 -
4.8 def dist_hook():
4.9 shutil.rmtree("doc/html", True)
4.10 shutil.rmtree("doc/latex", True)
4.11 @@ -48,6 +47,11 @@
4.12 # options provided by the modules
4.13 opt.tool_options('compiler_cxx')
4.14
4.15 + opt.add_option('--cwd',
4.16 + help=('Set the working directory for a program.'),
4.17 + action="store", type="string", default=None,
4.18 + dest='cwd_launch')
4.19 +
4.20 opt.add_option('--enable-gcov',
4.21 help=('Enable code coverage analysis.'
4.22 ' WARNING: this option only has effect '
4.23 @@ -164,7 +168,7 @@
4.24
4.25 def build(bld):
4.26 Params.g_cwd_launch = Params.g_build.m_curdirnode.abspath()
4.27 -
4.28 +
4.29 bld.create_ns3_program = types.MethodType(create_ns3_program, bld)
4.30
4.31 variant_name = bld.env_of_name('default')['NS3_ACTIVE_VARIANT']
4.32 @@ -378,9 +382,11 @@
4.33
4.34 execvec = shlex.split(command_template % (program_node.abspath(env),))
4.35
4.36 -
4.37 former_cwd = os.getcwd()
4.38 - os.chdir(Params.g_cwd_launch)
4.39 + if (Params.g_options.cwd_launch):
4.40 + os.chdir(Params.g_options.cwd_launch)
4.41 + else:
4.42 + os.chdir(Params.g_cwd_launch)
4.43 try:
4.44 retval = _run_argv(execvec)
4.45 finally:
4.46 @@ -416,7 +422,6 @@
4.47 env = Params.g_build.env_of_name('default')
4.48 _run_argv([shell], {'NS3_MODULE_PATH': os.pathsep.join(env['NS3_MODULE_PATH'])})
4.49
4.50 -
4.51 def doxygen():
4.52 if not os.path.exists('doc/introspected-doxygen.h'):
4.53 Params.warning("doc/introspected-doxygen.h does not exist; run waf check to generate it.")