diff --git a/src/flow-monitor/examples/wifi-olsr-flowmon.py b/src/flow-monitor/examples/wifi-olsr-flowmon.py index 603045b65..736d8984c 100644 --- a/src/flow-monitor/examples/wifi-olsr-flowmon.py +++ b/src/flow-monitor/examples/wifi-olsr-flowmon.py @@ -41,7 +41,7 @@ def main(argv): from ctypes import c_int, c_bool NumNodesSide = c_int(2) - Plot = c_bool(True) + Plot = c_bool(False) Results = "output.xml" cmd = ns.cppyy.gbl.GetCommandLine(__file__, NumNodesSide, Plot, Results) cmd.Parse(argv) @@ -170,7 +170,7 @@ def main(argv): print (monitor.SerializeToXmlFile(Results, True, True)) - if Plot is not None: + if Plot: import pylab delays = [] for flow_id, flow_stats in monitor.GetFlowStats(): diff --git a/test.py b/test.py index a274d5492..67232b22e 100755 --- a/test.py +++ b/test.py @@ -1641,10 +1641,19 @@ def run_tests(): total_tests = total_tests + 1 elif len(options.pyexample): + # Find the full relative path to file if only a partial path has been given. + if not os.path.exists(options.pyexample): + import glob + files = glob.glob("./**/%s" % options.pyexample, recursive=True) + if files: + options.pyexample = files[0] + # 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) + elif not os.path.exists(options.pyexample): + print("Example %s does not exist." % example_name) else: # # If you tell me to run a python example, I will try and run the example diff --git a/utils/tests/test-ns3.py b/utils/tests/test-ns3.py index c10078ab8..b9e8ea804 100644 --- a/utils/tests/test-ns3.py +++ b/utils/tests/test-ns3.py @@ -1887,6 +1887,35 @@ class NS3BuildBaseTestCase(NS3BaseTestCase): # Maybe check the built binary for shared library references? Using objdump, otool, etc NS3BuildBaseTestCase.cleaned_once = False + def test_12_CppyyBindings(self): + """! + Test if we can use python bindings + @return None + """ + try: + import cppyy + except ModuleNotFound: + self.skipTest("Cppyy was not found") + + # First enable examples and static build + return_code, stdout, stderr = run_ns3( + "configure -G \"Unix Makefiles\" --enable-python-bindings") + + # If configuration passes, we are half way done + self.assertEqual(return_code, 0) + + # Then build and run tests + return_code, stdout, stderr = run_program("test.py", "", python=True) + self.assertEqual(return_code, 0) + + # Then try to run a specific test + return_code, stdout, stderr = run_program("test.py", "-p mixed-wired-wireless", python=True) + self.assertEqual(return_code, 0) + + # Then try to run a specific test with the full relative path + return_code, stdout, stderr = run_program("test.py", "-p ./examples/wireless/mixed-wired-wireless", python=True) + self.assertEqual(return_code, 0) + class NS3ExpectedUseTestCase(NS3BaseTestCase): """!