apicompatanamdw/compatanalysercmd/checkbc/tsrc/testcheckbc.py
author shrivatsa
Mon, 27 Sep 2010 14:51:17 +0530
changeset 12 a0eee409ff14
permissions -rw-r--r--
Updates to CompatibilityAnalyser - The Tool should now work with Symbian^4 - Some minor bug fixes related to Qt headers in the Symbian Platform
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
     1
#
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
     2
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
     3
# All rights reserved.
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
     4
# This component and the accompanying materials are made available
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
     5
# under the terms of "Eclipse Public License v1.0"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
     6
# which accompanies this distribution, and is available
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
     8
#
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
     9
# Initial Contributors:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    11
#
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    12
# Contributors:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    13
#
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    14
# Description:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    15
#
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    16
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    17
import os
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    18
import time
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    19
import sys
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    20
import inspect
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    21
import testcases
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    22
import shutil
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    23
import platform
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    24
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    25
if os.name == 'nt':
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    26
    path = os.path.dirname(sys.argv[0])
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    27
else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    28
    path = os.getcwd()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    29
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    30
TC_DIR = path
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    31
TEMP_DIR = TC_DIR + os.sep + 'temp'
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    32
TOOLS_DIR = TC_DIR + os.sep + os.pardir + os.sep + os.pardir
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    33
EXEC_DIR = TC_DIR + os.sep + os.pardir + os.sep + "bin"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    34
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    35
time_taken = 0
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    36
total_time_taken = 0
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    37
totalCount = 0
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    38
timeval = time.strftime("%a %b %d, %Y at %H:%M:%S", time.localtime())
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    39
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    40
if os.environ.get('RVCT22BIN') is None:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    41
    print 'Environment Variable RVCT22BIN must be set before starting the test harness'
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    42
    sys.exit()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    43
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    44
report_file = 0
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    45
passed = 0
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    46
failed = 0
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    47
ostr = ""
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    48
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    49
def UpdateTimeTaken(tm):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    50
    global time_taken, total_time_taken
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    51
    time_taken = tm
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    52
    total_time_taken += tm
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    53
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    54
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    55
def write(key, res):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    56
    global passed
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    57
    global failed
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    58
    global totalCount
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    59
    global ostr
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    60
    totalCount = totalCount + 1
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    61
    ostr = ostr+"  <testcase classname=\"BCFilter\" name=\""+key+"\" time=\""+str(round(time_taken,3))+"\">\n"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    62
    if res[2] == 'PASSED':
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    63
        passed = passed + 1
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    64
    else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    65
        failed = failed + 1
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    66
        ostr = ostr+"    <failure message=\"Failed\" type=\"Failed\">Failed</failure>\n"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    67
    ostr = ostr+"    <expresults>"+res[0]+"</expresults>\n"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    68
    ostr = ostr+"    <actresults>"+res[1]+"</actresults>\n"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    69
    ostr = ostr+"  </testcase>\n"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    70
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    71
class registry:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    72
    _register = {}
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    73
    items = 0
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    74
    cur_item = -1
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    75
    keys = []
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    76
    def __init__(self):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    77
        pass
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    78
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    79
    def __iter__(self):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    80
        return self
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    81
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    82
    def __getitem__(self, item):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    83
        return self._register[item]
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    84
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    85
    def next(self):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    86
        if self.cur_item >= (self.items-1):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    87
            self.cur_item = -1
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    88
            raise StopIteration
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    89
        else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    90
            self.cur_item = self.cur_item + 1
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    91
            return tuple([ self.keys[self.cur_item],self._register[self.keys[self.cur_item]] ])
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    92
        
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    93
    def register(self, key, val):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    94
        self._register[key] = val
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    95
        self.items = self.items + 1
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    96
        self.keys.append(key)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    97
        
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    98
    def deregister(self, key):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
    99
        if self._register.has_key(key):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   100
            self._register.pop(key)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   101
            self.items = self.items - 1
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   102
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   103
    def next_entry(self):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   104
        if self.cur_item < (self.items-1):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   105
            self.cur_item = self.cur_item + 1
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   106
            return tuple([ self.keys[self.cur_item],self._register[self.keys[self.cur_item]] ])
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   107
        else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   108
            return tuple()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   109
        
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   110
    def prev_entry(self):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   111
        if self.cur_item != -1:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   112
            self.cur_item = self.cur_item - 1
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   113
            return tuple([ self.keys[self.cur_item], self._register[self.keys[self.cur_item]] ])
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   114
        else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   115
            return tuple()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   116
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   117
    def count():
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   118
        return self.items
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   119
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   120
def setUp(key):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   121
    print '\n---------------------------------------------------------------'
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   122
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   123
def tearDown():
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   124
    print '\n---------------------------------------------------------------'
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   125
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   126
def testAll(db):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   127
    global ostr
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   128
    result = 0
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   129
    os.chdir(TC_DIR)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   130
    for key, value in db:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   131
        print '\n---------------------------------------------------------------'
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   132
        stime = time.clock()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   133
        res = value()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   134
        etime = time.clock()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   135
        print '\n---------------------------------------------------------------'
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   136
        UpdateTimeTaken(etime-stime)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   137
        write(key, res)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   138
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   139
def register_tc(db):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   140
    index = 3
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   141
    if 'c' == sys.argv[2]:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   142
        index = 4 
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   143
    if len(sys.argv) > index:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   144
        cases = []
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   145
        file = open( sys.argv[index] )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   146
        for line in file:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   147
            cases.append(line.rstrip('\r\n').lower())
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   148
        file.close()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   149
    for key,value in inspect.getmembers(testcases):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   150
        if inspect.isfunction(value) and key.split('_')[0] == 'test':
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   151
            if len(sys.argv) > index:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   152
                if key in cases:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   153
                    db.register(key, value)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   154
            else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   155
                db.register(key, value)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   156
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   157
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   158
def open_results():
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   159
    if os.path.exists(REPORT) and os.name == 'nt':
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   160
        os.startfile(REPORT)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   161
    return
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   162
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   163
def write_header(file):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   164
    global failed
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   165
    global totalCount
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   166
    global total_time_taken
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   167
    file.write('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n')
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   168
    file.write('<?xml-stylesheet type="text/xsl" href="checkbctestresults.xsl"?>\n')
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   169
    file.write("<testsuite errors=\"0\" failures=\""+str(failed)+"\" hostname=\""+platform.node()+"\" name=\"BCFilter\" tests=\""+str(totalCount)+"\" time=\""+str(round(total_time_taken,3))+"\" timestamp=\""+str(timeval)+"\">\n")
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   170
    file.write("<properties>\n</properties>\n")
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   171
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   172
def write_footer(file, db):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   173
    global ostr
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   174
    file.write(ostr)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   175
    file.write("</testsuite>\n")
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   176
    file.close()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   177
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   178
def copy_toolset():
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   179
    dir = os.getcwd()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   180
    changed_TOOL_DIR = TOOLS_DIR;
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   181
    HA=""
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   182
    BCF=""
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   183
    LA=""
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   184
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   185
    file = open( sys.argv[1] )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   186
    cases = file.readlines()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   187
    file.close()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   188
    for tc in cases:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   189
        temp = tc.find('checkbc')
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   190
        if(temp!=-1):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   191
            if(tc.split('=')[1].split(';')[0]== 'trunk'):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   192
                changed_TOOL_DIR = changed_TOOL_DIR+ os.sep + os.pardir
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   193
            elif(tc.split('=')[1].split(';')[0]!= 'bin'):	
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   194
                changed_TOOL_DIR = changed_TOOL_DIR+ os.sep + os.pardir+ os.sep + os.pardir
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   195
                
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   196
    for tc in cases:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   197
        temp = tc.find('ha')
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   198
        if(temp != -1):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   199
            haDir = tc.split('=')[1].split(';')[0]
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   200
            if(haDir == 'trunk'):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   201
                HA = changed_TOOL_DIR+os.sep+"headeranalyser"+os.sep+"trunk"+os.sep+"bin"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   202
            elif(haDir != 'bin'):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   203
                HA = changed_TOOL_DIR+os.sep+"headeranalyser"+os.sep+"tags"+os.sep+haDir+os.sep+"bin"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   204
            else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   205
                HA = changed_TOOL_DIR+os.sep+"headeranalyser"+os.sep+"bin"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   206
                
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   207
    for tc in cases:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   208
        temp = tc.find('bcf')
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   209
        if(temp != -1):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   210
            bcDir = tc.split('=')[1].split(';')[0]
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   211
            if(bcDir == 'trunk'):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   212
                BCF = changed_TOOL_DIR+os.sep+"bcfilter"+os.sep+"trunk"+os.sep+"bin"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   213
            elif(bcDir != 'bin'):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   214
                BCF = changed_TOOL_DIR+os.sep+"bcfilter"+os.sep+"tags"+os.sep+bcDir+os.sep+"bin"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   215
            else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   216
                BCF = changed_TOOL_DIR+os.sep+"bcfilter"+os.sep+"bin"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   217
                
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   218
    for tc in cases:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   219
        temp = tc.find('la')
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   220
        if(temp != -1):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   221
            laDir = tc.split('=')[1].split(';')[0]
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   222
            if(laDir == 'trunk'):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   223
                LA = changed_TOOL_DIR+os.sep+"libraryanalyser"+os.sep+"trunk"+os.sep+"bin"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   224
            elif(laDir != 'bin'):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   225
                LA = changed_TOOL_DIR+os.sep+"libraryanalyser"+os.sep+"tags"+os.sep+laDir+os.sep+"bin"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   226
            else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   227
                LA = changed_TOOL_DIR+os.sep+"ordinalchecker"+os.sep+"bin"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   228
                
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   229
    os.chdir( TC_DIR + os.sep + os.pardir )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   230
    if not os.path.exists(EXEC_DIR):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   231
        os.makedirs(EXEC_DIR)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   232
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   233
    copy(HA+os.sep+"forced_9.1.h" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   234
    copy(HA+os.sep+"forced_9.2.h" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   235
    copy(HA+os.sep+"forced_9.3.h" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   236
    copy(HA+os.sep+"forced_9.4.h" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   237
    copy(HA+os.sep+"forced_9.4v2.h" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   238
    copy(HA+os.sep+"forced_10.1.h" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   239
    copy(HA+os.sep+"forced_mobileruntime.h" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   240
    copy(HA+os.sep+"forced_kernel.h" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   241
    copy(HA+os.sep+"forced_shai.h" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   242
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   243
    if os.name == 'nt':
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   244
        copy(BCF+os.sep+"bcfilter.exe" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   245
        copy(BCF+os.sep+"libxerces-c2_7_0.dll" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   246
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   247
        copy(HA+os.sep+"ha.exe" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   248
        copy(HA+os.sep+"ha_gccxml_cc1plus.exe" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   249
        copy(HA+os.sep+"boost_thread-gcc-mt-1_33_1.dll" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   250
        copy(HA+os.sep+"mingwm10.dll" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   251
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   252
        copy(LA+os.sep+"la.exe" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   253
        copy(LA+os.sep+"cfilt.exe" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   254
    else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   255
        copy(BCF+os.sep+"bcfilter" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   256
        copy(BCF+os.sep+"libxerces-c2_7_0.dll" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   257
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   258
        copy(HA+os.sep+"ha" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   259
        copy(HA+os.sep+"ha_gccxml_cc1plus" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   260
        copy(HA+os.sep+"boost_thread-gcc-mt-1_33_1.dll" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   261
        copy(HA+os.sep+"mingwm10.dll" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   262
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   263
        copy(LA+os.sep+"la" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   264
        copy(LA+os.sep+"cfilt" ,"bin"+os.sep )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   265
    os.chdir(dir)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   266
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   267
def copy(src, dst):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   268
    try:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   269
        shutil.copy(src, dst )
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   270
    except IOError, e:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   271
        print e
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   272
        shutil.rmtree(EXEC_DIR)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   273
        sys.exit(1)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   274
        
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   275
if __name__ == '__main__':
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   276
    #Check for proper python version and then continue execution
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   277
    if not "2.4" <= platform.python_version() < "3.0":
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   278
        python_error()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   279
    lst = []
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   280
    db = registry()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   281
    if len(sys.argv) < 3:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   282
        print "Usage: TestCheckBC.py <toolPathFile> [c] <outputfile> [<testcasefile>]"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   283
        print "<toolPathFile> - Text file with info regarding which path to be taken for each component."
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   284
        print "                 These can be either bin / trunk / tag number"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   285
        print "                 - bin, if it is for S60 Release"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   286
        print "                 - trunk, if executable should be taken from trunk "
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   287
        print "                 - tag number, specify the tag no from which executable should be taken"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   288
        print "[c] - Optional parameter to Copy binaries, if not already existing."
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   289
        print "<outputfile> - report filename eg: report.xml"
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   290
        print "[<testcasefile>] - Optional parameter. Text file with list of test cases mentioned, those to be executed."
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   291
        sys.exit(1)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   292
    if not os.path.exists(TEMP_DIR):        
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   293
        os.makedirs(TEMP_DIR)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   294
    if not os.path.exists(TEMP_DIR + os.sep + 'results'):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   295
        os.makedirs(TEMP_DIR + os.sep + 'results')
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   296
    
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   297
    if 'c' == sys.argv[2]:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   298
        copy_toolset()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   299
        if(len(sys.argv)== 3):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   300
            print '---------files copied--------'
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   301
            sys.exit(0)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   302
        REPORT = TC_DIR + os.sep + 'reports' + os.sep + sys.argv[3]
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   303
    else:
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   304
        if not os.path.exists(EXEC_DIR):
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   305
            copy_toolset()
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   306
            print 'Toolset not found. New copy created'
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   307
        REPORT = TC_DIR + os.sep + 'reports' + os.sep + sys.argv[2]
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   308
    	
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   309
    register_tc(db)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   310
    report_file = open(REPORT, 'w')
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   311
    testAll(db)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   312
    write_header(report_file)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   313
    write_footer(report_file, db)
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   314
    shutil.rmtree(TEMP_DIR) 
a0eee409ff14 Updates to CompatibilityAnalyser
shrivatsa
parents:
diff changeset
   315
    open_results()