btservices_plat/bluetooth_engine_settings_api/tsrc/LC_ATS3DropGen.py
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     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 os
       
    18 import sys
       
    19 import string
       
    20 from xml.dom.minidom import Document
       
    21 import re
       
    22 
       
    23 TRUE    = 1
       
    24 FALSE   = 0
       
    25 
       
    26 #Parameter Parsing
       
    27 NONEOPTION      = 0
       
    28 PATHOPTION      = 1
       
    29 IMAGEPATHOPTION = 2
       
    30 TARGETOPTION    = 3
       
    31 PLUGINRSCOPTION = 4
       
    32 HARNESSOPTION   = 5
       
    33 STIFTYPEOPTION  = 6
       
    34 
       
    35 pluginrscs = []
       
    36 testspath = ""
       
    37 imagepath = ""
       
    38 target = ""
       
    39 targethost = ""
       
    40 harness = ""
       
    41 stiftype = ""
       
    42 
       
    43 index = 1
       
    44 argnumber = len(sys.argv)
       
    45 if((argnumber < 2) or (sys.argv[1] == "HELP") or (sys.argv[1] == "help") or (sys.argv[1] == "Help")or (sys.argv[1] == "-HELP") or (sys.argv[1] == "-help") or (sys.argv[1] == "-Help")):
       
    46     print "\n"
       
    47     print "********** DropGenerator Tool Usage Manual ********** "
       
    48     print ""
       
    49     print " -------- THIS TOOL IS USED FOR: --------"
       
    50     print "     - Building the test module "
       
    51     print "     - Create the ATS3Drop folder under tsrc folder"
       
    52     print "     - Generate test.xml file under tsrc folder"
       
    53     print "     - Generate testdrop.zip file including ATS3Drop and test.xml"
       
    54     print ""
       
    55     print " -------- PARAMETERS TO BE PASSED TO THE TOOL: -------- \n"
       
    56     print " dropgenerator.py -PATH <complete path of tests folder>"
       
    57     print "                 -IMAGEPATH <complete path of the images>"
       
    58     print "                 -TARGET <target hardware type eg: devlon>"
       
    59     print "                 [-PLUGINRSCS <list of ecom plugin resources files>]"
       
    60     print "                 -HARNESS <test harness used eg: STIF>"
       
    61     print "                 -STIFTYPE <type of STIF test module used, if Harness is STIF>"
       
    62     print "                     Supported STIF Types: Testscripter, Hardcoded"
       
    63     sys.exit()
       
    64 
       
    65 # read paramters
       
    66 option = NONEOPTION
       
    67 for index in range(len(sys.argv)):
       
    68     param = sys.argv[index]
       
    69     if((param == "-PATH") or (param == "-path") or (param == "-Path")):
       
    70         option = PATHOPTION
       
    71         param = sys.argv[index]
       
    72         continue
       
    73     if((param == "-IMAGEPATH") or (param == "-imagepath") or (param == "-Imagepath")):
       
    74         option = IMAGEPATHOPTION
       
    75         param = sys.argv[index]
       
    76         continue    
       
    77     elif((param == "-TARGET") or (param == "-target") or (param == "-Target")):
       
    78         option = TARGETOPTION
       
    79         param = sys.argv[index]
       
    80         continue
       
    81     elif((param == "-PLUGINRSCS") or (param == "-pluginrscs") or (param == "-Pluginrscs")):
       
    82         option = PLUGINRSCOPTION
       
    83         param = sys.argv[index]
       
    84         continue
       
    85     elif((param == "-DATAFILES") or (param == "-datafiles") or (param == "-Datafiles")):
       
    86         option = DATAFILESOPTION
       
    87         param = sys.argv[index]
       
    88         continue
       
    89     
       
    90     elif((param == "-HARNESS") or (param == "-harness") or (param == "-Harness")):
       
    91         option = HARNESSOPTION
       
    92         param = sys.argv[index]
       
    93         continue
       
    94 
       
    95     elif((param == "-STIFTYPE") or (param == "-Stiftype") or (param == "-stiftype")):
       
    96         option = STIFTYPEOPTION
       
    97         param = sys.argv[index]
       
    98         continue    
       
    99 
       
   100     if(option == PATHOPTION):
       
   101         testspath = param
       
   102 
       
   103     if(option == IMAGEPATHOPTION):
       
   104         imagepath = param
       
   105 
       
   106     if(option == TARGETOPTION):
       
   107         target = param
       
   108         
       
   109     if(option == PLUGINRSCOPTION):
       
   110         pluginrscs.append(param)
       
   111 
       
   112     if(option == HARNESSOPTION):
       
   113         harness = param
       
   114 
       
   115     if(option == STIFTYPEOPTION):
       
   116         stiftype = param
       
   117     
       
   118 #validating parameters passed
       
   119 if(cmp(testspath, "") == 0):
       
   120     print "\n ERROR: tests PATH parameter not provided"
       
   121     sys.exit()
       
   122 
       
   123 if(cmp(imagepath, "") == 0):
       
   124     print "\n ERROR: image PATH parameter not provided"
       
   125     sys.exit()
       
   126 
       
   127 if(cmp(target, "") == 0):
       
   128     print "\n ERROR: TARGET parameter not provided"
       
   129     sys.exit()
       
   130 
       
   131 if(cmp(harness, "") == 0):
       
   132     print "\n ERROR: HARNESS parameter not provided"
       
   133     sys.exit()
       
   134 elif((cmp(harness, "STIF") == 0) or (cmp(harness, "stif") == 0) or (cmp(harness, "Stif") == 0)):
       
   135     if(cmp(stiftype, "") == 0):
       
   136         print "\n ERROR: STIFTYPE parameter not provided"
       
   137         sys.exit()
       
   138 
       
   139 EXECUTABLE  = 0
       
   140 CFGFILE     = 1
       
   141 INIFILE     = 2
       
   142 FLASHFILE   = 3
       
   143 DATAFILE    = 4
       
   144 INCLUDEFILE = 5
       
   145 MMPFILE     = 6
       
   146 INFFILE     = 7
       
   147 PLUGINRSCFILE = 8
       
   148 
       
   149 EXTDLL      = ".dll"
       
   150 EXTEXE      = ".exe"
       
   151 EXTCFG      = ".cfg"
       
   152 EXTMMP      = ".mmp"
       
   153 
       
   154 COMMONPATH  = "\\tsrc"
       
   155 
       
   156 #get the list of files&dirs in tests folder and clean ATS3Drop folder, test.xml and testdrop package
       
   157 Directory = testspath
       
   158 os.system("dir "+Directory+" /B /A > files1.txt")
       
   159 pre = open("files1.txt", 'r')
       
   160 file = pre.readline()
       
   161 while file:
       
   162    if(file[-1] == "\n"):
       
   163         file = file[:-1]
       
   164         
       
   165    if(cmp(file, "ATS3Drop") == 0):
       
   166        os.system("rmdir /S /Q " + Directory + "\\" + file)
       
   167    elif(cmp(file, "test.xml") == 0):
       
   168        os.system("del /Q " + Directory + "\\" + file)
       
   169    elif(cmp(file, "testdrop.zip") == 0):
       
   170        os.system("del /Q " + Directory + "\\" + file)
       
   171    file = pre.readline()
       
   172 pre.close()
       
   173 print "\nDirectory Path Parsed: "+Directory+"\n"
       
   174 
       
   175 #list all files under tests folder
       
   176 os.system("dir "+Directory+" /S/B /A-D > files.txt")
       
   177 cpp = open("files.txt", 'r')
       
   178 
       
   179 CfgFiles        = []
       
   180 ExecutableFiles = []
       
   181 
       
   182 count = 0
       
   183 file = cpp.readline()
       
   184 
       
   185 #go through each file in files.txt and pick up .cfg, and extract binary names with extension .dll and .exe from mmp files.
       
   186 while file:
       
   187     if(file[-1] == "\n"):
       
   188         file = file[:-1]
       
   189 
       
   190     if((re.search("\.cfg$", file) != None )):
       
   191         CfgFiles.append(file)
       
   192 
       
   193     if((re.search("\.mmp$", file) != None )):
       
   194         #parsing mmp file for getting the executable name
       
   195         mmp = open(file, "r")
       
   196         mmpline = mmp.readline()
       
   197         while mmpline:
       
   198             if(string.find(mmpline, "TARGET ") != -1):
       
   199                 mmplinetarget = string.split(mmpline)
       
   200                 ExecutableFiles.append(mmplinetarget[-1])
       
   201                 break
       
   202             mmpline = mmp.readline()
       
   203         mmp.close();
       
   204             
       
   205     count = count + 1
       
   206     file = cpp.readline()
       
   207 cpp.close();
       
   208 
       
   209 #validate if any .cfg exists as we are using STIP scripter.
       
   210 if((cmp(harness, "STIF") == 0) or (cmp(harness, "stif") == 0) or (cmp(harness, "Stif") == 0)):
       
   211     if((cmp(stiftype, "TESTSCRIPTER") == 0) or (cmp(stiftype, "Testscripter") == 0) or (cmp(stiftype, "testscripter") == 0)):
       
   212          if(len(CfgFiles) == 0):
       
   213              print "\n CFG file not available for TestScripter type STIF module"
       
   214              sys.exit()
       
   215 
       
   216 path = string.split(Directory, "\\")
       
   217 EXECUTABLEPATH = path[0] + "\\epoc32\\RELEASE\\armv5\\UREL\\"
       
   218 PLUGINRESOURCEPATH = path[0] + "\\epoc32\\data\Z\\resource\\plugins\\"
       
   219 
       
   220 #Create test drop structure and copy files to test drop
       
   221 print "\n Creating ATSDrop Directory"
       
   222 ret = os.mkdir(Directory + "\\ATS3Drop")
       
   223 ATS3DropDir = Directory + "\\ATS3Drop\\"
       
   224 ret = os.mkdir(Directory + "\\ATS3Drop\\armv5_urel")
       
   225 ATS3EXEDir = Directory + "\\ATS3Drop\\armv5_urel"
       
   226 ret = os.mkdir(Directory + "\\ATS3Drop\\images")
       
   227 ATS3ImageDir = Directory + "\\ATS3Drop\\images"
       
   228 
       
   229 DropFloderCreated = TRUE
       
   230 
       
   231 print "\n Copying files to the Drop"
       
   232 
       
   233 #copy test binaries
       
   234 for file in ExecutableFiles: 
       
   235     print("\n copy " + EXECUTABLEPATH + file +" to "+ ATS3EXEDir)
       
   236     ret = os.system("copy /Y "+ EXECUTABLEPATH + file +" "+ ATS3EXEDir)
       
   237     if(ret != 0):
       
   238         print "Error : unable to copy " + EXECUTABLEPATH + file
       
   239         sys.exit()
       
   240     
       
   241 #copy STIF .cfg files
       
   242 for file in CfgFiles:
       
   243     print("\n copy " + file +" to "+ ATS3DropDir)
       
   244     ret = os.system("copy /Y "+ file +" "+ ATS3DropDir)
       
   245     if(ret != 0):
       
   246         print "Error : unable to copy " + file
       
   247         sys.exit()        
       
   248 #copy ecom plugin resource files
       
   249 for file in pluginrscs:
       
   250     print("\n copy " + PLUGINRESOURCEPATH + file +" to "+ ATS3DropDir)
       
   251     ret = os.system("copy /Y "+ PLUGINRESOURCEPATH + file +" "+ ATS3DropDir)
       
   252     if(ret != 0):
       
   253         print "Error : unable to copy " + PLUGINRESOURCEPATH + file
       
   254         sys.exit()   
       
   255 
       
   256 #copy images files
       
   257 
       
   258 #list all files under the given image path
       
   259 os.system("dir "+ imagepath +" /S/B /A-D > imgs.txt")
       
   260 imgs = open("imgs.txt", 'r')
       
   261 
       
   262 ImageFiles  = []
       
   263 line = imgs.readline()
       
   264 #get the complete path and name of the core image
       
   265 while line:
       
   266     if(line[-1] == "\n"):
       
   267         line = line[:-1]
       
   268 
       
   269     if((re.search("\.C00$", line) != None )):
       
   270         ImageFiles.append(line)
       
   271         break;
       
   272     line = imgs.readline();
       
   273 imgs.close();
       
   274 
       
   275 #get the complete path and name of the variant image
       
   276 imgs = open("imgs.txt", 'r')
       
   277 line = imgs.readline()
       
   278 while line:
       
   279     if(line[-1] == "\n"):
       
   280         line = line[:-1]
       
   281     if((re.search("\.V01$", line) != None )):
       
   282         ImageFiles.append(line)
       
   283         break
       
   284     line = imgs.readline();
       
   285 imgs.close();
       
   286 
       
   287 #get the complete path and name of userdisk erase image
       
   288 imgs = open("imgs.txt", 'r')
       
   289 line = imgs.readline()
       
   290 while line:
       
   291     if(line[-1] == "\n"):
       
   292         line = line[:-1]
       
   293     if((re.search("\erase_userdisk.fpsx$", line) != None )):
       
   294         ImageFiles.append(line)
       
   295         break
       
   296     line = imgs.readline();
       
   297 imgs.close();
       
   298 
       
   299 #copy image files
       
   300 for file in ImageFiles:
       
   301     print("\n copy " + file +" to "+ ATS3ImageDir)
       
   302     ret = os.system("copy /Y "+ file +" "+ ATS3ImageDir)
       
   303     if(ret != 0):
       
   304         print "Error : unable to copy " + file
       
   305         sys.exit()   
       
   306 
       
   307 DLLTARGETPATH   = "c:\\sys\\bin\\"
       
   308 PLUGINRSCTARGETPATH = "c:\\resource\\plugins\\"
       
   309 CFGTARGETPATH   = "e:\\testing\\"
       
   310 LOGTARGETPATH   = "e:\\temp\\lc_apitest\\"
       
   311 
       
   312 imagestoflash = []
       
   313 cfgFileNoPath = []
       
   314 filestoinstall = []
       
   315 BINARYFILE = 0
       
   316 NONBINARYFILE = 1
       
   317 
       
   318 for line in ImageFiles:
       
   319     imagestoflash.append(line.split("\\")[-1])
       
   320 for line in CfgFiles:
       
   321     cfgFileNoPath.append(line.split("\\")[-1])
       
   322     filestoinstall.append([line.split("\\")[-1], NONBINARYFILE, CFGTARGETPATH])
       
   323 for file in ExecutableFiles:
       
   324     filestoinstall.append([file, BINARYFILE, DLLTARGETPATH])
       
   325 for file in pluginrscs:
       
   326     filestoinstall.append([file, NONBINARYFILE, PLUGINRSCTARGETPATH])
       
   327 
       
   328 
       
   329 #Create XML if the test drop folder is created
       
   330 if(DropFloderCreated == TRUE):
       
   331     # Create the minidom document
       
   332     #test tage
       
   333     xmldoc = Document()
       
   334     xmltest = xmldoc.createElement("test")
       
   335     xmldoc.appendChild(xmltest)
       
   336 
       
   337     #id tag
       
   338     xmlid = xmldoc.createElement("id")
       
   339     xmltest.appendChild(xmlid)
       
   340     xmlidtext = xmldoc.createTextNode("1")
       
   341     xmlid.appendChild(xmlidtext)
       
   342 
       
   343     xmlname = xmldoc.createElement("name")
       
   344     xmltest.appendChild(xmlname)
       
   345     xmlnametext = xmldoc.createTextNode("LC API test")
       
   346     xmlname.appendChild(xmlnametext)
       
   347 
       
   348     #target tag
       
   349     xmltarget = xmldoc.createElement("target")
       
   350     xmltest.appendChild(xmltarget)
       
   351 
       
   352     xmltergetdevice1 = xmldoc.createElement("device")
       
   353     xmltergetdevice1.setAttribute("alias", "DEFAULT")
       
   354     xmltergetdevice1.setAttribute("rank", "none")
       
   355     xmltarget.appendChild(xmltergetdevice1)
       
   356     
       
   357     xmltargetproperty1 = xmldoc.createElement("property")
       
   358     xmltargetproperty1.setAttribute("value",harness)
       
   359     xmltargetproperty1.setAttribute("name","HARNESS")
       
   360     xmltergetdevice1.appendChild(xmltargetproperty1)
       
   361 
       
   362     xmltargetproperty2 = xmldoc.createElement("property")
       
   363     xmltargetproperty2.setAttribute("value",target)
       
   364     xmltargetproperty2.setAttribute("name","TYPE")
       
   365     xmltergetdevice1.appendChild(xmltargetproperty2)
       
   366 
       
   367     #plan tag
       
   368     xmlplan1 = xmldoc.createElement("plan")
       
   369     xmlplan1.setAttribute("passrate","100")
       
   370     xmlplan1.setAttribute("enabled","true")
       
   371     xmlplan1.setAttribute("harness",harness)
       
   372     xmlplan1.setAttribute("name",string.rstrip("Test Plan"))
       
   373     xmlplan1.setAttribute("id","1.1")
       
   374     xmltest.appendChild(xmlplan1)
       
   375 
       
   376     #session tag
       
   377     xmlp1session1 = xmldoc.createElement("session")
       
   378     xmlp1session1.setAttribute("passrate","100")
       
   379     xmlp1session1.setAttribute("enabled","true")
       
   380     xmlp1session1.setAttribute("harness",harness)
       
   381     xmlp1session1.setAttribute("name","session")
       
   382     xmlp1session1.setAttribute("id","1.1.1")
       
   383     xmlplan1.appendChild(xmlp1session1)
       
   384 
       
   385     #set tag
       
   386     xmlp1s1set1 = xmldoc.createElement("set")
       
   387     xmlp1s1set1.setAttribute("passrate","100")
       
   388     xmlp1s1set1.setAttribute("enabled","true")
       
   389     xmlp1s1set1.setAttribute("harness",harness)
       
   390     xmlp1s1set1.setAttribute("name","set")
       
   391     xmlp1s1set1.setAttribute("id","1.1.1.1")
       
   392     xmlp1session1.appendChild(xmlp1s1set1)
       
   393 
       
   394     xmlp1s1s1target = xmldoc.createElement("target")
       
   395     xmlp1s1set1.appendChild(xmlp1s1s1target)
       
   396 
       
   397     xmlp1s1s1targetdevice = xmldoc.createElement("device")
       
   398     xmlp1s1s1targetdevice.setAttribute("alias","DEFAULT")
       
   399     xmlp1s1s1targetdevice.setAttribute("rank","master")
       
   400     xmlp1s1s1target.appendChild(xmlp1s1s1targetdevice)
       
   401 
       
   402     #case tag
       
   403     xmlp1s1s1case1 = xmldoc.createElement("case")
       
   404     xmlp1s1s1case1.setAttribute("passrate","100")
       
   405     xmlp1s1s1case1.setAttribute("enabled","true")
       
   406     xmlp1s1s1case1.setAttribute("harness",harness)
       
   407     xmlp1s1s1case1.setAttribute("name","Test Case 1")
       
   408     xmlp1s1s1case1.setAttribute("id","1.1.1.1.1")
       
   409     xmlp1s1set1.appendChild(xmlp1s1s1case1)
       
   410 
       
   411     #flash tags if there are images    
       
   412     for xmlimage in imagestoflash:
       
   413         xmlp1s1s1c1flash = xmldoc.createElement("flash")
       
   414         xmlp1s1s1case1.appendChild(xmlp1s1s1c1flash)
       
   415         xmlp1s1s1c1flash.setAttribute("target-alias","DEFAULT")
       
   416         xmlp1s1s1c1flash.setAttribute("images","ATS3Drop\\images\\" + xmlimage)
       
   417             
       
   418     #install steps
       
   419     xmlstepcount = 0
       
   420     for file in filestoinstall:
       
   421         xmlstepcount = xmlstepcount + 1
       
   422         #step1
       
   423         xmlp1s1s1c1step = xmldoc.createElement("step")
       
   424         xmlp1s1s1c1step.setAttribute("significant","false")
       
   425         xmlp1s1s1c1step.setAttribute("passrate","100")
       
   426         xmlp1s1s1c1step.setAttribute("enabled","true")
       
   427         xmlp1s1s1c1step.setAttribute("harness",harness)
       
   428         xmlp1s1s1c1step.setAttribute("name","Step "+str(xmlstepcount))
       
   429         xmlp1s1s1c1step.setAttribute("id","1.1.1.1.1."+str(xmlstepcount))
       
   430         xmlp1s1s1case1.appendChild(xmlp1s1s1c1step)
       
   431 
       
   432         xmlp1s1s1c1s1command1 = xmldoc.createElement("command")
       
   433         xmlp1s1s1c1step.appendChild(xmlp1s1s1c1s1command1)
       
   434         xmlp1s1s1c1s1command1text = xmldoc.createTextNode("install")
       
   435         xmlp1s1s1c1s1command1.appendChild(xmlp1s1s1c1s1command1text)
       
   436 
       
   437         xmlp1s1s1c1s1params1 = xmldoc.createElement("params")
       
   438         xmlp1s1s1c1step.appendChild(xmlp1s1s1c1s1params1)
       
   439         if(file[1] == BINARYFILE):
       
   440             #parameter1
       
   441             xmlp1s1s1c1s1p1param1 = xmldoc.createElement("param")
       
   442             xmlp1s1s1c1s1p1param1.setAttribute("type","binary")
       
   443             xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param1)
       
   444             #end of parameter1
       
   445         #parameter2
       
   446         xmlp1s1s1c1s1p1param1 = xmldoc.createElement("param")
       
   447         xmlp1s1s1c1s1p1param1.setAttribute("src",file[0])
       
   448         xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param1)
       
   449         #end of parameter2
       
   450         #parameter3
       
   451         xmlp1s1s1c1s1p1param1 = xmldoc.createElement("param")
       
   452         xmlp1s1s1c1s1p1param1.setAttribute("dst",file[2] + file[0])
       
   453         xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param1)
       
   454         #end of parameter3
       
   455         #parameter4
       
   456         xmlp1s1s1c1s1p1param1 = xmldoc.createElement("param")
       
   457         xmlp1s1s1c1s1p1param1.setAttribute("component-path","ATS3Drop")
       
   458         xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param1)
       
   459         #end of parameter4
       
   460         #end of Step1
       
   461 
       
   462     xmlstepcount = xmlstepcount + 1
       
   463     xmlp1s1s1c1step6 = xmldoc.createElement("step")
       
   464     xmlp1s1s1c1step6.setAttribute("significant","false")
       
   465     xmlp1s1s1c1step6.setAttribute("passrate","100")
       
   466     xmlp1s1s1c1step6.setAttribute("enabled","true")
       
   467     xmlp1s1s1c1step6.setAttribute("harness",harness)
       
   468     xmlp1s1s1c1step6.setAttribute("name","Step "+str(xmlstepcount))
       
   469     xmlp1s1s1c1step6.setAttribute("id","1.1.1.1.1."+str(xmlstepcount))
       
   470     xmlp1s1s1case1.appendChild(xmlp1s1s1c1step6)
       
   471 
       
   472     xmlp1s1s1c1s6command1 = xmldoc.createElement("command")
       
   473     xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6command1)
       
   474     xmlp1s1s1c1s1command1text = xmldoc.createTextNode("makedir")
       
   475     xmlp1s1s1c1s6command1.appendChild(xmlp1s1s1c1s1command1text)
       
   476 
       
   477     xmlp1s1s1c1s6params1 = xmldoc.createElement("params")
       
   478     xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6params1)
       
   479     
       
   480     xmlp1s1s1c1s6p1param1 = xmldoc.createElement("param")
       
   481     xmlp1s1s1c1s6p1param1.setAttribute("dir","e:\\temp\\lc_apitest")
       
   482     xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param1)  
       
   483         
       
   484     #execute test case step
       
   485     if((cmp(harness, "STIF") == 0) or (cmp(harness, "stif") == 0) or (cmp(harness, "Stif") == 0)):
       
   486         if((cmp(stiftype, "TESTSCRIPTER") == 0) or (cmp(stiftype, "Testscripter") == 0) or (cmp(stiftype, "testscripter") == 0)):
       
   487             for cfgfiles_ in cfgFileNoPath:
       
   488                 xmlstepcount = xmlstepcount + 1
       
   489                 xmlp1s1s1c1step = xmldoc.createElement("step")
       
   490                 xmlp1s1s1c1step.setAttribute("significant","false")
       
   491                 xmlp1s1s1c1step.setAttribute("passrate","100")
       
   492                 xmlp1s1s1c1step.setAttribute("enabled","true")
       
   493                 xmlp1s1s1c1step.setAttribute("harness",harness)
       
   494                 xmlp1s1s1c1step.setAttribute("name","Step "+str(xmlstepcount))
       
   495                 xmlp1s1s1c1step.setAttribute("id","1.1.1.1.1."+str(xmlstepcount))
       
   496                 xmlp1s1s1case1.appendChild(xmlp1s1s1c1step)
       
   497 
       
   498                 xmlp1s1s1c1s1command1 = xmldoc.createElement("command")
       
   499                 xmlp1s1s1c1step.appendChild(xmlp1s1s1c1s1command1)
       
   500                 xmlp1s1s1c1s1command1text = xmldoc.createTextNode("run-cases")
       
   501                 xmlp1s1s1c1s1command1.appendChild(xmlp1s1s1c1s1command1text)
       
   502 
       
   503                 xmlp1s1s1c1s1params1 = xmldoc.createElement("params")
       
   504                 xmlp1s1s1c1step.appendChild(xmlp1s1s1c1s1params1)
       
   505                 
       
   506                 xmlp1s1s1c1s1p1param1 = xmldoc.createElement("param")
       
   507                 xmlp1s1s1c1s1p1param1.setAttribute("module","testscripter")
       
   508                 xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param1)
       
   509 
       
   510                 xmlp1s1s1c1s1p1param2 = xmldoc.createElement("param")
       
   511                 xmlp1s1s1c1s1p1param2.setAttribute("filter","*")
       
   512                 xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param2)
       
   513 
       
   514                 xmlp1s1s1c1s1p1param3 = xmldoc.createElement("param")
       
   515                 xmlp1s1s1c1s1p1param3.setAttribute("timeout","3000")
       
   516                 xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param3)
       
   517 
       
   518                 xmlp1s1s1c1s1p1param4 = xmldoc.createElement("param")
       
   519                 xmlp1s1s1c1s1p1param4.setAttribute("testcase-file", CFGTARGETPATH + cfgfiles_)
       
   520                 xmlp1s1s1c1s1params1.appendChild(xmlp1s1s1c1s1p1param4)
       
   521 
       
   522     #fetch STIF test report
       
   523     xmlstepcount = xmlstepcount + 1
       
   524     xmlp1s1s1c1step6 = xmldoc.createElement("step")
       
   525     xmlp1s1s1c1step6.setAttribute("significant","false")
       
   526     xmlp1s1s1c1step6.setAttribute("passrate","100")
       
   527     xmlp1s1s1c1step6.setAttribute("enabled","true")
       
   528     xmlp1s1s1c1step6.setAttribute("harness",harness)
       
   529     xmlp1s1s1c1step6.setAttribute("name","Step "+str(xmlstepcount))
       
   530     xmlp1s1s1c1step6.setAttribute("id","1.1.1.1.1."+str(xmlstepcount))
       
   531     xmlp1s1s1case1.appendChild(xmlp1s1s1c1step6)
       
   532 
       
   533     xmlp1s1s1c1s6command1 = xmldoc.createElement("command")
       
   534     xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6command1)
       
   535     xmlp1s1s1c1s1command1text = xmldoc.createTextNode("fetch-log")
       
   536     xmlp1s1s1c1s6command1.appendChild(xmlp1s1s1c1s1command1text)
       
   537 
       
   538     xmlp1s1s1c1s6params1 = xmldoc.createElement("params")
       
   539     xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6params1)
       
   540     
       
   541     xmlp1s1s1c1s6p1param1 = xmldoc.createElement("param")
       
   542     xmlp1s1s1c1s6p1param1.setAttribute("type","text")
       
   543     xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param1)
       
   544 
       
   545     xmlp1s1s1c1s6p1param2 = xmldoc.createElement("param")
       
   546     xmlp1s1s1c1s6p1param2.setAttribute("delete","true")
       
   547     xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param2)
       
   548 
       
   549     xmlp1s1s1c1s6p1param3 = xmldoc.createElement("param")
       
   550     xmlp1s1s1c1s6p1param3.setAttribute("path","C:\\Logs\\TestFramework\\*")
       
   551     xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param3)     
       
   552 
       
   553     #fetch test module own logs 
       
   554     xmlstepcount = xmlstepcount + 1
       
   555     xmlp1s1s1c1step6 = xmldoc.createElement("step")
       
   556     xmlp1s1s1c1step6.setAttribute("significant","false")
       
   557     xmlp1s1s1c1step6.setAttribute("passrate","100")
       
   558     xmlp1s1s1c1step6.setAttribute("enabled","true")
       
   559     xmlp1s1s1c1step6.setAttribute("harness",harness)
       
   560     xmlp1s1s1c1step6.setAttribute("name","Step "+str(xmlstepcount))
       
   561     xmlp1s1s1c1step6.setAttribute("id","1.1.1.1.1."+str(xmlstepcount))
       
   562     xmlp1s1s1case1.appendChild(xmlp1s1s1c1step6)
       
   563 
       
   564     xmlp1s1s1c1s6command1 = xmldoc.createElement("command")
       
   565     xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6command1)
       
   566     xmlp1s1s1c1s1command1text = xmldoc.createTextNode("fetch-log")
       
   567     xmlp1s1s1c1s6command1.appendChild(xmlp1s1s1c1s1command1text)
       
   568 
       
   569     xmlp1s1s1c1s6params1 = xmldoc.createElement("params")
       
   570     xmlp1s1s1c1step6.appendChild(xmlp1s1s1c1s6params1)
       
   571     
       
   572     xmlp1s1s1c1s6p1param1 = xmldoc.createElement("param")
       
   573     xmlp1s1s1c1s6p1param1.setAttribute("type","text")
       
   574     xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param1)
       
   575 
       
   576     xmlp1s1s1c1s6p1param2 = xmldoc.createElement("param")
       
   577     xmlp1s1s1c1s6p1param2.setAttribute("delete","true")
       
   578     xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param2)
       
   579 
       
   580     xmlp1s1s1c1s6p1param3 = xmldoc.createElement("param")
       
   581     xmlp1s1s1c1s6p1param3.setAttribute("path","e:\\temp\\lc_apitest\\*")
       
   582     xmlp1s1s1c1s6params1.appendChild(xmlp1s1s1c1s6p1param3)
       
   583     
       
   584     #files section
       
   585     xmlfiles = xmldoc.createElement("files")
       
   586     xmltest.appendChild(xmlfiles)
       
   587     for file in filestoinstall:
       
   588         xmlfilesfile1 = xmldoc.createElement("file")
       
   589         if(file[1] == BINARYFILE):
       
   590             xmlfile1text = xmldoc.createTextNode("ATS3Drop\\armv5_urel\\"+file[0])
       
   591             xmlfilesfile1.appendChild(xmlfile1text)
       
   592             xmlfiles.appendChild(xmlfilesfile1)
       
   593         else:
       
   594             xmlfile1text = xmldoc.createTextNode("ATS3Drop\\"+file[0])
       
   595             xmlfilesfile1.appendChild(xmlfile1text)
       
   596             xmlfiles.appendChild(xmlfilesfile1)  
       
   597     #image files in files section
       
   598     for xmlimage in imagestoflash:
       
   599         xmlflashfile = xmldoc.createElement("file")
       
   600         xmlflashfiletext = xmldoc.createTextNode("ATS3Drop\\images\\" + xmlimage)
       
   601         xmlflashfile.appendChild(xmlflashfiletext)
       
   602         xmlfiles.appendChild(xmlflashfile)
       
   603 
       
   604     #post action: send logs by email
       
   605     xmlpostaction = xmldoc.createElement("postAction")
       
   606     xmltest.appendChild(xmlpostaction)
       
   607     xmlactiontype = xmldoc.createElement("type")
       
   608     xmlpostaction.appendChild(xmlactiontype)
       
   609     xmlactiontext = xmldoc.createTextNode("SendEmailAction")
       
   610     xmlactiontype.appendChild(xmlactiontext)
       
   611 
       
   612     xmlsendemailparams = xmldoc.createElement("params")
       
   613     xmlpostaction.appendChild(xmlsendemailparams)
       
   614     
       
   615     xmlsendemailparam = xmldoc.createElement("param")
       
   616     xmlsendemailparam.setAttribute("name", "type")
       
   617     xmlsendemailparam.setAttribute("value", "ATS3_REPORT")
       
   618     xmlsendemailparams.appendChild(xmlsendemailparam)
       
   619  
       
   620     xmlsendemailparam = xmldoc.createElement("param")
       
   621     xmlsendemailparam.setAttribute("name", "to")
       
   622     xmlsendemailparam.setAttribute("value","ext-aminul.2.islam@nokia.com;yongjiang.yu@nokia.com")
       
   623     xmlsendemailparams.appendChild(xmlsendemailparam)
       
   624 
       
   625     xmlsendemailparam = xmldoc.createElement("param")
       
   626     xmlsendemailparam.setAttribute("name", "subject")
       
   627     xmlsendemailparam.setAttribute("value","LC API test report")
       
   628     xmlsendemailparams.appendChild(xmlsendemailparam)
       
   629     
       
   630     xmlsendemailparam = xmldoc.createElement("param")
       
   631     xmlsendemailparam.setAttribute("name", "unzip")
       
   632     xmlsendemailparam.setAttribute("value","true")
       
   633     xmlsendemailparams.appendChild(xmlsendemailparam)
       
   634     
       
   635     xmlsendemailparam = xmldoc.createElement("param")
       
   636     xmlsendemailparam.setAttribute("name", "send-files")
       
   637     xmlsendemailparam.setAttribute("value","true")
       
   638     xmlsendemailparams.appendChild(xmlsendemailparam)
       
   639 
       
   640     xmlsendemailparam = xmldoc.createElement("param")
       
   641     xmlsendemailparam.setAttribute("name", "report-dir")
       
   642     xmlsendemailparam.setAttribute("value","\\\\jamppa\\ATS\\filestore\\api_auto_test_logs")
       
   643     xmlsendemailparams.appendChild(xmlsendemailparam)    
       
   644 
       
   645     # Print our newly created XML and create test.xml
       
   646     print xmldoc.toprettyxml(indent="     ")
       
   647     xmlfile = open(Directory + "\\test.xml", "w")
       
   648     xmldoc.writexml(xmlfile, indent="     ", addindent="     ", newl="\n")
       
   649     xmlfile.close()
       
   650 
       
   651     #create the testdrop.zip file
       
   652     os.chdir(Directory)    
       
   653 
       
   654     ret = os.system("zip -R testdrop.zip test.xml  \".\\ATS3drop\\*\" \".\\ATS3drop\\armv5_urel\\*\" \".\\ATS3drop\\images\\*\"")
       
   655     if(ret != 0):
       
   656         print "Error : unable to create test.xml"
       
   657         sys.exit()
       
   658 
       
   659 print "\n Test Drop Sucessfully created in "+Directory