def test_configure(option, opt_str, value, parser, *args, **kwargs): print "***** Configure Device and Execution Profile *****" try: # configure_profile.config_profiles() edit_profile.edit_profiles(get_buildname(), args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]) except TestException, e: print inred(e.value)
def ffmpegEncode(casePath, serialNumber): try: from conf import path except Exception, e: print inred("No path.py generated. please run setup.py again.") return -1
def showUserGuidePrint(self): print ingreen("\n*****************************") print "You may need to create or edit your profile files, please refer to below detail profile info:\n" print "1 " + inred( "execution profile") + " -- located in test_repo/execution/" print " 1.1 name: refer to TMS Excution name and replace all spaces ' ' with underlines '_'. e.g. tms_excution_name: Build 20110312-001, and the name in execution.xml should be Build_20110312-001" print " 1.2 OS: operating system under test. android or meego" print " 1.3 DUTTestsuite: ftp or http address for downloading Testsuite. e.g. ftp://172.16.120.166/TestSuite/Android/mfld/0318/" print " 1.4 DUTWorkDirectory: an absolute path used for storing you test output files. e.g. /cache/" print " 1.5 ClipsDirectory: an absolute path leading to your stored clips. e.g. /cache/Clips/" print " 1.6 SystemBoot: from where your system boot. e.g. SD or eMMC \n" print "2 " + inred( "device profile") + " -- located in test_repo/device/" print " 2.1 Platform: platform under test. MFLD or MRST" print " 2.2 OS: operating system under test. android or meego" print " 2.3 Connect: device connection method. adb or ssh" print " 2.4 serialNumber: use unix command \"adb devices\" to obtain you device serialNumber. e.g. 0123456789ABCDEF or 172.16.125.197:5555\n" print "3. You need" + inred( " root" ) + " authority to completely implement all functions in setup.py.\n" print "4. Your Python version should be" + inred(" 2.6") + ".\n" print "5. If you encountered something wrong with Paramiko, try executing step 4 first.\n" print "6. You need busybox installed. If not, please install it with step 5 in the main menu." print ingreen("*****************************\n") userNext = raw_input("Please Enter to continue: ")
def chDev(device_numer): try: tree = ET.parse(conf.DEFAULT_DEVICE_PATH) root = tree.getroot() except Exception, e: print inred("Error: cannot parse device profile: " + conf.DEFAULT_DEVICE_PATH) exit(-1)
def push_suite(self): target_path = '' push_fail_list = [] push_success_list = [] for file_num in self.download_item_pass_list: if file_num.endswith('apk'): self.pre_command_run() cmd = ' install -r ' + file_num stdout, stderr = self.acc.execute_on_host(cmd) if stdout.lower().find('success') == -1: push_fail_list.append(file_num) else: if file_num[-2:] == 'so': target_path = '/system/lib/' elif (file_num[-2:]== 'ko' or file_num == 'adbd.sh') and file_num != "matrix.ko": target_path = '/data/' else: target_path = '/system/bin/' self.acc.upload(file_num, target_path) cmd = 'test -f ' + str( target_path + file_num) + " && echo 'File exists' || echo 'File not found'" stdout, stderr = self.acc.execute(cmd) if stdout.strip().find('File not found') != -1: push_fail_list.append(file_num) if push_fail_list: print inred('##################### Fail to Push ' + ','.join(push_fail_list) + ' to Device ##############') # else: # print ingreen('##################### Push ' + ', '.join( [item for item in self.download_item_pass_list if item not in push_fail_list] ) + ' to Device Successfully ################') #delete old files for item in self.download_item_pass_list: clear_unuseful_file('./' + item)
def run(self): print inpurple('Welcome to RapidRunner Framework!') print '1. Push Busybox to Device' print '2. Download and Push TestTools to Device' print '3. Install Android SDK' print '4. Run All Step' print '0. Exit' userInput = '' self.pre_command_run() while userInput != '0': userInput = raw_input ('Please select your operation:') if userInput == '1': self._push_busybox() elif userInput == '2': self.download_suite() self.push_suite() self.chmod_suite() elif userInput == '3': self.install_android_sdk() elif userInput == '4': self._push_busybox() self.download_suite() self.push_suite() self.chmod_suite() self.install_android_sdk() # self.install_paramiko() elif userInput == '0': pass else: print inred("Wrong operation number!")
def run(self): print inpurple('Welcome to RapidRunner Framework!') print '1. Push Busybox to Device' print '2. Download and Push TestTools to Device' print '3. Install Android SDK' print '4. Run All Step' print '0. Exit' userInput = '' self.pre_command_run() while userInput != '0': userInput = raw_input('Please select your operation:') if userInput == '1': self._push_busybox() elif userInput == '2': self.download_suite() self.push_suite() self.chmod_suite() elif userInput == '3': self.install_android_sdk() elif userInput == '4': self._push_busybox() self.download_suite() self.push_suite() self.chmod_suite() self.install_android_sdk() # self.install_paramiko() elif userInput == '0': pass else: print inred("Wrong operation number!")
def main(): try: url = 'http://10.23.31.14:8080/Service1.svc/getalltestcase' (full_url, build_name, ing) = parse_args(url) cmd = 'curl --noproxy 10.23.31.14 -o alltestcase.xml "%s"' % full_url p = Popen(cmd, bufsize=-1, shell=True, stderr=PIPE, stdout=PIPE) if p.wait() != 0: raise TestException("Error: failed to execute command: %s" % cmd) # parse souce file result_dict = get_result_from_source_file('./alltestcase.xml', full_url) intro = 'Medfield+Android+%s+%s' % (ing, build_name) suite_list = result_dict.keys() # create exeuction.xml create_execution_xml(intro, build_name, suite_list) # create many suite.xml for suite_name, case_tuple_list in result_dict.iteritems(): case_list = [] for case_tuple in case_tuple_list: case_list.append(case_tuple[0]) create_suite_xml('', suite_name, case_list) # create case_list.xml create_caselist_xml(intro, build_name, result_dict) # move files to the right path source_file_dict = {} source_file_dict['%s.xml' % build_name] = EXECUTION_XML_TARGET_PATH for suite_name in suite_list: source_file_dict['%s.xml' % suite_name] = SUITE_XML_TARGET_PATH source_file_dict['caselist.xml'] = '../test_repo/result/%s/' % build_name move_files(source_file_dict) except TestException, e: print inred(e.value)
def autoEdit_execution(buildname, executionOS, testsuiteUrl, workDir, clipDir, vaClipDir, systemBoot): try: tree = ET.parse(conf.EXECUTION_PATH + buildname + ".xml") root = tree.getroot() except Exception, e: print inred(e)
def main(argv): try: for arg in argv: if arg == "-e": ecfg = argv[argv.index(arg) + 1] except IndexError, e: print inred("Error: you must input the parameter value of --build or --ingredient") exit(-1)
def install_paramiko(self): result = install_paramiko() if result: print ingreen( '##################### Install Paramiko Successfully.#####################' ) else: print inred( '##################### Fail to Install Paramiko, Check If You Run This by Root #####################' )
def install_android_sdk(self): result = install_android_sdk(self.devcfg) if result: print ingreen( '##################### Install Android SDK Successfully #######################' ) else: print inred( '##################### Fail to Install Android SDK ##########################' )
def _connect_wifi(self): result = connect_wifi(self.devcfg) if result: print ingreen( '##################### Connect Wifi Successfully #############################' ) else: print inred( '##################### Fail to Connect Wifi #############################' )
def _push_busybox(self): result = push_busybox(self.devcfg) if result: print ingreen( '##################### Push Busybox to Device Successfully #####################' ) else: print inred( '##################### Fail to Push Busybox to Device #####################' )
def main(argv): try: for arg in argv: if arg == "-e": ecfg = argv[argv.index(arg) + 1] except IndexError, e: print inred( "Error: you must input the parameter value of --build or --ingredient" ) exit(-1)
def readCommand_profile(type): if type == "c" or type == "s" or type == "e": try: recordFile = open(recordCommandFilePath,'r') except Exception, e: print inred("Can not read command file: " + recordCommandFilePath) return -1 cmd = recordFile.read() recordFile.close() paramList = cmd.split(' ') try: return paramList[paramList.index("-" + type)+1] except Exception, e: return -1
def parse_args(url): usage = "usage: python %prog [options]" parser = OptionParser(usage=usage) parser.add_option('-n', '--name', dest='name', help="build's name", default=False) parser.add_option('-i', '--ing', dest='ing', help="project's name", default=False) options, args = parser.parse_args() if (not options.name) or (not options.ing): print inred('Error: you should input -n and -i parameter, the usage is as bellow:') parser.print_help() sys.exit(2) else: name = options.name ing = options.ing return (url + '?ex=' + name.strip() + '&ing=' + ing.strip(), name, ing)
def showCIGuidePrint(self): print ingreen("\n*****************************") print "You may need to create or edit your profile files, please refer to below detail profile info:\n" print "1 " + inred("execution profile") + " -- located in test_repo/execution/" print " 1.1 name: refer to TMS Excution name and replace all spaces ' ' with underlines '_'. e.g. tms_excution_name: Build 20110312-001, and the name in execution.xml should be Build_20110312-001\n" print "2 " + inred("device profile") + " -- located in test_repo/device/" print " 2.1 Platform: platform under test. MFLD or MRST" print " 2.2 OS: operating system under test. android or meego" print " 2.3 Connect: device connection method. adb or ssh" print " 2.4 serialNumber: use unix command \"adb devices\" to obtain you device serialNumber. e.g. 0123456789ABCDEF or 172.16.125.197:5555\n" print "3. You need" + inred(" root") + " authority to completely implement all functions in setup.py.\n" print "4. Your Python version should be" + inred(" 2.6") + ".\n" print "5. If you encountered something wrong with Paramiko, try executing step 4 first." print ingreen("*****************************\n") userNext = raw_input ("Please Enter to continue: ")
def chmod_suite(self): fail_chmod_list = [] for file_num in self.download_item_pass_list: if file_num[-2:] in ['so', 'ko'] or file_num.strip().endswith('apk'): pass else: result = self.acc.execute('chmod 4777 /system/bin/%s'%(file_num) ) if result == ('', ''): pass else: fail_chmod_list.appand(file_num) if fail_chmod_list: print inred('##################### Fail to change mode' + ', '.join(fail_chmod_list) + ' ####################') if len(self.download_item_pass_list) != 0: print ingreen('##################### Push ' + ', '.join([item for item in self.download_item_pass_list if item not in fail_chmod_list]) + ' into Device Successfully ##############')
def sendMail(srcNameList): if srcNameList != []: generateReport(readCommand_type()) dstNameString = "" for eachName in srcNameList: dstNameString = dstNameString + ',' + eachName dstNameString = dstNameString[1:] print path.build_name if os.path.exists(path.mailContentFile_path): cmd = "mail -s RapidRunner_TestReport_" + path.build_name + " " + dstNameString + " < " + path.mailContentFile_path os.system(cmd) os.system("rm -rf " + path.mailContentFile_path) else: print inred("No mail content file found, will not send mail!") else: pass
def execuitonEndPrint(self, execution_name, end_time, pass_count_total, fail_count_total, TBD_count_total, result_xml): print "\nExecution Name: %s"%execution_name print "End Time: %s" %end_time print "Pass Count: " + ingreen(pass_count_total) print "Fail Count: " + inred(fail_count_total) print "TBD Count: " + ingreen(TBD_count_total) print "Log Path: %s" %result_xml print "_____________________________\n"
def suiteEndPrint(self, suitename, end_time, pass_count, fail_count, TBD_count, rtlog): print "Suite Name: %s"%suitename print "End Time: %s" %end_time print 'Pass Count: ' + ingreen(pass_count) print 'Fail Count: ' + inred(fail_count) print 'TBD Count: ' + ingreen(TBD_count) print "Log Path: %s" %rtlog print "###############################\n"
def sendMail(srcNameList, wikisrc): if maillist == []: pass else: #start writing report mailContentFile = open("tempMailContent", 'w') separateLine = "\n******************************************************************\n" mailContentFile.write(separateLine) mailContentFile.write("Build:\n") mailContentFile.write("link: " + wikisrc + "\n") mailContentFile.write(separateLine) mailContentFile.write("\n\n") mailContentFile.write(separateLine) mailContentFile.write("Integrated new Patch list\n") mailContentFile.write("link: " + wikisrc + "/diff/HEAD please see Patches\n") mailContentFile.write(separateLine) mailContentFile.write("\n\n") mailContentFile.write(separateLine) mailContentFile.write("Bug info and Bug list related new patches\n") mailContentFile.write("link: " + wikisrc + "/diff/HEAD/ please see Bugs\n") mailContentFile.write(separateLine) mailContentFile.close() #send mail dstNameString = "" for eachName in srcNameList: dstNameString = dstNameString + ',' + eachName dstNameString = dstNameString[1:] if os.path.exists("tempMailContent"): #cmd = "mail -s RapidRunner_TestReport_" + path.build_name + " " + dstNameString + " < tempMailContent" cmd = "mail -s 'Video pre-integration " + path.build_name + " build release' " + dstNameString + " < tempMailContent" #cmd = "mail -s Video_pre-integration_build_release " + buildname + " " + dstNameString + " < tempMailContent" os.system(cmd) os.system("rm -rf tempMailContent") else: print inred("No mail content file found, will not send mail!")
def suiteEndPrint(self, suitename, end_time, pass_count, fail_count, TBD_count, rtlog): print "Suite Name: %s" % suitename print "End Time: %s" % end_time print 'Pass Count: ' + ingreen(pass_count) print 'Fail Count: ' + inred(fail_count) print 'TBD Count: ' + ingreen(TBD_count) print "Log Path: %s" % rtlog print "###############################\n"
def execuitonEndPrint(self, execution_name, end_time, pass_count_total, fail_count_total, TBD_count_total, result_xml): print "\nExecution Name: %s" % execution_name print "End Time: %s" % end_time print "Pass Count: " + ingreen(pass_count_total) print "Fail Count: " + inred(fail_count_total) print "TBD Count: " + ingreen(TBD_count_total) print "Log Path: %s" % result_xml print "_____________________________\n"
def caseEndPrint(self, casename, end_time, case_result, xmllog): print "\nCase Name: %s" % casename print "End Time: %s" % end_time if not cmp(case_result, 'pass'): print 'Result: ' + ingreen(case_result) else: print 'Result: ' + inred(case_result) print "Log Path: %s" % xmllog print "******************************"
def main(argv): #obtain build name and ingredient name build = '' ingredient = '' platform = '' deviceOS = '' connect = '' serialNumber = '' executionOS = '' testsuiteUrl = '' workDir = '' clipDir = '' vaClipDir = '' systemBoot = '' try: for arg in argv: if arg == "--build": build = argv[argv.index(arg) + 1] if arg == "--ingredient": ingredient = argv[argv.index(arg) + 1] if arg == "--platform": platform = argv[argv.index(arg) + 1] if arg == "--deviceOS": deviceOS = argv[argv.index(arg) + 1] if arg == "--connect": connect = argv[argv.index(arg) + 1] if arg == "--serialNumber": serialNumber = argv[argv.index(arg) + 1] if arg == "--executionOS": executionOS = argv[argv.index(arg) + 1] if arg == "--testsuiteUrl": testsuiteUrl = argv[argv.index(arg) + 1] if arg == "--workDir": workDir = argv[argv.index(arg) + 1] if arg == "--clipDir": clipDir = argv[argv.index(arg) + 1] if arg == "--vaClipDir": vaClipDir = argv[argv.index(arg) + 1] if arg == "--systemBoot": systemBoot = argv[argv.index(arg) + 1] except IndexError, e: print inred("Error: you must input the parameter value of " + arg) exit(-1)
def sendMail(srcNameList,wikisrc): if maillist == []: pass else: #start writing report mailContentFile = open("tempMailContent", 'w') separateLine = "\n******************************************************************\n" mailContentFile.write(separateLine) mailContentFile.write("Build:\n") mailContentFile.write("link: " + wikisrc + "\n") mailContentFile.write(separateLine) mailContentFile.write("\n\n") mailContentFile.write(separateLine) mailContentFile.write("Integrated new Patch list\n") mailContentFile.write("link: " + wikisrc + "/diff/HEAD please see Patches\n") mailContentFile.write(separateLine) mailContentFile.write("\n\n") mailContentFile.write(separateLine) mailContentFile.write("Bug info and Bug list related new patches\n") mailContentFile.write("link: " + wikisrc + "/diff/HEAD/ please see Bugs\n") mailContentFile.write(separateLine) mailContentFile.close() #send mail dstNameString = "" for eachName in srcNameList: dstNameString = dstNameString + ',' + eachName dstNameString = dstNameString[1:] if os.path.exists("tempMailContent"): #cmd = "mail -s RapidRunner_TestReport_" + path.build_name + " " + dstNameString + " < tempMailContent" cmd = "mail -s 'Video pre-integration " + path.build_name + " build release' " + dstNameString + " < tempMailContent" #cmd = "mail -s Video_pre-integration_build_release " + buildname + " " + dstNameString + " < tempMailContent" os.system(cmd) os.system("rm -rf tempMailContent") else: print inred("No mail content file found, will not send mail!")
def caseEndPrint(self, casename, end_time, case_result, xmllog): print "\nCase Name: %s" %casename print "End Time: %s" %end_time if not cmp(case_result, 'pass'): print 'Result: ' + ingreen(case_result) else: print 'Result: ' + inred(case_result) print "Log Path: %s" %xmllog print "******************************"
def showCIGuidePrint(self): print ingreen("\n*****************************") print "You may need to create or edit your profile files, please refer to below detail profile info:\n" print "1 " + inred( "execution profile") + " -- located in test_repo/execution/" print " 1.1 name: refer to TMS Excution name and replace all spaces ' ' with underlines '_'. e.g. tms_excution_name: Build 20110312-001, and the name in execution.xml should be Build_20110312-001\n" print "2 " + inred( "device profile") + " -- located in test_repo/device/" print " 2.1 Platform: platform under test. MFLD or MRST" print " 2.2 OS: operating system under test. android or meego" print " 2.3 Connect: device connection method. adb or ssh" print " 2.4 serialNumber: use unix command \"adb devices\" to obtain you device serialNumber. e.g. 0123456789ABCDEF or 172.16.125.197:5555\n" print "3. You need" + inred( " root" ) + " authority to completely implement all functions in setup.py.\n" print "4. Your Python version should be" + inred(" 2.6") + ".\n" print "5. If you encountered something wrong with Paramiko, try executing step 4 first." print ingreen("*****************************\n") userNext = raw_input("Please Enter to continue: ")
def run(self): try: self.args, self.help = self.parseArgs(self.argv) self.parse_device_profile() check_adb_connect(self.devcfg) # pushing busy box must run first, because the following step will use command in it if self.args.get('busybox') is not None : self._push_busybox() if self.args.get('connect_wifi') is not None: self._connect_wifi() if self.args.get('open_fps') is not None: self._open_fps() if self.args.get('execution') is not None : self._run_execution() # ip should be written to path.py, so run after execution if self.args.get('ip') is not None: self.change_ip() except TestException, e: print inred(e.value)
def run(self): try: self.args, self.help = self.parseArgs(self.argv) self.parse_device_profile() check_adb_connect(self.devcfg) # pushing busy box must run first, because the following step will use command in it if self.args.get('busybox') is not None: self._push_busybox() if self.args.get('connect_wifi') is not None: self._connect_wifi() if self.args.get('open_fps') is not None: self._open_fps() if self.args.get('execution') is not None: self._run_execution() # ip should be written to path.py, so run after execution if self.args.get('ip') is not None: self.change_ip() except TestException, e: print inred(e.value)
def download(ingredient, buildname): if ingredient == '': ingredient = raw_input("Enter Ingredient name:"); ingredient = ingredient.replace(" ","%20"); if buildname == '': buildname = raw_input("Enter Test Execution name:"); buildname = buildname.replace(" ","%20"); #create buildname in ./conf/ buildname_file = open('conf/buildname','w') buildname_file.write(buildname) buildname_file.close() #delete origin test_repo os.system("cd .. ; rm -rf test_repo") #download test_repo.tar.gz url = "http://tms.bj.intel.com/tms/execution/tool/download.php" command = "curl --noproxy tms.bj.intel.com -o ../test_repo.tar.gz '%s'" %(url) status, output = commands.getstatusoutput(command) if not status == 0: print inred("###########################--Download test_repo.tar.gz Error--###########################") else: status, output = commands.getstatusoutput("cd .. ; tar zxvf test_repo.tar.gz") if not status == 0: print inred("Error: fail to download test_repo from TMS.") else: os.system("cd .. ; rm -rf test_repo.tar.gz") #download config.tar.gz url = "http://tms.bj.intel.com/tms/execution/tool/video_profile.php?plat=Medfield&os=Android&ing=%s&ex=%s"%(ingredient, buildname) command = "curl --noproxy tms.bj.intel.com -o %sconfig.tar.gz '%s'" %(conf.TEST_REPO, url) status, output = commands.getstatusoutput(command) if not status == 0: print inred("###########################--Download Case Profile Error--###########################") else: status, output = commands.getstatusoutput("cd " + conf.TEST_REPO + " ; tar zxvf config.tar.gz") if not status == 0: print inred("Error: fail to download execution from TMS, maybe the ingredient name or execution name is invalid. Or your host need to install curl.") else: os.system("cd " + conf.TEST_REPO + " ; rm -rf config.tar.gz") os.system("mv " + conf.TEST_REPO + "config/" + buildname + ".xml " + conf.TEST_REPO) os.system("mv " + conf.TEST_REPO + "config/case_profile " + conf.TEST_REPO) os.system("cd " + conf.TEST_REPO + " ; mv config suite_profile") print ingreen("###########################Download Successful--###########################") # set device number try: main() except Exception, e: print e
def showUserGuidePrint(self): print ingreen("\n*****************************") print "You may need to create or edit your profile files, please refer to below detail profile info:\n" print "1 " + inred("execution profile") + " -- located in test_repo/execution/" print " 1.1 name: refer to TMS Excution name and replace all spaces ' ' with underlines '_'. e.g. tms_excution_name: Build 20110312-001, and the name in execution.xml should be Build_20110312-001" print " 1.2 OS: operating system under test. android or meego" print " 1.3 DUTTestsuite: ftp or http address for downloading Testsuite. e.g. ftp://172.16.120.166/TestSuite/Android/mfld/0318/" print " 1.4 DUTWorkDirectory: an absolute path used for storing you test output files. e.g. /cache/" print " 1.5 ClipsDirectory: an absolute path leading to your stored clips. e.g. /cache/Clips/" print " 1.6 SystemBoot: from where your system boot. e.g. SD or eMMC \n" print "2 " + inred("device profile") + " -- located in test_repo/device/" print " 2.1 Platform: platform under test. MFLD or MRST" print " 2.2 OS: operating system under test. android or meego" print " 2.3 Connect: device connection method. adb or ssh" print " 2.4 serialNumber: use unix command \"adb devices\" to obtain you device serialNumber. e.g. 0123456789ABCDEF or 172.16.125.197:5555\n" print "3. You need" + inred(" root") + " authority to completely implement all functions in setup.py.\n" print "4. Your Python version should be" + inred(" 2.6") + ".\n" print "5. If you encountered something wrong with Paramiko, try executing step 4 first.\n" print "6. You need busybox installed. If not, please install it with step 5 in the main menu." print ingreen("*****************************\n") userNext = raw_input ("Please Enter to continue: ")
def parseArgs(self, argv): usage = "usage: python %prog [options]" parser = OptionParser(usage=usage) parser.add_option('-e', '--execution', help="execution's configure file") parser.add_option('-d', '--device', help="optional, device's configure file") parser.add_option('-t', '--type', help="optional, v(video)") parser.add_option('-c', '--connect_wifi', action='store_false', help="connect to wiki") parser.add_option('-o', '--open_fps', action='store_false', help="open fps in logcat") parser.add_option('-i', '--ip', help="set IP for av streaming") parser.add_option('-p', '--platform', help="set platform") parser.add_option('-b', '--busybox', action='store_false', help="push busybox to device") if len(argv) == 0: print parser.print_help() sys.exit(0) else: options, args = parser.parse_args(argv) if (options.execution is None and options.connect_wifi is None and options.ip is None) and options.open_fps is None and options.busybox is None: print inred("ERROR: make sure you should input one of -e, -c, -o, -b or -i !") print parser.print_help() else: return (options.__dict__, parser.print_help)
def chmod_suite(self): fail_chmod_list = [] for file_num in self.download_item_pass_list: if file_num[-2:] in ['so', 'ko' ] or file_num.strip().endswith('apk'): pass else: result = self.acc.execute('chmod 4777 /system/bin/%s' % (file_num)) if result == ('', ''): pass else: fail_chmod_list.appand(file_num) if fail_chmod_list: print inred('##################### Fail to change mode' + ', '.join(fail_chmod_list) + ' ####################') if len(self.download_item_pass_list) != 0: print ingreen('##################### Push ' + ', '.join([ item for item in self.download_item_pass_list if item not in fail_chmod_list ]) + ' into Device Successfully ##############')
def check_if_config_device(): # check if user has configured the device profile and execution profile device_path = '' execution_path = '' args = '' # at the beginning, config.DEVICE_PATH doesn't exist, only if the users have configured the device profile, the # directory will be created. if not os.path.isdir(conf.DEVICE_PATH): print inred("Warning: you haven't configure device profile, please run python rapidrunner.py -c first") sys.exit(0) else: if os.path.isfile(conf.DEVICE_PATH + conf.DEVICE_PROFILE_NAME): device_path = conf.DEVICE_PATH + conf.DEVICE_PROFILE_NAME else: print inred("please run python rapidrunner.py -c first to configure device profile") sys.exit(0) build_name = get_build_name() if os.path.isfile(conf.EXECUTION_PATH + build_name + '.xml'): args = args + ' -e ' + conf.EXECUTION_PATH + build_name + '.xml' else: raise TestException("Error: no execution profile under %s" %conf.EXECUTION_PATH) if device_path: args = args + ' -d %s' %device_path else: print inred("please run python rapidrunner.py -c first to configure device profile") sys.exit(0) connect_way, serial_number = get_device_serialnumber(device_path) ip_or_serialnumber = connect_way == 'adb' and 'serialNumber' or 'IP' print inblue('TIP: you will run with execution: %s.xml on DUT with %s: %s' %(build_name, ip_or_serialnumber, serial_number)) return args
def parseArgs(self, argv): usage = "usage: python %prog [options]" parser = OptionParser(usage=usage) parser.add_option('-e', '--execution', help="execution's configure file") parser.add_option('-d', '--device', help="optional, device's configure file") parser.add_option('-t', '--type', help="optional, v(video)") parser.add_option('-c', '--connect_wifi', action='store_false', help="connect to wiki") parser.add_option('-o', '--open_fps', action='store_false', help="open fps in logcat") parser.add_option('-i', '--ip', help="set IP for av streaming") parser.add_option('-p', '--platform', help="set platform") parser.add_option('-b', '--busybox', action='store_false', help="push busybox to device") if len(argv) == 0: print parser.print_help() sys.exit(0) else: options, args = parser.parse_args(argv) if (options.execution is None and options.connect_wifi is None and options.ip is None ) and options.open_fps is None and options.busybox is None: print inred( "ERROR: make sure you should input one of -e, -c, -o, -b or -i !" ) print parser.print_help() else: return (options.__dict__, parser.print_help)
def push_suite(self): target_path = '' push_fail_list = [] push_success_list = [] for file_num in self.download_item_pass_list: if file_num.endswith('apk'): self.pre_command_run() cmd = ' install -r ' + file_num stdout, stderr = self.acc.execute_on_host(cmd) if stdout.lower().find('success') == -1: push_fail_list.append(file_num) else: if file_num[-2:] == 'so': target_path = '/system/lib/' elif (file_num[-2:] == 'ko' or file_num == 'adbd.sh') and file_num != "matrix.ko": target_path = '/data/' else: target_path = '/system/bin/' self.acc.upload(file_num, target_path) cmd = 'test -f ' + str( target_path + file_num ) + " && echo 'File exists' || echo 'File not found'" stdout, stderr = self.acc.execute(cmd) if stdout.strip().find('File not found') != -1: push_fail_list.append(file_num) if push_fail_list: print inred('##################### Fail to Push ' + ','.join(push_fail_list) + ' to Device ##############') # else: # print ingreen('##################### Push ' + ', '.join( [item for item in self.download_item_pass_list if item not in push_fail_list] ) + ' to Device Successfully ################') #delete old files for item in self.download_item_pass_list: clear_unuseful_file('./' + item)
def check_if_config_device(): # check if user has configured the device profile and execution profile device_path = '' execution_path = '' args = '' # at the beginning, config.DEVICE_PATH doesn't exist, only if the users have configured the device profile, the # directory will be created. if not os.path.isdir(conf.DEVICE_PATH): print inred( "Warning: you haven't configure device profile, please run python rapidrunner.py -c first" ) sys.exit(0) else: if os.path.isfile(conf.DEVICE_PATH + conf.DEVICE_PROFILE_NAME): device_path = conf.DEVICE_PATH + conf.DEVICE_PROFILE_NAME else: print inred( "please run python rapidrunner.py -c first to configure device profile" ) sys.exit(0) build_name = get_build_name() if os.path.isfile(conf.EXECUTION_PATH + build_name + '.xml'): args = args + ' -e ' + conf.EXECUTION_PATH + build_name + '.xml' else: raise TestException("Error: no execution profile under %s" % conf.EXECUTION_PATH) if device_path: args = args + ' -d %s' % device_path else: print inred( "please run python rapidrunner.py -c first to configure device profile" ) sys.exit(0) connect_way, serial_number = get_device_serialnumber(device_path) ip_or_serialnumber = connect_way == 'adb' and 'serialNumber' or 'IP' print inblue( 'TIP: you will run with execution: %s.xml on DUT with %s: %s' % (build_name, ip_or_serialnumber, serial_number)) return args
def codec(self): for item in self.par_dict: if self.par_dict[item] == None: raise TestException("Error: No text in element '" + item + "', please check the case profile.") #obtain clip format if self.stepType == 0 or self.stepType == 10: if self.stepType == 10: return "noResult" if self.stepType == 0 or self.stepType == 20: case_path = path.test_repo + '/case_profile/' + self.caseFolderName.strip() + '/run.xml' tree = et.parse(case_path) root = tree.getroot() try: clip_ele_list = root.find('URL').findall('Clip') except Exception, e: raise TestException("Error: no URL found, VideoEditor case should have at least one xml file to be download.") xml_name = '' for clip_ele in clip_ele_list: clip_url = clip_ele.text.strip() clip_name = clip_url.split('/')[-1] if clip_name.strip().endswith('.xml'): xml_name = clip_name.strip() if xml_name == '': raise TestException("Error: No xml file found in Clip element, please check the case profile.") format = self.par_dict['Format'] # push xml to /data/, and rename to VideoEditorTest.xml cmd = 'mv ' + self.Clip_Path + format + '/' + xml_name + ' /data/' stdout, stderr = self.cli.execute(cmd) if stdout.find('No such file or directory') != -1: raise TestException('Error: fail to run command: ' + cmd) cmd = 'mv /data/' + xml_name + ' /data/VideoEditorTest.xml' self.cli.execute(cmd) check_cmd = "test -f /data/VideoEditorTest.xml && echo 'File exists' || echo 'File not found'" stdout, stderr = self.cli.execute(check_cmd) if str(stdout).strip() == 'File not found': raise TestException("Error: rename failed: " + cmd) # check clip should be got by download or by capture try: clipsource = self.par_dict['ClipSource'] except KeyError: raise TestException("Error: no ClipSource element found.") if clipsource.strip() == 'True': pass else: self.capture() # delete old output file try: output_file_name = self.par_dict['OutputFile'].strip() except KeyError: raise TestException("Error: no OutputFile element found.") cmd = 'rm -rf ' + self.Clip_Path + format + '/' + output_file_name self.cli.execute(cmd) # run am command cmd = 'am instrument -e class com.android.mediaframeworktest.functional.videoeditor.VideoEditorTest#execute -w com.android.mediaframeworktest/.MediaFrameworkTestRunner' self.cli.execute(cmd) # check if output file generate successfully result_cmd = "test -f "+ self.Clip_Path + format + '/' + output_file_name + " && echo 'File exists' || echo 'File not found'" stdout, stderr = self.cli.execute(result_cmd) if str(stdout).strip() == 'File not found': print inred('fail to generate outputfile: ' + output_file_name) else: # pull output file to case result os.system("mkdir -p " + path.resultClip_path + '/' + self.caseFolderName + '/') self.cli.download(self.Clip_Path + format + '/' + output_file_name + " ", path.resultClip_path + '/' + self.caseFolderName + '/') # kill monitor not finished TestCase(self.stepType).kill_monitor_thread(self.all_monitor_thread_dict, path.result_path + '/' + self.caseFolderName + '/', self.dev_dict, False, self.step_id) #waiting for new FILE generated print "waiting for logcat file generated ......" logcat_file_name = get_locat_file_name(self.all_monitor_thread_dict) while(not os.path.exists(path.result_path + '/' + self.caseFolderName + '/' + logcat_file_name)): time.sleep(1) #rename FILE into step_id.logcat os.system("cd " + path.result_path + '/' + self.caseFolderName + " ; mv " + logcat_file_name + " " + str(self.step_id) + ".logcat") #obtain mediainfo result on result clip mediainfo_dict = parseMediaInfo(path.resultClip_path + '/' + self.caseFolderName + '/' + output_file_name) for eachItem in mediainfo_dict: self.rt_dict.setdefault(eachItem, mediainfo_dict[eachItem]) return self.rt_dict
if os.path.exists("tempMailContent"): #cmd = "mail -s RapidRunner_TestReport_" + path.build_name + " " + dstNameString + " < tempMailContent" cmd = "mail -s 'Video pre-integration " + path.build_name + " build release' " + dstNameString + " < tempMailContent" #cmd = "mail -s Video_pre-integration_build_release " + buildname + " " + dstNameString + " < tempMailContent" os.system(cmd) os.system("rm -rf tempMailContent") else: print inred("No mail content file found, will not send mail!") if __name__ == "__main__": usage = "usage: python %prog [options]" parser = OptionParser(usage=usage) parser.add_option( '--mail', dest='mail', help="send mail manually according to current execution result.", default=None) options, args = parser.parse_args(sys.argv) if options.mail is not None: print options.mail maillist = checkMailList(options.mail) else: print inred( "Could not send mail because of the lack of --mail parameter.") exit(-1) sendMail(maillist, args[1])
def decode(self): for item in self.dict: if self.dict[item] == None: raise TestException("Error: No text in element '" + item + "', please check the case profile.") #obtain clip format format = self.dict['Format'] #obtain inputfile input = self.Clip_Path + self.dict['Format'] + '/' + self.dict['InputFile'] #obtain mode if not cmp(self.dict['Mode'], 'Off'): mode = '' elif not cmp(self.dict['Mode'], 'gt'): mode = "--mode \\>" elif not cmp(self.dict['Mode'], 'lt'): mode = "--mode \\<" else: mode = "--mode " + self.dict['Mode'] #obtain render if not cmp(self.dict['Render'], 'ov'): render = "--render ov" elif not cmp(self.dict['Render'], 'ts'): render = "--render ts" else: render = '' ''' #obtain hdmi if not cmp(self.dict['HDMI'], 'clone'): hdmi = "--hdmi clone" elif not cmp(self.dict['HDMI'], 'extend'): hdmi = "--hdmi extend" else: hdmi = '' ''' #obtain seedTo if not cmp(self.dict['SeekTo'], None) or not cmp(self.dict['SeekTo'], 'Off') or not cmp(self.dict['SeekTo'], 'off'): seedTo = '' else: seedTo = "--seekto " + self.dict['SeekTo'] #obtain SeekInterval if not cmp(self.dict['SeekInterval'], None) or not cmp(self.dict['SeekInterval'], 'Off') or not cmp(self.dict['SeekInterval'], 'off'): duration = '' else: duration = "--duration " + self.dict['SeekInterval'] #generate cmd cmd = "mediaplayer --input_file " + input + ' ' + mode + ' ' + render + ' ' + seedTo + ' ' + duration print "" self.rt_dict.setdefault('cmd', cmd) if self.stepType == 0 or self.stepType == 10: if self.stepType == 10: return "noResult" if self.stepType == 0 or self.stepType == 20: #delete old logcat file try: logcat_file_name = get_locat_file_name(self.all_monitor_thread_dict) os.system("rm -rf " + path.result_path + '/' + self.caseFolderName + '/' + logcat_file_name) except Exception, e: pass #execute in remote device print "Execute Output: \n" self.cli.execute_test(cmd, self.step_id) try: outfile = open('log' + str(self.step_id), 'r') except IOError, e: print inred("Error: cannot generate log.") os.system("touch log" + str(self.step_id))
def encode(self): for item in self.dict: if self.dict[item] == None: raise TestException("Error: No text in element '" + item + "', please check the case profile.") #obtain outputfile output = get_result_path() + self.dict['OutputFile'] # check if output exist cmd = 'test -d ' + get_result_path() + " && echo 'directory exists' || echo 'directory not found'" stdout, stderr = self.cli.execute(cmd) print stdout, stderr if stdout.strip() == 'directory not found': cmd = 'mkdir -p ' + get_result_path() self.cli.execute(cmd) #obtain bitrate if not cmp(self.dict['VideoBitrate'], 'Off'): bitrate = '' else: bitrate = "--bitrate " + self.dict['VideoBitrate'] #obtain framerate if not cmp(self.dict['Framerate'], 'Off'): framerate = '' else: framerate = "--framerate " + self.dict['Framerate'] #obtain audiocodec if not cmp(self.dict['Audiocodec'].replace(' ',''), 'amr'): ac = "--audiocodec amr" elif not cmp(self.dict['Audiocodec'].replace(' ',''), 'awb'): ac = "--audiocodec awb" elif not cmp(self.dict['Audiocodec'].replace(' ',''), 'aac'): ac = "--audiocodec aac" else: ac = '--audiocodec aac' #obtain videocodec if not cmp(self.dict['Videocodec'], 'h263'): vc = "--videocodec h263" elif not cmp(self.dict['Videocodec'], 'h264'): vc = "--videocodec h264" elif not cmp(self.dict['Videocodec'], 'mpeg4'): vc = "--videocodec mpeg4" else: vc = '' #obtain format if not cmp(self.dict['Format'], '3gp'): format = "--format 3gp" elif not cmp(self.dict['Format'], 'mp4'): format = "--format mp4" else: format = '' #obtain resolution if not cmp(self.dict['Resolution'], 'Off'): resolution = '' else: resolution = "--resolution " + self.dict['Resolution'] #obtain duration if not cmp(self.dict['Duration'], 'Off'): duration = '' else: duration = "--duration " + self.dict['Duration'] #obtain mode if not cmp(self.dict['Mode'], 'av'): mode = "--mode av" elif not cmp(self.dict['Mode'], 'vo'): mode = "--mode vo" elif not cmp(self.dict['Mode'], 'ao'): mode = "--mode ao" else: mode = '' #obtain audio bitrate if not cmp(self.dict['AudioBitrate'], 'Off'): audiobitrate = '' else: audiobitrate = "--audiobitrate " + self.dict['AudioBitrate'] #obtain audio sampling rate if not cmp(self.dict['AudioSampleRate'], 'Off'): audiosamplerate = '' else: audiosamplerate = "--samplingrate " + self.dict['AudioSampleRate'] + " --EnableChSampling" #generate cmd cmd = "mediarecorder --output " + output + ' ' + bitrate + ' ' + framerate + ' ' + ac + ' ' + vc + ' ' + format + ' ' + resolution + ' ' + duration + ' ' + mode + ' ' + audiobitrate + ' ' + audiosamplerate # cmd = "mediarecorder --output " + output + ' ' + bitrate + ' ' + framerate + ' ' + ac + ' ' + vc + ' ' + format + ' ' + resolution + ' ' + duration + ' ' + mode + ' ' + audiosamplerate print "" print cmd print "" self.rt_dict.setdefault('cmd', cmd) if self.stepType == 0 or self.stepType == 10: if self.stepType == 10: return "noResult" if self.stepType == 0 or self.stepType == 20: #execute in remote device print "Execute Output: \n" self.cli.execute_test(cmd, self.step_id) try: outfile = open('log' + str(self.step_id), 'r') except IOError, e: print inred("Error: cannot generat log.") os.system("touch log" + str(self.step_id)) stdout = outfile.read() outfile.close() #pull result clip to host os.system("mkdir -p " + path.resultClip_path + '/' + self.caseFolderName + '/') self.cli.download(output, path.resultClip_path + '/' + self.caseFolderName + '/') #obtain mediainfo result from result clip mediainfo_dict = parseMediaInfo(path.resultClip_path + '/' + self.caseFolderName + '/' + self.dict['OutputFile']) for eachItem in mediainfo_dict: self.rt_dict.setdefault(eachItem, mediainfo_dict[eachItem])
dstNameString = "" for eachName in srcNameList: dstNameString = dstNameString + ',' + eachName dstNameString = dstNameString[1:] if os.path.exists("tempMailContent"): #cmd = "mail -s RapidRunner_TestReport_" + path.build_name + " " + dstNameString + " < tempMailContent" cmd = "mail -s 'Video pre-integration " + path.build_name + " build release' " + dstNameString + " < tempMailContent" #cmd = "mail -s Video_pre-integration_build_release " + buildname + " " + dstNameString + " < tempMailContent" os.system(cmd) os.system("rm -rf tempMailContent") else: print inred("No mail content file found, will not send mail!") if __name__ == "__main__": usage = "usage: python %prog [options]" parser = OptionParser(usage=usage) parser.add_option('--mail', dest='mail', help="send mail manually according to current execution result.", default=None) options, args = parser.parse_args(sys.argv) if options.mail is not None: print options.mail maillist = checkMailList(options.mail) else: print inred("Could not send mail because of the lack of --mail parameter.") exit(-1) sendMail(maillist,args [1])
return -1 root = xml_tree.getroot() try: if casePath[-1] == '/': casePath = casePath[:-1] caseName = casePath.split('/')[-1] inputFile = root.find('Step').find('Parameter').find('InputFile').text resolution = root.find('Step').find('Parameter').find( 'Resolution').text bitRate = str( long(root.find('Step').find('Parameter').find('BitRate').text) / 1000) frame = inputFile[:inputFile.find("frame")].split('_')[-1] except Exception, e: print inred("Error reading element info from " + (casePath + "/run.xml").replace('//', '/')) return -1 print("inputFile: " + inputFile) print("resolution: " + resolution) print("bitRate: " + bitRate) print("frame: " + frame) #generate folders yuvPath = path.resultClip_path + '/' + caseName + "/ffmpegEncode/YUV/" I420Path = path.resultClip_path + '/' + caseName + "/ffmpegEncode/I420/" EncodedClipPath = path.resultClip_path + '/' + caseName + "/ffmpegEncode/EncodedClip/" os.system("mkdir -p " + yuvPath) os.system("mkdir -p " + I420Path) os.system("mkdir -p " + EncodedClipPath)
def decode(self): for item in self.dict: if self.dict[item] == None: raise TestException("Error: No text in element '" + item + "', please check the case profile.") #obtain clip format format = self.dict['Format'] #obtain inputfile input = self.Clip_Path + self.dict['Format'] + '/' + self.dict[ 'InputFile'] #obtain mode if not cmp(self.dict['Mode'], 'Off'): mode = '' elif not cmp(self.dict['Mode'], 'gt'): mode = "--mode \\>" elif not cmp(self.dict['Mode'], 'lt'): mode = "--mode \\<" else: mode = "--mode " + self.dict['Mode'] #obtain render if not cmp(self.dict['Render'], 'ov'): render = "--render ov" elif not cmp(self.dict['Render'], 'ts'): render = "--render ts" else: render = '' ''' #obtain hdmi if not cmp(self.dict['HDMI'], 'clone'): hdmi = "--hdmi clone" elif not cmp(self.dict['HDMI'], 'extend'): hdmi = "--hdmi extend" else: hdmi = '' ''' #obtain seedTo if not cmp(self.dict['SeekTo'], None) or not cmp( self.dict['SeekTo'], 'Off') or not cmp(self.dict['SeekTo'], 'off'): seedTo = '' else: seedTo = "--seekto " + self.dict['SeekTo'] #obtain SeekInterval if not cmp(self.dict['SeekInterval'], None) or not cmp( self.dict['SeekInterval'], 'Off') or not cmp( self.dict['SeekInterval'], 'off'): duration = '' else: duration = "--duration " + self.dict['SeekInterval'] #generate cmd cmd = "mediaplayer --input_file " + input + ' ' + mode + ' ' + render + ' ' + seedTo + ' ' + duration print "" self.rt_dict.setdefault('cmd', cmd) if self.stepType == 0 or self.stepType == 10: if self.stepType == 10: return "noResult" if self.stepType == 0 or self.stepType == 20: #delete old logcat file try: logcat_file_name = get_locat_file_name( self.all_monitor_thread_dict) os.system("rm -rf " + path.result_path + '/' + self.caseFolderName + '/' + logcat_file_name) except Exception, e: pass #execute in remote device print "Execute Output: \n" self.cli.execute_test(cmd, self.step_id) try: outfile = open('log' + str(self.step_id), 'r') except IOError, e: print inred("Error: cannot generate log.") os.system("touch log" + str(self.step_id))
def encode(self): for item in self.dict: if self.dict[item] == None: raise TestException("Error: No text in element '" + item + "', please check the case profile.") #obtain outputfile output = get_result_path() + self.dict['OutputFile'] # check if output exist cmd = 'test -d ' + get_result_path( ) + " && echo 'directory exists' || echo 'directory not found'" stdout, stderr = self.cli.execute(cmd) print stdout, stderr if stdout.strip() == 'directory not found': cmd = 'mkdir -p ' + get_result_path() self.cli.execute(cmd) #obtain bitrate if not cmp(self.dict['VideoBitrate'], 'Off'): bitrate = '' else: bitrate = "--bitrate " + self.dict['VideoBitrate'] #obtain framerate if not cmp(self.dict['Framerate'], 'Off'): framerate = '' else: framerate = "--framerate " + self.dict['Framerate'] #obtain audiocodec if not cmp(self.dict['Audiocodec'].replace(' ', ''), 'amr'): ac = "--audiocodec amr" elif not cmp(self.dict['Audiocodec'].replace(' ', ''), 'awb'): ac = "--audiocodec awb" elif not cmp(self.dict['Audiocodec'].replace(' ', ''), 'aac'): ac = "--audiocodec aac" else: ac = '--audiocodec aac' #obtain videocodec if not cmp(self.dict['Videocodec'], 'h263'): vc = "--videocodec h263" elif not cmp(self.dict['Videocodec'], 'h264'): vc = "--videocodec h264" elif not cmp(self.dict['Videocodec'], 'mpeg4'): vc = "--videocodec mpeg4" else: vc = '' #obtain format if not cmp(self.dict['Format'], '3gp'): format = "--format 3gp" elif not cmp(self.dict['Format'], 'mp4'): format = "--format mp4" else: format = '' #obtain resolution if not cmp(self.dict['Resolution'], 'Off'): resolution = '' else: resolution = "--resolution " + self.dict['Resolution'] #obtain duration if not cmp(self.dict['Duration'], 'Off'): duration = '' else: duration = "--duration " + self.dict['Duration'] #obtain mode if not cmp(self.dict['Mode'], 'av'): mode = "--mode av" elif not cmp(self.dict['Mode'], 'vo'): mode = "--mode vo" elif not cmp(self.dict['Mode'], 'ao'): mode = "--mode ao" else: mode = '' #obtain audio bitrate if not cmp(self.dict['AudioBitrate'], 'Off'): audiobitrate = '' else: audiobitrate = "--audiobitrate " + self.dict['AudioBitrate'] #obtain audio sampling rate if not cmp(self.dict['AudioSampleRate'], 'Off'): audiosamplerate = '' else: audiosamplerate = "--samplingrate " + self.dict[ 'AudioSampleRate'] + " --EnableChSampling" #generate cmd cmd = "mediarecorder --output " + output + ' ' + bitrate + ' ' + framerate + ' ' + ac + ' ' + vc + ' ' + format + ' ' + resolution + ' ' + duration + ' ' + mode + ' ' + audiobitrate + ' ' + audiosamplerate # cmd = "mediarecorder --output " + output + ' ' + bitrate + ' ' + framerate + ' ' + ac + ' ' + vc + ' ' + format + ' ' + resolution + ' ' + duration + ' ' + mode + ' ' + audiosamplerate print "" print cmd print "" self.rt_dict.setdefault('cmd', cmd) if self.stepType == 0 or self.stepType == 10: if self.stepType == 10: return "noResult" if self.stepType == 0 or self.stepType == 20: #execute in remote device print "Execute Output: \n" self.cli.execute_test(cmd, self.step_id) try: outfile = open('log' + str(self.step_id), 'r') except IOError, e: print inred("Error: cannot generat log.") os.system("touch log" + str(self.step_id)) stdout = outfile.read() outfile.close() #pull result clip to host os.system("mkdir -p " + path.resultClip_path + '/' + self.caseFolderName + '/') self.cli.download( output, path.resultClip_path + '/' + self.caseFolderName + '/') #obtain mediainfo result from result clip mediainfo_dict = parseMediaInfo(path.resultClip_path + '/' + self.caseFolderName + '/' + self.dict['OutputFile']) for eachItem in mediainfo_dict: self.rt_dict.setdefault(eachItem, mediainfo_dict[eachItem])
import os import sys import commands from optparse import OptionParser from xml.etree import ElementTree as ET from tools.color import inred from common_module.email import checkMailList import conf try: from conf import path except ImportError, e: print inred("ERROR: no path.py found, please run setup.py again.") sys.exit(2) try: email_profile = conf.email_profile_path except Exception, e: print inred("Error: Cannot find path.email_profile_path. Please run setup.py first.") sys.exit(2) def sendMail(srcNameList,wikisrc,buildlink): if maillist == []: pass else: status, output = commands.getstatusoutput("ls " + path.result_path) if output.find("No such file or directory") != -1: print inred("Cannot send mail because we could not find any result file.") return caseList = output.split('\n') if caseList == []: print inred("Cannot send mail because we could not find any result file.") return
def sendMail(srcNameList,wikisrc,buildlink): if maillist == []: pass else: status, output = commands.getstatusoutput("ls " + path.result_path) if output.find("No such file or directory") != -1: print inred("Cannot send mail because we could not find any result file.") return caseList = output.split('\n') if caseList == []: print inred("Cannot send mail because we could not find any result file.") return #start writing report mailContentFile = open("tempMailContent", 'w') buildInfo = " Build: " + path.build_name + "\n" HWInfo = " H/W: PR3.1\n" separateLine = "***************************************************************************\n" mailContentFile.write(separateLine) mailContentFile.write("General Info:\n") mailContentFile.write(buildInfo) mailContentFile.write(HWInfo) mailContentFile.write("\n") mailContentFile.write(separateLine) mailContentFile.write("\n\n") mailContentFile.write(separateLine) mailContentFile.write(" build image: " + buildlink + "\n") mailContentFile.write("\n") mailContentFile.write(separateLine) total_count = 0 pass_count = 0 fail_count = 0 TBD_count = 0 passCaseList = [] failCaseList = [] TBDCaseList = [] for eachCase in caseList: try: tree = ET.parse(path.result_path + "/" + eachCase + "/" + eachCase + ".xml") root = tree.getroot() except Exception, e: print "Error: cannot parse file: " + path.result_path + "/" + eachCase + "/" + eachCase + ".xml" continue if root.find("pass_count") is not None: #only record case result continue else: total_count += 1 caseResult = "pass" try: stepList = root.find("execute_information").findall("step") for each_step in stepList: result = each_step.find("result").text if result is None: caseResult = "Cannot obtain result" break elif result.lower() == "pass": pass elif result.lower() == "fail": caseResult = "fail" fail_count += 1 failCaseList.append(eachCase) break elif result.lower() == "TBD": caseResult = "TBD" TBD_count += 1 TBDCaseList.append(eachCase) break else: caseResult = result break if caseResult == "pass": pass_count += 1 passCaseList.append(eachCase) except Exception, e: print "Exception occurs when finding step element in file: " + path.result_path + "/" + eachCase + "/" + eachCase + ".xml"
return "noResult" if self.stepType == 0 or self.stepType == 20: cmd = "cd /cache/ ; ./" + caseFolderName_withoutCaseId print "Command:" print cmd print "" self.rt_dict.setdefault('cmd', cmd) #execute in remote device print "Execute Output: \n" self.cli.execute_test(cmd, self.step_id) try: outfile = open('log' + str(self.step_id), 'r') except IOError, e: print inred("Error: cannot generat log.") os.system("touch log" + str(self.step_id)) stdout = outfile.read() outfile.close() if self.stepType == 0 or self.stepType == 30: #create case result storing dir caseResultStorePath = "../cats/Execution/" + path.build_name + '/' + dir + '/' + caseFolderName_withoutCaseId status, output = commands.getstatusoutput("mkdir -p " + caseResultStorePath) if status != 0: print inred("Error: cannot create result storing dir.") #pull all case result print inblue("Pulling case result files ......") # self.cli.execute("rm -rf /sdcard/result/" + caseFolderName_withoutCaseId) self.cli.download("/sdcard/result", caseResultStorePath)
filename = executionResumePath if not os.path.isfile(directStr): raise TestException("Error: " + directStr + " doesn't exist ") shutil.copyfile(directStr, filename) else: raise TestException("Error: wrong createResume type!") def deleteCaseInSuiteResume(casename): try: parsed_xml = ET.parse(suiteResumePath) except Exception,e: raise TestException("IOError: Cannot find: " + suiteResumePath) root = parsed_xml.getroot() all_cases = root.find('list') if len(all_cases) == 0: print inred("Error: no case in this suite file: " + suiteResumePath) userinput = '' while userinput != 'y' and userinput !='n': userinput = raw_input(inblue('Do you want to delete this suite resume file? y/n ')) if userinput == 'y': deleteResume('suite') print ingreen("File deleted.") else: print inred("This suite file is invalid, we strongly recommend you delete it!") sys.exit(-1) for case in all_cases: if case.text == casename: all_cases.remove(case) break try: parsed_xml.write(suiteResumePath)
import sys from exception.testexception import TestException from tools.color import inred try: from conf import path except ImportError, e: print inred("ERROR: no path.py found, please run setup.py again.") sys.exit(0) def check_item_in_path(): try: path.build_name + " " + path.MediaRecorderResult + " " \ + path.result_path + " " + path.resultClip_path + " " + path.test_repo except AttributeError, e: raise TestException("Error: there is something wrong with the item created in path.py. Please run setup.py again.")
try: usage = "usage: python %prog [options]" rapidrunner = OptionParser(usage=usage) rapidrunner.add_option("-d", "--download", action="callback", callback=test_download, callback_args=(ingredient, build), help="Download execution case list to local from TMS.") rapidrunner.add_option("-l", "--list", action="callback", callback=test_list, help="check the execution case list.") rapidrunner.add_option("-c", "--configure", action="callback", callback=test_configure, callback_args=(platform, deviceOS, connect, serialNumber, executionOS, testsuiteUrl, workDir, clipDir, vaClipDir, systemBoot), help="configure device and execution profile.") # rapidrunner.add_option("-r", "--report", action="callback", callback=test_report, help="report test result.") rapidrunner.add_option("-u", "--upload", action="callback", callback=test_upload, callback_args=(ingredient, build), help="update execution result to TMS.") # rapidrunner.add_option("-p", "--prepare", action="callback", callback=test_prepare, help="prepare for test.") # rapidrunner.add_option("-e", "--execute", action="callback", callback=test_execute, help="test execution.") rapidrunner.add_option("-p", "--uploadClip", action="callback", callback=clip_upload, callback_args=(ingredient, build), help="upload result clips to media server.") rapidrunner.add_option("--build", help="build name in TMS") rapidrunner.add_option("--ingredient", help="ingredient name in TMS") rapidrunner.add_option("--platform", help="element Platform in device profile") rapidrunner.add_option("--deviceOS", help="element OS in device profile") rapidrunner.add_option("--connect", help="element Connect in device profile") rapidrunner.add_option("--serialNumber", help="element serialNumber in device profile") rapidrunner.add_option("--executionOS", help="element OS in execution profile") rapidrunner.add_option("--testsuiteUrl", help="element DUTTestsuite in execution profile") rapidrunner.add_option("--workDir", help="element DUTWorkDirectory in execution profile") rapidrunner.add_option("--clipDir", help="element ClipsDirectory in execution profile") rapidrunner.add_option("--vaClipDir", help="element VAClipsDirectory in execution profile") rapidrunner.add_option("--systemBoot", help="element SystemBoot in execution profile") (options, args) = rapidrunner.parse_args() except TestException, e: print inred(e.value) if __name__ == "__main__": main(sys.argv)
def test_list(option, opt_str, value, parser): print "***** Execution case list *****" try: list_cases.list_cases(True, get_buildname()) except TestException, e: print inred(e.value)