apicompatanamdw/compatanalysercmd/libraryanalyser/tsrc/scripts/latestrun.py
changeset 12 a0eee409ff14
equal deleted inserted replaced
11:bdd2944b914b 12:a0eee409ff14
       
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 #
       
    16 
       
    17 import sys
       
    18 import os
       
    19 import shutil
       
    20 
       
    21 LATEST_GCCE_BIN = os.pardir+os.sep+"tsrc"+os.sep+"bin"
       
    22 LATEST_GCC_BIN = os.pardir+os.sep+"tsrc"+os.sep+"bin"
       
    23 
       
    24 
       
    25 TC_NUM = sys.argv[1]
       
    26 TC_FOLDER = os.getcwd()+os.sep+"TC"+os.sep+TC_NUM
       
    27 SCRIPT_DIR = TC_FOLDER+os.sep+"scripts"+os.sep
       
    28 BBCRESULTS = os.pardir+os.sep+os.pardir+os.sep+"checkbc"+os.sep+"results"+os.sep+"BBCResults.xsl"
       
    29 
       
    30 if len(sys.argv) == 1:
       
    31     print "Usage: latestrun testcase_name"
       
    32     sys.exit()
       
    33     
       
    34 if not os.path.exists(TC_FOLDER):
       
    35     print "Test case directory cannot be found: " + TC_FOLDER
       
    36     sys.exit()
       
    37     
       
    38 if not os.path.exists(SCRIPT_DIR+"prepare.txt"):
       
    39     print "Test case directory cannot be found: " + SCRIPT_DIR + "prepare.txt"
       
    40     sys.exit()
       
    41     
       
    42 file = open( SCRIPT_DIR+"prepare.txt" )
       
    43 BASENAME = ((file.readline()).replace("\\",os.sep).replace("/",os.sep)).rstrip('\n\r ')
       
    44 BASEDIR = ((file.readline()).replace("\\",os.sep).replace("/",os.sep)).rstrip('\n\r ')
       
    45 CURRNAME = ((file.readline()).replace("\\",os.sep).replace("/",os.sep)).rstrip('\n\r ')
       
    46 CURRDIR = ((file.readline()).replace("\\",os.sep).replace("/",os.sep)).rstrip('\n\r ')
       
    47 RESDIR = ((file.readline()).replace("\\",os.sep).replace("/",os.sep)).rstrip('\n\r ')
       
    48 TOOLCHAIN = ((file.readline()).replace("\\",os.sep).replace("/",os.sep)).rstrip('\n\r ')
       
    49 USELIBS = ((file.readline()).replace("\\",os.sep).replace("/",os.sep)).rstrip('\n\r ')
       
    50 BASEDLLDIR = ((file.readline()).replace("\\",os.sep).replace("/",os.sep)).rstrip('\n\r ')
       
    51 CURRDLLDIR = ((file.readline()).replace("\\",os.sep).replace("/",os.sep)).rstrip('\n\r ')
       
    52 file.close()
       
    53 
       
    54 
       
    55 print "Checking test case directories..."
       
    56 basedirlist = BASEDIR.split(';')
       
    57 BASEDIRS = ""
       
    58 for d in basedirlist:
       
    59 	if d != "":
       
    60 		if not os.path.exists(TC_FOLDER+os.sep+d):
       
    61 			print "Cannot find base platform directory: " + TC_FOLDER+os.sep+d
       
    62 			sys.exit()
       
    63 		if BASEDIRS != "":
       
    64 			BASEDIRS = BASEDIRS + ";"
       
    65 		BASEDIRS = BASEDIRS+TC_FOLDER+os.sep+d
       
    66 
       
    67 curdirlist = CURRDIR.split(';')
       
    68 CURRDIRS = ""
       
    69 for d in curdirlist:
       
    70 	if d != "":
       
    71 		if not os.path.exists(TC_FOLDER+os.sep+d):
       
    72 			print "Cannot find current platform directory: " + TC_FOLDER+os.sep+d
       
    73 			sys.exit()
       
    74 		if CURRDIRS != "":
       
    75 			CURRDIRS = CURRDIRS + ";"
       
    76 		CURRDIRS = CURRDIRS+TC_FOLDER+os.sep+d
       
    77 
       
    78 basedlldirlist = BASEDLLDIR.split(';')
       
    79 BASEDLLDIRS = ""
       
    80 for d in basedlldirlist:
       
    81 	if d != "":
       
    82 		if not os.path.exists(TC_FOLDER+os.sep+d):
       
    83 			BASEDLLDIRS = ""
       
    84 		else:
       
    85 			if BASEDLLDIRS != "":
       
    86 				BASEDLLDIRS = BASEDLLDIRS + ";"
       
    87 			BASEDLLDIRS = BASEDLLDIRS+TC_FOLDER+os.sep+d
       
    88 
       
    89 curdlldirlist = CURRDLLDIR.split(';')
       
    90 CURRDLLDIRS = ""
       
    91 for d in curdlldirlist:
       
    92 	if d != "":
       
    93 		if not os.path.exists(TC_FOLDER+os.sep+d):
       
    94 			CURRDLLDIRS = ""
       
    95 		else:
       
    96 			if CURRDLLDIRS != "":
       
    97 				CURRDLLDIRS = CURRDLLDIRS + ";"
       
    98 			CURRDLLDIRS = CURRDLLDIRS+TC_FOLDER+os.sep+d
       
    99 
       
   100 if not os.path.exists(TC_FOLDER+os.sep+RESDIR):
       
   101     print "Cannot find result directory: " + TC_FOLDER+os.sep+RESDIR
       
   102     sys.exit()    
       
   103 TC_BBCRESULTS =  TC_FOLDER+os.sep+RESDIR+os.sep +"BBCResults.xsl"
       
   104 
       
   105 if not os.path.exists( BBCRESULTS):
       
   106     print "Cannot find BBCResults.xsl"
       
   107 else:
       
   108     shutil.copyfile(BBCRESULTS,TC_BBCRESULTS)
       
   109 
       
   110 if TOOLCHAIN == "GCCE":
       
   111     LATEST_TOOLDIR = LATEST_GCCE_BIN
       
   112 elif TOOLCHAIN == "GCC":
       
   113     if os.name == "posix":
       
   114         print "Test case not supported on Linux"
       
   115         sys.exit()
       
   116     LATEST_TOOLDIR = LATEST_GCC_BIN 
       
   117 elif TOOLCHAIN == "RVCT":
       
   118     LATEST_TOOLDIR = ""
       
   119 else:
       
   120 	  TOOLCHAIN = "GCCE"
       
   121 	  LATEST_TOOLDIR ="" 
       
   122 
       
   123 print "---- Starting Library Analyser ----"
       
   124 os.chdir(os.pardir+os.sep+"bin")
       
   125 
       
   126 if os.name == "posix":
       
   127     LATEST_CFILT_BIN = "cfilt"
       
   128 else:
       
   129     LATEST_CFILT_BIN = "cfilt.exe"
       
   130     
       
   131 lib_command = ""
       
   132 if BASEDIRS != "":
       
   133 	lib_command = " -baselinelibdir " + "\"" + BASEDIRS + "\""
       
   134 if CURRDIRS != "":
       
   135 	lib_command = lib_command + " -currentlibdir " + "\""+ CURRDIRS + "\""
       
   136 	
       
   137 dll_command = ""
       
   138 if BASEDLLDIRS != "":
       
   139 	dll_command=" -baselinedlldir " + "\"" + BASEDLLDIRS + "\""
       
   140 if CURRDLLDIRS != "":
       
   141 	dll_command = dll_command + " -currentdlldir " + "\"" + CURRDLLDIRS + "\""
       
   142     
       
   143 RESULTS_DIR = TC_FOLDER + os.sep + RESDIR + os.sep
       
   144 if os.path.exists(RESULTS_DIR+"results.xml"):
       
   145     os.remove(RESULTS_DIR+"results.xml")
       
   146 
       
   147 if LATEST_TOOLDIR == "":
       
   148 	cmd="la "+TOOLCHAIN+lib_command+dll_command+" -baselineversion \""+BASENAME+"\" -currentversion \""+CURRNAME+"\" -reportfile \""+TC_FOLDER+os.sep+"results"+os.sep+"results.xml\" -temp \""+os.getcwd()+os.sep+"temp\" -set \""+TC_FOLDER+os.sep+"scripts"+os.sep+"config.txt\"" 
       
   149 elif TOOLCHAIN == "RVCT":
       
   150   cmd="la "+TOOLCHAIN+lib_command+dll_command+" -baselineversion \""+BASENAME+"\" -currentversion \""+CURRNAME+"\" -reportfile \""+TC_FOLDER+os.sep+"results"+os.sep+"results.xml\" -temp \""+os.getcwd()+os.sep+"temp\" -set \""+TC_FOLDER+os.sep+"scripts"+os.sep+"config.txt\""
       
   151 else:
       
   152 	cmd="la "+TOOLCHAIN+lib_command+dll_command+" -baselineversion \""+BASENAME+"\" -currentversion \""+CURRNAME+"\" -reportfile \""+TC_FOLDER+os.sep+"results"+os.sep+"results.xml\" -temp \""+os.getcwd()+os.sep+"temp\" -set \""+TC_FOLDER+os.sep+"scripts"+os.sep+"config.txt\""
       
   153 
       
   154 print cmd
       
   155 if USELIBS == "TRUE":
       
   156     cmd = cmd + " --uselibs"
       
   157 if TOOLCHAIN == "RVCT":
       
   158     cmd = cmd + " -cfilt " + LATEST_CFILT_BIN
       
   159 
       
   160 os.system(cmd)
       
   161 os.chdir(os.pardir+os.sep+"tsrc")
       
   162 sys.exit()
       
   163 
       
   164