bindings, test: fix for python tests and Cppyy test case (fixes #724)
This commit is contained in:
@@ -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():
|
||||
|
||||
9
test.py
9
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
|
||||
|
||||
@@ -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):
|
||||
"""!
|
||||
|
||||
Reference in New Issue
Block a user