Bug 1463 - ./test.py --example should automatically detect the path

This commit is contained in:
Mitch Watrous
2012-09-14 11:48:14 -07:00
parent e2fec417ea
commit fbdc39460e
4 changed files with 37 additions and 13 deletions

View File

@@ -24,8 +24,13 @@ New user-visible features
Bugs fixed
----------
- bug 1284 - ./test.py performance tests do not exist
- bug 1463 - ./test.py --example should automatically detect the path
- bug 1485 - Setting global properties in config file (raw text) does
not have any effect
- bug 1493 - test.py --list should show the test type default tip
- bug 1494 - test.py --constrain doesn't work
- bug 1495 - test.py claims test passed when no test was run
Known issues
------------

View File

@@ -115,7 +115,8 @@ if you run ``test.py --help`` you should see a command summary like:
-c KIND, --constrain=KIND
constrain the test-runner by kind of test
-e EXAMPLE, --example=EXAMPLE
specify a single example to run (with relative path)
specify a single example to run (no relative path is
needed)
-g, --grind run the test suites and examples using valgrind
-k, --kinds print the kinds of tests available
-l, --list print the list of known tests
@@ -285,12 +286,12 @@ Any of these listed suites can be selected to be run by itself using the
Similarly to test suites, one can run a single C++ example program
using the ``--example`` option. Note that the relative path for the
example must be included and that the executables built for C++
examples do not have extensions. Entering
example does not need to be included and that the executables built
for C++ examples do not have extensions. Entering
::
./test.py --example=examples/udp/udp-echo
./test.py --example=udp-echo
results in that single example being run.
@@ -303,7 +304,7 @@ You can specify the directory where ns-3 was built using the
::
./test.py --buildpath=/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build/debug --example=examples/wireless/wifi-simple-adhoc
./test.py --buildpath=/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build/debug --example=wifi-simple-adhoc
One can run a single Python example program using the ``--pyexample``
option. Note that the relative path for the example must be included

24
test.py
View File

@@ -1044,7 +1044,9 @@ def run_tests():
#
make_paths()
#
# Get the information from the build status file.
#
build_status_file = os.path.join (NS3_BUILDDIR, 'build-status.py')
if os.path.exists(build_status_file):
ns3_runnable_programs = get_list_from_file(build_status_file, "ns3_runnable_programs")
@@ -1053,6 +1055,15 @@ def run_tests():
print >> sys.stderr, 'The build status file was not found. You must do waf build before running test.py.'
sys.exit(2)
#
# Make a dictionary that maps the name of a program to its path.
#
ns3_runnable_programs_dictionary = {}
for program in ns3_runnable_programs:
# Remove any directory names from path.
program_name = os.path.basename(program)
ns3_runnable_programs_dictionary[program_name] = program
# Generate the lists of examples to run as smoke tests in order to
# ensure that they remain buildable and runnable over time.
#
@@ -1367,7 +1378,7 @@ def run_tests():
test_name = os.path.basename(test_name)
# Don't try to run this example if it isn't runnable.
if test_name in ns3_runnable_programs:
if ns3_runnable_programs_dictionary.has_key(test_name):
if eval(do_run):
job = Job()
job.set_is_example(True)
@@ -1393,22 +1404,21 @@ def run_tests():
elif len(options.example):
# Add the proper prefix and suffix to the example name to
# match what is done in the wscript file.
(example_path_without_name, example_name) = os.path.split(options.example)
example_name = "%s%s-%s-%s" % (APPNAME, VERSION, example_name, BUILD_PROFILE)
example_path = os.path.join(example_path_without_name, example_name)
example_name = "%s%s-%s-%s" % (APPNAME, VERSION, options.example, BUILD_PROFILE)
# Don't try to run this example if it isn't runnable.
if example_name not in ns3_runnable_programs:
if not ns3_runnable_programs_dictionary.has_key(example_name):
print "Example %s is not runnable." % example_name
else:
#
# If you tell me to run an example, I will try and run the example
# irrespective of any condition.
#
example_path = ns3_runnable_programs_dictionary[example_name]
job = Job()
job.set_is_example(True)
job.set_is_pyexample(False)
job.set_display_name(example_name)
job.set_display_name(example_path)
job.set_tmp_file_name("")
job.set_cwd(testpy_output_dir)
job.set_basedir(os.getcwd())
@@ -1755,7 +1765,7 @@ def main(argv):
parser.add_option("-e", "--example", action="store", type="string", dest="example", default="",
metavar="EXAMPLE",
help="specify a single example to run (with relative path)")
help="specify a single example to run (no relative path is needed)")
parser.add_option("-u", "--update-data", action="store_true", dest="update_data", default=False,
help="If examples use reference data files, get them to re-generate them")

10
wscript
View File

@@ -773,7 +773,15 @@ def build(bld):
if program_built:
object_name = "%s%s-%s%s" % (wutils.APPNAME, wutils.VERSION,
obj.name, bld.env.BUILD_SUFFIX)
bld.env.append_value('NS3_RUNNABLE_PROGRAMS', object_name)
# Get the relative path to the program from the
# launch directory.
launch_dir = os.path.abspath(Context.launch_dir)
object_relative_path = os.path.join(
wutils.relpath(obj.path.abspath(), launch_dir),
object_name)
bld.env.append_value('NS3_RUNNABLE_PROGRAMS', object_relative_path)
# disable the modules themselves
if hasattr(obj, "is_ns3_module") and obj.name not in modules: