Merge "[ONOS-2424] Move flowTable functions from remotemininetdriver to mininetdriver"
diff --git a/TestON/bin/cli.py b/TestON/bin/cli.py
index b515486..ffe9d67 100755
--- a/TestON/bin/cli.py
+++ b/TestON/bin/cli.py
@@ -472,7 +472,8 @@
converter = updatedriver.UpdateDriver()
if config == '':
- path = re.sub("(bin)$", "", os.getcwd())
+ location = os.path.abspath( os.path.dirname( __file__ ) )
+ path = re.sub( "(bin)$", "", location )
config = path + "/config/updatedriver.cfg"
configDict = converter.configparser(config)
diff --git a/TestON/config/teston.cfg b/TestON/config/teston.cfg
index 82c96dc..c7442f6 100644
--- a/TestON/config/teston.cfg
+++ b/TestON/config/teston.cfg
@@ -1,18 +1,18 @@
<config>
- <parser>
- <file>../core/xmlparser.py</file>
+ <parser>
+ <file>core/xmlparser.py</file>
<class>xmlparser</class>
</parser>
<mail_to>hari@onlab.us</mail_to>
- <logger>
- <file>../core/logger.py</file>
+ <logger>
+ <file>core/logger.py</file>
<class>Logger</class>
</logger>
-
+
<responseparser>
- <file>../core/jsonparser.py</file>
+ <file>core/jsonparser.py</file>
<class>JsonParser</class>
</responseparser>
</config>
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 067d268..5bc702b 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -37,16 +37,17 @@
import openspeak
import subprocess
global path, drivers_path, core_path, tests_path,logs_path
-path = re.sub("(core|bin)$", "", os.getcwd())
+location = os.path.abspath( os.path.dirname( __file__ ) )
+path = re.sub( "(core|bin)$", "", location )
drivers_path = path+"drivers/"
core_path = path+"core"
tests_path = path+"tests"
logs_path = path+"logs/"
config_path = path + "config/"
-sys.path.append(path)
-sys.path.append( drivers_path)
-sys.path.append(core_path )
-sys.path.append(tests_path)
+sys.path.append( path )
+sys.path.append( drivers_path )
+sys.path.append( core_path )
+sys.path.append( tests_path )
from core.utilities import Utilities
from core.Thread import Thread
@@ -624,15 +625,16 @@
verifyOnosCell(options)
def verifyTest(options):
- if options.testname:
- main.TEST = options.testname
- main.classPath = "tests."+main.TEST+"."+main.TEST
- main.tests_path = tests_path
- elif options.example :
- main.TEST = options.example
- main.tests_path = path+"/examples/"
- main.classPath = "examples."+main.TEST+"."+main.TEST
- else :
+ try:
+ if options.testname:
+ main.TEST = options.testname
+ main.classPath = "tests."+main.TEST+"."+main.TEST
+ main.tests_path = tests_path
+ elif options.example:
+ main.TEST = options.example
+ main.tests_path = path+"/examples/"
+ main.classPath = "examples."+main.TEST+"."+main.TEST
+ except AttributeError:
print "Test or Example not specified please specify the --test <test name > or --example <example name>"
main.exit()
@@ -713,18 +715,22 @@
main.openspeak = openspeak.OpenSpeak()
openspeakfile = main.testDir+"/" + main.TEST + "/" + main.TEST + ".ospk"
testfile = main.testDir+"/" + main.TEST + "/" + main.TEST + ".py"
- if os.path.exists(openspeakfile) :
+ if os.path.exists(openspeakfile):
+ # Openspeak file found, compiling to python
main.openspeak.compiler(openspeakfile=openspeakfile,writetofile=1)
elif os.path.exists(testfile):
- print ''
+ # No openspeak found, using python file instead
+ pass
else:
- print "\nThere is no :\""+main.TEST+"\" test, Please Provide OpenSpeak Script/ test script"
+ print "\nThere is no \""+main.TEST+"\" test script.\nPlease provide a " +\
+ "Python or OpenSpeak test script in the tests folder: " +\
+ main.testDir+"/" + main.TEST + "/"
__builtin__.testthread = None
main.exit()
try :
testModule = __import__(main.classPath, globals(), locals(), [main.TEST], -1)
except(ImportError):
- print "There was an import error, it might mean that there is no test like "+main.TEST
+ print "There was an import error, it might mean that there is no test named "+main.TEST
main.exit()
testClass = getattr(testModule, main.TEST)
@@ -754,28 +760,26 @@
'''
confighash = main.configDict
if 'file' in confighash['config']['parser'] and 'class' in confighash['config']['parser']:
- if confighash['config']['parser']['file'] != None or confighash['config']['parser']['class']!= None :
- if os.path.exists(confighash['config']['parser']['file']) :
- module = re.sub(r".py\s*$","",confighash['config']['parser']['file'])
+ path = confighash['config']['parser']['file']
+ if path != None or confighash['config']['parser']['class']!= None:
+ try:
+ module = re.sub( r".py\s*$", "", path )
moduleList = module.split("/")
newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
- try :
- parsingClass = confighash['config']['parser']['class']
- parsingModule = __import__(newModule, globals(), locals(), [parsingClass], -1)
- parsingClass = getattr(parsingModule, parsingClass)
- main.parser = parsingClass()
- #hashobj = main.parser.parseParams(main.classPath)
- if hasattr(main.parser,"parseParams") and hasattr(main.parser,"parseTopology") and hasattr(main.parser,"parse") :
- pass
- else:
- main.exit()
- except ImportError:
- print sys.exc_info()[1]
+ parsingClass = confighash['config']['parser']['class']
+ parsingModule = __import__(newModule, globals(), locals(), [parsingClass], -1)
+ parsingClass = getattr(parsingModule, parsingClass)
+ main.parser = parsingClass()
+ #hashobj = main.parser.parseParams(main.classPath)
+ if hasattr(main.parser,"parseParams") and hasattr(main.parser,"parseTopology") and hasattr(main.parser,"parse"):
+ pass
+ else:
+ print "Invalid parser format"
main.exit()
- else :
- print "No Such File Exists !!"+ confighash['config']['parser']['file'] +"using default parser"
+ except ImportError:
+ print "Could not find the file " + path + " using default parser."
load_defaultParser()
- elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :
+ elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None:
load_defaultParser()
else:
load_defaultParser()
@@ -808,22 +812,19 @@
'''
confighash = main.configDict
if 'file' in confighash['config']['logger'] and 'class' in confighash['config']['logger']:
- if confighash['config']['logger']['file'] != None or confighash['config']['logger']['class']!= None :
- if os.path.exists(confighash['config']['logger']['file']) :
- module = re.sub(r".py\s*$","",confighash['config']['logger']['file'])
+ path = confighash['config']['logger']['file']
+ if path != None or confighash['config']['logger']['class']!= None :
+ try:
+ module = re.sub( r".py\s*$", "", path )
moduleList = module.split("/")
newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]])
- try :
- loggerClass = confighash['config']['logger']['class']
- loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1)
- loggerClass = getattr(loggerModule, loggerClass)
- main.logger = loggerClass()
- #hashobj = main.parser.parseParams(main.classPath)
-
- except ImportError:
- print sys.exc_info()[1]
- else :
- print "No Such File Exists !!"+confighash['config']['logger']['file']+ "Using default logger"
+ loggerClass = confighash['config']['logger']['class']
+ loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1)
+ loggerClass = getattr(loggerModule, loggerClass)
+ main.logger = loggerClass()
+ #hashobj = main.parser.parseParams(main.classPath)
+ except ImportError:
+ print "Could not find the file " + path + " using default logger."
load_defaultlogger()
elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None :
load_defaultlogger()