summaryrefslogtreecommitdiffstats
path: root/ATFExecute.py
diff options
context:
space:
mode:
Diffstat (limited to 'ATFExecute.py')
-rwxr-xr-xATFExecute.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/ATFExecute.py b/ATFExecute.py
new file mode 100755
index 0000000..0f3a913
--- /dev/null
+++ b/ATFExecute.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import ATFUtils
+
+def execute():
+ """
+ Description:
+ Execute the TestsCases for Specified TestUnits.
+ Keyword is used to select the testscases under each TestUnit
+
+ Parameters:
+ None
+
+ Returns:
+ Success: 0 ( Successful Execution of all TestUnits )
+ Failure: 1 ( Unsuccessful Test Runs )
+ """
+
+ testunits = ATFUtils.TestsObj.get_testunits()
+ atfroot = ATFUtils.get_environ('ATF_ROOT')
+
+ for unit in testunits:
+ testdir = atfroot + "/Glusterfs/TestUnits/" + unit
+ cwd = os.getcwd()
+ try:
+ os.chdir(testdir)
+
+ except OSError as (errno, errstr):
+ ATFUtils.Logger.warning("OSError: [Error %d] %s: %s" % (errno,
+ errstr, testdir))
+ ATFUtils.Logger.warning("Ignoring TestUnit:" + testdir)
+ continue
+
+ else:
+ ATFUtils.set_environ(ATF_WORKUNIT=testdir)
+ try:
+ os.mkdir('Log')
+
+ except OSError as (errno, errstr):
+ ATFUtils.Logger.debug("Log Directory already exist")
+
+ ATFUtils.LogObj.add_detaillog_handler('ATF_LOG')
+
+ ATFUtils.Logger.info("Starting Tests in TestUnit: " + testdir)
+
+ sys.path.append(testdir)
+ import Main
+
+ returncode = Main.main()
+
+ if returncode:
+ ATFUtils.Logger.error("Test Runs Unsuccessful in TestUnit: " +
+ testdir)
+ ATFUtils.Logger.info("Ending Tests in TestUnit: " + testdir)
+ ATFUtils.LogObj.remove_detaillog_handler('ATF_LOG')
+ continue
+
+ else:
+ ATFUtils.Logger.info("Test Runs Successful in TestUnit: " +
+ testdir)
+ ATFUtils.Logger.info("Ending Tests in TestUnit: " + testdir)
+ ATFUtils.LogObj.remove_detaillog_handler('ATF_LOG')
+ continue
+
+ return 0
+