diff options
author | Shwetha-H-Panduranga <shwetha@gluster.com> | 2011-12-12 11:29:47 +0530 |
---|---|---|
committer | Shwetha-H-Panduranga <shwetha@gluster.com> | 2011-12-12 11:29:47 +0530 |
commit | 689f862f24f949361603a808250ae3f7ec9f40f6 (patch) | |
tree | 37894a4807f9fcf1edab4ad846e57d8ba339cf13 /atfexecute.py | |
parent | d7524954807ed63ed05762a945e7e6956c929eda (diff) |
Changes to logger class, Using the logger class in the framework, adding new global values, Changes made to argument parser, testruninfo
Diffstat (limited to 'atfexecute.py')
-rw-r--r-- | atfexecute.py | 77 |
1 files changed, 40 insertions, 37 deletions
diff --git a/atfexecute.py b/atfexecute.py index a60402b..c793cbb 100644 --- a/atfexecute.py +++ b/atfexecute.py @@ -1,53 +1,56 @@ """atfexecute """ - import os.path import sys -import parser +import imp from atfglobals import GlobalObj +import pdb -def _execute_testunit(testunit): +def _execute_testunit(testunitname): """ *) Parse the testcaseslist file in the 'testunit' and select test cases specified for testing 'glusterversion' *) Call Main.py of 'testunit' to execute the testcases. """ return_status = 1 - testruninfo_obj = GlobalObj.getTestrunInfoObj() - atfdir = testruninfo_obj.getAtfDir() - testunit_abspath = atfdir + "/TestUnits/" + testunit - - testenvfile = testunit_abspath + "/testenv.cfg" - testcaseslistfile = testunit_abspath + "/testcaseslist" - - if not os.path.exists(testenvfile): - default_testenvfile = atfdir + "testenv.cfg" - if not os.path.exists(testenvfile): - print "Skipping TestUnit %s . TestEnv File Not Found" % testenvfile - return return_status - else: - testenvfile = default_testenvfile - - if not os.path.exists(testcaseslistfile): - print "Skipping TestUnit %s" % testunit - return return_status + logger = GlobalObj.getLoggerObj() + detaillog_file = GlobalObj.detaillog_file + detaillog_level = GlobalObj.detaillog_level + atfdir = GlobalObj.atfdir + testunits_maindir = GlobalObj.testunits_maindir + testunit_mainmodule = GlobalObj.testunit_mainmodule + testunit_abspath = os.path.join(atfdir, testunits_maindir, testunitname) + + + _file, path, description = imp.find_module(testunit_mainmodule, + [testunit_abspath]) + + if _file is None: + logger.error("TestUnit: %s not found" % testunit_abspath) + return 0 + + sys.path.append(testunit_abspath) + try: + module = imp.load_module(testunit_mainmodule, _file, path, description) + + except ImportError: + logger.error("Unable to load '%s' in testunit %s" % + (testunit_mainmodule, testunitname)) + logger.error("%s execution Failed" % testunitname) + return_status = 0 + else: - testcaseslist = [] - testcasespassed = None - testcasesfailed = None - totaltestcases = None - - testcaseslist = parser.parse_testcaseslist_file(testcaseslistfile) - if not testcaseslist: - print "Skipping TestUnit %s. No testcases to execute" % testunit - return return_status - else: - sys.path.append(testunit_abspath) - import Main - print "Executing TestUnit: %s" % testunit - print "-" * 50 - return_status = Main.main(testenvfile, *testcaseslist) - return return_status + detaillog_abspath = os.path.join(testunit_abspath, detaillog_file) + if logger.addDetaillogHandler(detaillog_abspath, detaillog_level): + logger.error("Unbale to add Detaillog Handler for testunit: %s" % + testunitname) + return_status = module.main() + logger.removelogHandler('detaillog') + + finally: + _file.close() + sys.path.remove(testunit_abspath) + return return_status def execute(): """ |