From 26006abcca40c06b31e0277b97c798bc99574c2e Mon Sep 17 00:00:00 2001 From: Mitch Watrous Date: Fri, 29 Apr 2011 09:53:35 -0700 Subject: [PATCH] Make test.py not run examples that are not runnable --- examples/routing/wscript | 2 +- examples/tutorial/wscript | 2 +- examples/wireless/wscript | 4 +- src/flow-monitor/examples/wscript | 2 +- src/point-to-point-layout/wscript | 2 +- test.py | 203 +++++++++++++++++------------- wscript | 4 +- 7 files changed, 122 insertions(+), 97 deletions(-) diff --git a/examples/routing/wscript b/examples/routing/wscript index ebf7e3e5c..d1e133ba6 100644 --- a/examples/routing/wscript +++ b/examples/routing/wscript @@ -33,4 +33,4 @@ def build(bld): ['csma', 'internet']) obj.source = 'simple-routing-ping6.cc' - bld.register_ns3_script('simple-routing-ping.py', ['csma', 'internet']) + bld.register_ns3_script('simple-routing-ping6.py', ['csma', 'internet', 'applications', 'tools', 'config-store', 'mobility', 'wifi', 'olsr']) diff --git a/examples/tutorial/wscript b/examples/tutorial/wscript index a06f7941f..5e2ed3665 100644 --- a/examples/tutorial/wscript +++ b/examples/tutorial/wscript @@ -7,7 +7,7 @@ def build(bld): obj = bld.create_ns3_program('first', ['core', 'point-to-point', 'internet', 'applications']) obj.source = 'first.cc' - bld.register_ns3_script('first.py', ['core', 'point-to-point', 'internet', 'applications']) + bld.register_ns3_script('first.py', ['internet', 'point-to-point', 'applications', 'tools', 'config-store', 'csma', 'mobility', 'wifi']) obj = bld.create_ns3_program('second', ['core', 'point-to-point', 'csma', 'internet', 'applications']) obj.source = 'second.cc' diff --git a/examples/wireless/wscript b/examples/wireless/wscript index 66920bbab..f840b073e 100644 --- a/examples/wireless/wscript +++ b/examples/wireless/wscript @@ -6,7 +6,7 @@ def build(bld): obj.source = 'mixed-wireless.cc' bld.register_ns3_script('mixed-wireless.py', ['core', 'mobility', 'wifi', 'applications', 'point-to-point', - 'internet', 'csma', 'olsr']) + 'internet', 'csma', 'olsr', 'config-store', 'tools']) obj = bld.create_ns3_program('wifi-adhoc', ['core', 'mobility', 'wifi', 'applications', 'tools']) obj.source = 'wifi-adhoc.cc' @@ -17,7 +17,7 @@ def build(bld): obj = bld.create_ns3_program('wifi-ap', ['core', 'mobility', 'wifi', 'applications', 'config-store', 'tools']) obj.source = 'wifi-ap.cc' - bld.register_ns3_script('wifi-ap.py', ['core', 'mobility', 'wifi', 'applications', 'config-store', 'tools']) + bld.register_ns3_script('wifi-ap.py', ['internet', 'mobility', 'wifi', 'applications', 'config-store', 'tools', 'csma', 'point-to-point']) obj = bld.create_ns3_program('wifi-wired-bridging', ['internet', 'mobility', 'wifi', 'csma', 'bridge', 'applications']) obj.source = 'wifi-wired-bridging.cc' diff --git a/src/flow-monitor/examples/wscript b/src/flow-monitor/examples/wscript index 4ce4f3922..c8e3657bd 100644 --- a/src/flow-monitor/examples/wscript +++ b/src/flow-monitor/examples/wscript @@ -1,4 +1,4 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- def build(bld): - bld.register_ns3_script('wifi-olsr-flowmon.py', ['flow-monitor', 'internet', 'tools', 'config-store', 'wifi', 'olsr', 'applications', 'mobility']) + bld.register_ns3_script('wifi-olsr-flowmon.py', ['flow-monitor', 'internet', 'tools', 'config-store', 'wifi', 'olsr', 'applications', 'mobility', 'csma', 'network', 'point-to-point']) diff --git a/src/point-to-point-layout/wscript b/src/point-to-point-layout/wscript index a5639e452..4ab18b42d 100644 --- a/src/point-to-point-layout/wscript +++ b/src/point-to-point-layout/wscript @@ -1,7 +1,7 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- def build(bld): - module = bld.create_ns3_module('point-to-point-layout', ['internet', 'point-to-point', 'mobility']) + module = bld.create_ns3_module('point-to-point-layout', ['internet', 'point-to-point', 'mobility', 'netanim']) module.includes = '.' module.source = [ 'model/point-to-point-dumbbell.cc', diff --git a/test.py b/test.py index b4d10f6c5..b40b3d0ec 100755 --- a/test.py +++ b/test.py @@ -993,6 +993,15 @@ def run_tests(): read_waf_config() make_paths() + # Get the information from the build status file. + build_status_file = os.path.join (NS3_BUILDDIR, NS3_ACTIVE_VARIANT, 'build-status.py') + if os.path.exists(build_status_file): + ns3_runnable_programs = get_list_from_file(build_status_file, "ns3_runnable_programs") + ns3_runnable_scripts = get_list_from_file(build_status_file, "ns3_runnable_scripts") + else: + print >> sys.stderr, 'The build status file was not found. You must do waf build before running test.py.' + sys.exit(2) + # Generate the lists of examples to run as smoke tests in order to # ensure that they remain buildable and runnable over time. # @@ -1271,50 +1280,58 @@ def run_tests(): if len(options.constrain) == 0 or options.constrain == "example": if ENABLE_EXAMPLES: for test, do_run, do_valgrind_run in example_tests: - if eval(do_run): - job = Job() - job.set_is_example(True) - job.set_is_pyexample(False) - job.set_display_name(test) - job.set_tmp_file_name("") - job.set_cwd(testpy_output_dir) - job.set_basedir(os.getcwd()) - job.set_tempdir(testpy_output_dir) - job.set_shell_command(test) - job.set_build_path("") - if options.valgrind and not eval(do_valgrind_run): - job.set_is_skip (True) + # Don't try to run this example if it isn't runnable. + if os.path.basename(test) in ns3_runnable_programs: + if eval(do_run): + job = Job() + job.set_is_example(True) + job.set_is_pyexample(False) + job.set_display_name(test) + job.set_tmp_file_name("") + job.set_cwd(testpy_output_dir) + job.set_basedir(os.getcwd()) + job.set_tempdir(testpy_output_dir) + job.set_shell_command(test) + job.set_build_path("") - if options.verbose: - print "Queue %s" % test + if options.valgrind and not eval(do_valgrind_run): + job.set_is_skip (True) - input_queue.put(job) - jobs = jobs + 1 - total_tests = total_tests + 1 + if options.verbose: + print "Queue %s" % test + + input_queue.put(job) + jobs = jobs + 1 + total_tests = total_tests + 1 elif len(options.example): - # - # If you tell me to run an example, I will try and run the example - # irrespective of any condition. - # - job = Job() - job.set_is_example(True) - job.set_is_pyexample(False) - job.set_display_name(options.example) - job.set_tmp_file_name("") - job.set_cwd(testpy_output_dir) - job.set_basedir(os.getcwd()) - job.set_tempdir(testpy_output_dir) - job.set_shell_command(options.example) - job.set_build_path(options.buildpath) - - if options.verbose: - print "Queue %s" % options.example + # Don't try to run this example if it isn't runnable. + example_name = os.path.basename(options.example) + if example_name not in ns3_runnable_programs: + 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. + # + job = Job() + job.set_is_example(True) + job.set_is_pyexample(False) + job.set_display_name(options.example) + job.set_tmp_file_name("") + job.set_cwd(testpy_output_dir) + job.set_basedir(os.getcwd()) + job.set_tempdir(testpy_output_dir) + job.set_shell_command(options.example) + job.set_build_path(options.buildpath) - input_queue.put(job) - jobs = jobs + 1 - total_tests = total_tests + 1 + if options.verbose: + print "Queue %s" % options.example + + input_queue.put(job) + jobs = jobs + 1 + total_tests = total_tests + 1 # # Run some Python examples as smoke tests. We have a list of all of @@ -1340,64 +1357,72 @@ def run_tests(): if len(options.constrain) == 0 or options.constrain == "pyexample": if ENABLE_EXAMPLES: for test, do_run in python_tests: - if eval(do_run): - job = Job() - job.set_is_example(False) - job.set_is_pyexample(True) - job.set_display_name(test) - job.set_tmp_file_name("") - job.set_cwd(testpy_output_dir) - job.set_basedir(os.getcwd()) - job.set_tempdir(testpy_output_dir) - job.set_shell_command(test) - job.set_build_path("") - # - # Python programs and valgrind do not work and play - # well together, so we skip them under valgrind. - # We go through the trouble of doing all of this - # work to report the skipped tests in a consistent - # way throught the output formatter. - # - if options.valgrind: - job.set_is_skip (True) + # Don't try to run this example if it isn't runnable. + if os.path.basename(test) in ns3_runnable_scripts: + if eval(do_run): + job = Job() + job.set_is_example(False) + job.set_is_pyexample(True) + job.set_display_name(test) + job.set_tmp_file_name("") + job.set_cwd(testpy_output_dir) + job.set_basedir(os.getcwd()) + job.set_tempdir(testpy_output_dir) + job.set_shell_command(test) + job.set_build_path("") - # - # The user can disable python bindings, so we need - # to pay attention to that and give some feedback - # that we're not testing them - # - if not ENABLE_PYTHON_BINDINGS: - job.set_is_skip (True) + # + # Python programs and valgrind do not work and play + # well together, so we skip them under valgrind. + # We go through the trouble of doing all of this + # work to report the skipped tests in a consistent + # way throught the output formatter. + # + if options.valgrind: + job.set_is_skip (True) - if options.verbose: - print "Queue %s" % test + # + # The user can disable python bindings, so we need + # to pay attention to that and give some feedback + # that we're not testing them + # + if not ENABLE_PYTHON_BINDINGS: + job.set_is_skip (True) - input_queue.put(job) - jobs = jobs + 1 - total_tests = total_tests + 1 + if options.verbose: + print "Queue %s" % test + + input_queue.put(job) + jobs = jobs + 1 + total_tests = total_tests + 1 elif len(options.pyexample): - # - # If you tell me to run a python example, I will try and run the example - # irrespective of any condition. - # - job = Job() - job.set_is_pyexample(True) - job.set_display_name(options.pyexample) - job.set_tmp_file_name("") - job.set_cwd(testpy_output_dir) - job.set_basedir(os.getcwd()) - job.set_tempdir(testpy_output_dir) - job.set_shell_command(options.pyexample) - job.set_build_path("") - - if options.verbose: - print "Queue %s" % options.pyexample + # Don't try to run this example if it isn't runnable. + example_name = os.path.basename(options.pyexample) + if example_name not in ns3_runnable_scripts: + print "Example %s is not runnable." % example_name + else: + # + # If you tell me to run a python example, I will try and run the example + # irrespective of any condition. + # + job = Job() + job.set_is_pyexample(True) + job.set_display_name(options.pyexample) + job.set_tmp_file_name("") + job.set_cwd(testpy_output_dir) + job.set_basedir(os.getcwd()) + job.set_tempdir(testpy_output_dir) + job.set_shell_command(options.pyexample) + job.set_build_path("") - input_queue.put(job) - jobs = jobs + 1 - total_tests = total_tests + 1 + if options.verbose: + print "Queue %s" % options.pyexample + + input_queue.put(job) + jobs = jobs + 1 + total_tests = total_tests + 1 # # Tell the worker threads to pack up and go home for the day. Each one diff --git a/wscript b/wscript index 2391793d5..691934763 100644 --- a/wscript +++ b/wscript @@ -753,10 +753,10 @@ def shutdown(ctx): out.write('#! /usr/bin/env python\n') out.write('\n') out.write('# Programs that are runnable.\n') - out.write('NS3_RUNNABLE_PROGRAMS = ' + str(env['NS3_RUNNABLE_PROGRAMS']) + '\n') + out.write('ns3_runnable_programs = ' + str(env['NS3_RUNNABLE_PROGRAMS']) + '\n') out.write('\n') out.write('# Scripts that are runnable.\n') - out.write('NS3_RUNNABLE_SCRIPTS = ' + str(env['NS3_RUNNABLE_SCRIPTS']) + '\n') + out.write('ns3_runnable_scripts = ' + str(env['NS3_RUNNABLE_SCRIPTS']) + '\n') out.write('\n') out.close()