summaryrefslogtreecommitdiffstats
path: root/atfexecute.py
blob: a60402bf3fb5a1f7a1adfd9c0dc8f512fe27b734 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""atfexecute
"""

import os.path
import sys
import parser
from atfglobals import GlobalObj

def _execute_testunit(testunit):
    """
    *) 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
    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

def execute():
    """
    *) Execute the TestsCases form TestUnits specified in TestRunInfo File
    """
    testruninfo_obj = GlobalObj.getTestrunInfoObj()
    testunits = testruninfo_obj.getTestUnits()
    for testunit in testunits:
        _execute_testunit(testunit)

    return 0

__all__ = ['execute']