def execute_factory_tests(jenkins_upload_f, jobtype, branch, variant): import pl1_testbench_framework.pl1_rf_system.pl1_rf_system_test_env import pl1_rf_system.runTest as rf results_dir = os.sep.join( os.environ['PL1TESTBENCH_ROOT_FOLDER'].split(os.sep)[:] + ['pl1_rf_system', 'results', 'latest']) res_str = rf.runTestExternal(testType=jobtype, branch=branch, variant=variant) summaryFilePath = getSummaryFilePath(results_dir=results_dir, rat="RF") disable_root_logging() if summaryFilePath: getVerdict(summaryFilePath=summaryFilePath, rat="RF") # copy from latest_f to final_f # final_f is the one uploaded to Jenkins server copy_files(source_f=results_dir, dest_f=jenkins_upload_f) else: print "RF Factory Summary File from %s could not be found" % results_dir filenamePrefix = "RF_CMW500" writeVerdictFile(verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_REGEX], testVerdictDir=jenkins_upload_f, filenamePrefix=filenamePrefix) return res_str
def main(): jenkins_job = get_jenkins_job_params() if jenkins_job: print "Jenkins url: %s" % (jenkins_job['url']) branch = reg_expr.get_branch_from_url(url=jenkins_job['url']) print "Jenkins branch: %s" % branch rat_l = re.sub(r'[\[\]\s]', '', jenkins_job['rat']).split(',') print "Selected RAT = %s" % rat_l print "test type = %s" % jenkins_job['testtype'] variant = reg_expr.get_variant_from_url(url=jenkins_job['url']) if not variant: print "Cannot extract variant from %s" % jenkins_job['url'] return else: jenkins_job['variant'] = variant if jenkins_job['variant'] in get_supported_variant_list(): pass else: print "variant %s is not supported" % jenkins_job['variant'] print "list of supported variants is %s" % get_supported_variant_list( ) return print "variant = %s" % jenkins_job['variant'] print "generic build option = %s" % jenkins_job['genericBuild'] write_config_file(dictionary=jenkins_job) get_config_params_from_file() else: print "No command line options specified!" return xml_abs_path = os.sep.join(cmdpath.split(os.sep)[:] + ['nosetests.xml']) import time ts = time.strftime("%Y%m%d_%H%M%S", time.localtime()) # folder for local results storage final_storage_f = os.sep.join( os.environ['PL1TESTBENCH_ROOT_FOLDER'].split(os.sep)[:] + [ 'jenkins_interface', 'win8', 'test_system', 'results', ts + '_TestReport' ]) # final folder to store all the consolidated test results for all rats # it is the contents of this folder that is uploaded by Jenkins final_f = os.sep.join( os.environ['PL1TESTBENCH_ROOT_FOLDER'].split(os.sep)[:] + ['jenkins_interface', 'win8', 'test_system', 'results', 'final']) # results folder for each rat results_f = os.sep.join( os.environ['PL1TESTBENCH_ROOT_FOLDER'].split(os.sep)[:] + ['jenkins_interface' 'win8', 'test_system', 'results', 'latest']) # remove if os.path.isdir(final_f): shutil.rmtree(final_f) if flash_build(jenkins_dict=jenkins_job, flash_results_dir=final_f) == tg.FAIL: return else: pass disable_root_logging() # if flash successful then remove directory containing results of the flash # operation as this same directory will be poulated with the test results if os.path.isdir(final_f): shutil.rmtree(final_f) for rat in rat_l: if rat == 'WCDMA': dir_wcdma = os.sep.join(cmdpath.split(os.sep)[:] + ['test_WCDMA']) AddSysPath(dir_wcdma) execute_wcdma_unittest(jenkins_upload_f=final_f, jobtype=jenkins_job['testtype']) elif rat == 'LTE_FDD' or rat == 'LTE_TDD' or rat == 'LTE': if rat.upper() == 'LTE': rat = 'LTE_FDD' res = execute_lte_test(jenkins_upload_f=final_f, rat=rat, jobtype=jenkins_job['testtype']) elif rat.upper() == "RF": res_str = execute_factory_tests(jenkins_upload_f=final_f, jobtype=jenkins_job['testtype'], branch=branch, variant=variant) else: print "rat %s is not supported" % rat writeVerdictFile(verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_UNSUPPORTED_RAT], testVerdictDir=final_f, filenamePrefix="") return status_file_list = get_status_list(directory=final_f) remove_files(directory=final_f, file_l=status_file_list) new_status_filename = status_verdict_filename( directory=final_f, status_file_l=status_file_list) writeStatusFile(directory=final_f, fileName=new_status_filename) copy_folder(source_f=final_f, dest_f=final_storage_f)
def getVerdict(summaryFilePath, rat): import ntpath summaryFileName = ntpath.basename(summaryFilePath) results_dir = os.path.dirname(summaryFilePath) test_prefix = rat.upper() + '_CMW500' verdict = ec.ERRCODE_SUCCESS test_inconclusive = 0 test_invalid = 0 test_fail = 0 test_pass = 0 try: file_h = open(summaryFilePath) linenumber = 0 colNumVerdict = None for line in file_h: # remove new line line = line[:-1] cols = line.split(',') if re.match('\s*TestID', cols[0], re.I): foundTitleLine = True print " ".join('%-20s' % col for col in cols) # now found col num for verdict colNum = 0 for colHead in cols: if re.match('\s*verdict', colHead, re.I): # col number found for verdict colNumVerdict = colNum break colNum += 1 if not colNumVerdict: print "Cannot find verdict column" verdict = ec.ERRCODE_TEST_INCONCLUSIVE test_inconclusive = 1 break else: continue if colNumVerdict: if re.match('\s*pass', cols[colNumVerdict], re.I): test_pass = True elif re.match('\s*fail', cols[colNumVerdict], re.I): test_fail = True elif re.match('\s*inconclusive', cols[colNumVerdict], re.I): test_inconclusive = True else: test_invalid = True print "Unknown column verdict : %s" % cols[colNumVerdict] verdict = ec.ERRCODE_INVALID_VERDICT print " ".join('%-20s' % col for col in cols) linenumber += 1 # end of for for loop if test_inconclusive: writeVerdictFile( verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_TEST_INCONCLUSIVE], testVerdictDir=results_dir, filenamePrefix=test_prefix) verdict = ec.ERRCODE_TEST_INCONCLUSIVE elif test_fail: writeVerdictFile(verdict="FAILURE", descr=ec.error_table[ec.ERRCODE_TEST_FAIL], testVerdictDir=results_dir, filenamePrefix=test_prefix) verdict = ec.ERRCODE_TEST_FAIL elif test_pass: writeVerdictFile(verdict="PASS", descr=ec.error_table[ec.ERRCODE_SUCCESS], testVerdictDir=results_dir, filenamePrefix=test_prefix) verdict = ec.ERRCODE_SUCCESS else: print "Code should not enter here" writeVerdictFile(verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_INVALID_VERDICT], testVerdictDir=results_dir, filenamePrefix=test_prefix) verdict = ec.ERRCODE_TEST_INCONCLUSIVE file_h.close() return verdict except IOError: print "## Error: file %s not created" % summaryFilePath print traceback.format_exc() verdict = ec.ERRCODE_SUMMARY_FILE_NOT_FOUND writeVerdictFile( verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_SUMMARY_FILE_NOT_FOUND], testVerdictDir=results_dir, filenamePrefix=test_prefix) return verdict
def execute_lte_test(jenkins_upload_f, rat, jobtype): testbench_file_executable = os.path.join( os.environ['PL1TESTBENCH_ROOT_FOLDER'], 'run_pl1testbench_lte.py') if rat.upper() == "LTE_FDD": if jobtype.upper() == "PER_CL": testbench_file_xmlconfig = "lte_testconfig_fdd_percl.xml" elif jobtype.upper() == "NIGHTLY": testbench_file_xmlconfig = "lte_testconfig_fdd_nightly.xml" elif jobtype.upper() == "WEEKLY": testbench_file_xmlconfig = "lte_testconfig_fdd_weekly.xml" else: print("INVALID %s JOB TYPE : %s" % ("LTE", jobtype)) filenamePrefix = "LTE_FDD_CMW500" # write verdict file to final_f writeVerdictFile(verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_UNKNOWN_JOBTYPE], testVerdictDir=jenkins_upload_f, filenamePrefix=filenamePrefix) return elif rat.upper() == "LTE_TDD": if jobtype.upper() == "PER_CL": testbench_file_xmlconfig = "lte_testconfig_tdd_percl.xml" else: filenamePrefix = "%s_CMW500" % rat writeVerdictFile(verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_UNKNOWN_JOBTYPE], testVerdictDir=jenkins_upload_f, filenamePrefix=filenamePrefix) testbench_file_xmlconfig = os.path.join( os.environ['PL1TESTBENCH_ROOT_FOLDER'], testbench_file_xmlconfig) results_dir = os.sep.join( os.environ['PL1TESTBENCH_ROOT_FOLDER'].split(os.sep)[:] + ['lte', 'results', 'latest']) summaryFile = os.sep.join( results_dir.split(os.sep)[:] + ['LTE_CMW500_TestReport_SUMMARY.csv']) cmd_run = r"python %s -xml %s" % (testbench_file_executable, testbench_file_xmlconfig) print("RUNNING CMD : %s" % cmd_run) if jobtype.upper() == 'WEEKLY': timeout = (14 * 60 * 60) else: timeout = (3 * 60 * 60) enable_logging(loglevel="Debug") res = runTestbench(cmd_run, timeout=timeout) disable_root_logging() summaryFilePath = getSummaryFilePath(results_dir=results_dir, rat=rat) if summaryFilePath: getVerdict(summaryFilePath=summaryFilePath, rat=rat.upper()) # copy from latest_f to final_f # final_f is the one uploaded to Jenkins server copy_files(source_f=results_dir, dest_f=jenkins_upload_f) else: print "LTE Test Summary File from %s could not be found" % results_dir filenamePrefix = "%s_CMW500" % rat_mod writeVerdictFile(verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_REGEX], testVerdictDir=jenkins_upload_f, filenamePrefix=filenamePrefix) return res
def test_FirmwareUpdate(self): numReTry = 0 res = 0 SUCCESS = 0 FAIL = -1 target_cl_str = reg_expr.extract_target_cl(url_link=self.autobuild_url) if not self.flash_required(target_cl=target_cl_str, target_p4webrev=self.p4webrev): writeVerdictFile(verdict="PASS", descr="FLASH_NOT_REQUIRED", filenamePrefix=self.filenamePrefix, testVerdictDir=self.get_testVerdictDir()) return SUCCESS self.set_perforce_cl(target_cl_str) self.set_build_dir() self.InitFirmwarePath() while numReTry < self.maxNumRetries: sys.stdout.flush() print '--> Start Downloading firmware' download_fw_result = self.DownloadFirmware() if download_fw_result == SUCCESS: verify_flash_result = self.verifyFlash(numReTry) if verify_flash_result == SUCCESS: res = SUCCESS break else: res = FAIL download_fw_result = res numReTry += 1 else: # modem flash download failure if numReTry == self.maxNumRetries: res = download_fw_result duration_sec = 60 print "pausing %s to see if modem enters bootloader mode after second flash failure!" % duration_sec insertPause(tsec=duration_sec) modem_mode = modem.query_modem_mode() if modem_mode != 0: # cannot query mode or in boot loader mode, either way try to extract # core dump core_dump_filename = 'coredump_%s.log' % numReTry modem.collect_full_core_dump( core_dump_dir=self.get_results_dir(), filename=core_dump_filename) break else: res = FAIL duration_sec = 60 print "pausing %s to see if modem enters bootloader mode after flash failure!" % duration_sec insertPause(tsec=duration_sec) modem_mode = modem.query_modem_mode() if modem_mode != 0: core_dump_filename = 'coredump_%s.log' % numReTry modem.collect_full_core_dump( core_dump_dir=self.get_results_dir(), filename=core_dump_filename) numReTry += 1 if res == SUCCESS: writeVerdictFile(verdict="PASS", descr="SOFTWARE_BUILD_FLASH_SUCCESFUL", filenamePrefix=self.filenamePrefix, testVerdictDir=self.get_testVerdictDir()) else: writeVerdictFile( verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_DOWNLOAD_GENERIC_FAIL], filenamePrefix=self.filenamePrefix, testVerdictDir=self.get_testVerdictDir()) return download_fw_result return (res)
if jenkins['special_build']: print "Special build selected!" # if no URL supplied then download the latest URL from branch my_download = testBuild.DownloadPackage( variant=jenkins['variant'], branch=branch, http_build_url=jenkins['url'], b_special_build=jenkins['special_build']) if my_download.download_modem_binaries( param='ristretto_package') == SUCCESS: writeVerdictFile(verdict="PASS", descr="PASS") else: writeVerdictFile(verdict="INCONCLUSIVE", descr="DOWNLOAD_FAIL_CODE_UNDEF") flash_dir = my_download.getFlashBinDir() tools_dir = my_download.get_tools_dir() fw_update = TestFirmwareUpdate( variant=jenkins['variant'], autobuild_url=my_download.http_build_url, tools_dir=tools_dir, flash_binaries_dir=flash_dir,
try: # hard code use of power supply for test purposes only # so that we can run from IDE rather than DOS command prompt # where the power supply option has to be explicitly specified my_download = DownloadPackage(variant=jenkins['variant'], branch=branch, http_build_url=jenkins['url'], b_special_build=jenkins['special_build']) ## ------------------------------------ RISTRETTO --------------------------------------------- ## if my_download.download_modem_binaries( param='ristretto_package') == SUCCESS: writeVerdictFile(verdict="PASS", descr="PASS") else: writeVerdictFile(verdict="INCONCLUSIVE", descr="DOWNLOAD_FAIL_CODE_UNDEF") except SystemExit: exc_info = sys.exc_info() state = int('%s' % exc_info[1]) print state writeVerdictFile(verdict="INCONCLUSIVE", descr=ec.error_table[state])
def getVerdict(cls): # class method gets the verdict from the merged test summary file # for the tests comprising the test class and writes STATUS_xx.txt # indicating SUCCESS, FAIL or INCONCLUSIVE #import pl1_jenkins.common.error_codes as ec #from pl1_jenkins.test_system.csv_verdict import writeVerdictFile verdict = ec.ERRCODE_SUCCESS test_inconclusive = 0 test_invalid = 0 test_fail = 0 test_pass = 0 try: file_h = open(cls.get_summary_file_path()) linenumber = 0 colNumVerdict = None for line in file_h: # remove new line line = line[:-1] cols = line.split(',') if re.match('\s*TestID', cols[0], re.I): foundTitleLine = True print " ".join('%-20s' % col for col in cols) # now found col num for verdict colNum = 0 for colHead in cols: if re.match('\s*verdict', colHead, re.I): # col number found for verdict colNumVerdict = colNum break colNum += 1 if not colNumVerdict: print "Cannot find verdict column" verdict = ec.ERRCODE_TEST_INCONCLUSIVE test_inconclusive = 1 break else: continue if colNumVerdict: if re.match('\s*pass', cols[colNumVerdict], re.I): test_pass = True elif re.match('\s*fail', cols[colNumVerdict], re.I): test_fail = True elif re.match('\s*inconclusive', cols[colNumVerdict], re.I): test_inconclusive = True else: test_invalid = True print "Unknown column verdict : %s" % cols[ colNumVerdict] verdict = ec.ERRCODE_INVALID_VERDICT print " ".join('%-20s' % col for col in cols) linenumber += 1 # end of for for loop if test_inconclusive: writeVerdictFile( verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_TEST_INCONCLUSIVE], testVerdictDir=cls.get_results_dir(), filenamePrefix=cls.get_verdict_file_prefix()) verdict = ec.ERRCODE_TEST_INCONCLUSIVE elif test_fail: writeVerdictFile(verdict="FAILURE", descr=ec.error_table[ec.ERRCODE_TEST_FAIL], testVerdictDir=cls.get_results_dir(), filenamePrefix=cls.get_verdict_file_prefix()) verdict = ec.ERRCODE_TEST_FAIL elif test_pass: writeVerdictFile(verdict="PASS", descr=ec.error_table[ec.ERRCODE_SUCCESS], testVerdictDir=cls.get_results_dir(), filenamePrefix=cls.get_verdict_file_prefix()) verdict = ec.ERRCODE_SUCCESS else: print "Code should not enter here" writeVerdictFile( verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_INVALID_VERDICT], testVerdictDir=cls.get_results_dir(), filenamePrefix=cls.get_verdict_file_prefix()) file_h.close() return verdict except IOError: print "## Error: file %s not created" % cls.get_summary_file_path() print traceback.format_exc() verdict = ec.ERRCODE_SUMMARY_FILE_NOT_FOUND writeVerdictFile( verdict="INCONCLUSIVE", descr=ec.error_table[ec.ERRCODE_SUMMARY_FILE_NOT_FOUND], testVerdictDir=cls.get_results_dir(), filenamePrefix=cls.get_verdict_file_prefix()) return verdict