Ejemplo n.º 1
0
    def crash_simulation(self):

        loggerModem = logging.getLogger(__name__ + 'crash_simulation')

        loggerModem.info("Forced crash simulation")

        self.send_cmd(cmd_str='AT%IDBGTEST=1')

        insertPause(tsec=60, desc="Wait for modem to crash")

        return
Ejemplo n.º 2
0
def check_for_modem_port():

    func_name = sys._getframe(0).f_code.co_name

    logger = logging.getLogger(__name__ + func_name)

    if poll_for_port(portName="Modem_port", timeout_sec=60, poll_time_sec=5):

        logger.info("modem com port successfully found")

        insertPause(tsec=10, desc="delay after finding modem port")

        return tg.SUCCESS

    else:

        logger.info("modem com port not found")

        return tg.FAIL
    def runTest(self):

        try:

            logger_test = logging.getLogger(__name__ + ' runTest')

            print self.cur_test

            # Open a connection to the CMW500
            # ====================================================
            cmwname = 'cmw500'
            self.cmw = cmw.CmuControl(name=cmwname, ip_addr=self.config.cmwip)
            logger_test.info("Connection to %s @ %s...OK" %
                             (cmwname, self.config.cmwip))

            self.get_cmw_sw_version()

            # switch on power
            self.setup_pwr_meas(Vmax_V=3.8, Imax_A=5)

            self.cmw.Cell_OFF()

            self.modemObj = modem.serialComms(
                timeout=2, simulate_usim=self.config.usimemu)
            modeminfo = self.modemObj.getInfo()
            self.cur_test.set_modeminfo(modeminfo=modeminfo)

            # initialise cvs report bler, must be done here to extract modeminfo
            self.csvReportBler = CsvDualCellHsdpaReportBler(
                test_s=self.cur_test,
                test_conf=self.config,
                csv_fname=self.csvReportBlerPathName,
                pwrmeas=self.config.pwrmeas)

            # Initialise database
            # ====================================================
            self.init_database()

            # Local constant and variables
            # ====================================================
            self.result, self.result_msg = 0, 'OK'  # OK=0, ERROR otherwise
            teststep_idx = 0  # Test step index

            # CSV Bler report
            logger_test.debug("Total test steps = %s" %
                              self.cur_test.get_total_test_steps())

            # hard code configuration for max Tput
            #self.cmw.max_hspa_tputConfig(modulation='64-QAM', numHsdschCodes=15, ki = 62,
            #                             hsupa_cat=6, tti_ms = 10)

            data_rate = self.cur_test.datarate[0]

            snr_zip = zip(self.cur_test.snr_1,
                          self.cur_test.snr_2)  # currently not used
            rfpower_zip = zip(self.cur_test.rfpower_1, self.cur_test.rfpower_2)
            inter_tti_zip = zip(self.cur_test.inter_tti_1,
                                self.cur_test.inter_tti_2)
            ki_zip = zip(self.cur_test.ki_1, self.cur_test.ki_2)
            num_hsdcsh_codes_zip = zip(self.cur_test.num_hsdsch_codes_1,
                                       self.cur_test.num_hsdsch_codes_2)
            modulation_zip = zip(self.cur_test.modulation_1,
                                 self.cur_test.modulation_2)

            for rfband in self.cur_test.rfband:

                self.modemObj.set_preferred_rat(rat="UTRAN", band=rfband)

                for uarfcn in self.cur_test.uarfcn_dic[rfband]:

                    logger_test.debug("Selected RF_BAND=%s, DL_UARFCN=%s" %
                                      (rfband, uarfcn))

                    if self.intraHO:

                        matchObj = re.match('.*BLER_INTRAHO_(.*)',
                                            self.cur_test.testtype, re.I)

                        if matchObj:

                            uarfcn_intraho_l = self.get_intraHHO_list(
                                band=rfband,
                                num_uarfcn_sel_str=matchObj.group(1))

                            num_hho_steps = len(uarfcn_intraho_l)

                        else:

                            sys.exit(self.code.ERRCODE_TEST_FAILURE_INTRAHO)

                    else:

                        uarfcn_intraho_l = [uarfcn]

                    for (rfpower_1, rfpower_2) in rfpower_zip:

                        for txants in self.cur_test.txants:

                            for (snr_1, snr_2) in snr_zip:

                                for (modulation_1,
                                     modulation_2) in modulation_zip:

                                    for (num_hsdpa_codes_1, num_hsdpa_codes_2
                                         ) in num_hsdcsh_codes_zip:

                                        for (tb_index_1, tb_index_2) in ki_zip:

                                            logger_test.info(
                                                "Resetting CMW500")

                                            self.cmw.reset()

                                            self.cmw.max_hspa_tputConfig(
                                                modulation='64-QAM',
                                                numHsdschCodes=15,
                                                ki=62,
                                                hsupa_cat=6,
                                                tti_ms=10,
                                                dc_hsdpa=1)

                                            insertPause(
                                                tsec=1,
                                                desc=
                                                "short pause for cmw init config"
                                            )

                                            self.cmw.set_rf_band(rfband)

                                            self.cmw.set_uarfcn(uarfcn)

                                            self.cmw.set_rf_power_dbm(
                                                power=rfpower_1, carrier=1)
                                            self.cmw.set_rf_power_dbm(
                                                power=rfpower_2, carrier=2)

                                            self.cmw.set_hsdpa_modulation(
                                                carrier=1,
                                                modulation=modulation_1)
                                            self.cmw.set_hsdpa_modulation(
                                                carrier=2,
                                                modulation=modulation_2)

                                            chan_code_1 = self.calc_suitable_hsdsch_code(
                                                num_hsdpa_codes_1)
                                            self.cmw.set_hsdsch_num_codes(
                                                numCodes=num_hsdpa_codes_1)
                                            self.cmw.set_hsdsch_chanelisation_code(
                                                code=chan_code_1, carrier=1)

                                            chan_code_2 = self.calc_suitable_hsdsch_code(
                                                num_hsdpa_codes_2)
                                            self.cmw.set_hsdsch_num_codes(
                                                numCodes=num_hsdpa_codes_2)
                                            self.cmw.set_hsdsch_chanelisation_code(
                                                code=chan_code_2, carrier=2)

                                            if num_hsdpa_codes_1 == 1:

                                                self.cmw.set_hsdsch_level(
                                                    carrier=1, leveldB=-4)

                                            else:

                                                self.cmw.set_hsdsch_level(
                                                    carrier=1, leveldB=-1)

                                            if num_hsdpa_codes_2 == 2:

                                                self.cmw.set_hsdsch_level(
                                                    carrier=2, leveldB=-4)

                                            else:

                                                self.cmw.set_hsdsch_level(
                                                    carrier=2, leveldB=-1)

                                            self.cmw.set_hsdpa_tbi(
                                                carrier=1, ki=tb_index_1)
                                            self.cmw.set_hsdpa_tbi(
                                                carrier=2, ki=tb_index_2)

                                            self.cmw.Cell_OFF()

                                            # radio off
                                            self.disable_modem_fun()

                                            # ENABLE LOG
                                            # ====================================================
                                            modemLogBaseName = ""
                                            modemLogBaseName = 'WCDMA_CMW500_test_id_%s_modem_tbi_%s_%s_mod_%s_%s_numCodes_%s_%s' % (
                                                self.testID, tb_index_1,
                                                tb_index_2, modulation_1,
                                                modulation_2,
                                                num_hsdpa_codes_1,
                                                num_hsdpa_codes_2)
                                            proc_id = self.start_modem_log_capture(
                                                basefilename=modemLogBaseName)

                                            self.cmw.Cell_ON()

                                            # DUT ON
                                            self.modemObj.funcON()

                                            # DUT ATTACH
                                            # =========================================================
                                            T0 = time.time(
                                            )  # Probe start time
                                            if not self.cmw.dut_attach():
                                                logger_test.debug(
                                                    "ATTACH FAILURE: Skipping DL BLER test"
                                                )
                                                self.result = self.code.ERRCODE_TEST_FAILURE_ATTACH if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL
                                                sys.exit(self.result)

                                            # Check for chanelisation code conflict
                                            # =========================================================
                                            if self.cmw.check_code_conflict():
                                                logger_test.error(
                                                    " code conflict detected")
                                                self.result = self.code.ERRCODE_TEST_FAILURE_TESTCONFIG if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL

                                            # DUT CONNECT
                                            # =========================================================
                                            if not self.cmw.dut_connect():
                                                logger_test.debug(
                                                    "CONNECT FAILURE: Skipping DL BLER test"
                                                )
                                                self.result = self.code.ERRCODE_TEST_FAILURE_CEST if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL
                                                sys.exit(self.result)
                                            Tf = time.time()

                                            logger_test.debug(
                                                "DUT CONNECTION PROCEDURE: T0=%d, Tf=%d, Tf-T0[sec]=%d"
                                                %
                                                (T0, Tf, math.floor(Tf - T0)))

                                            uarfcn_prev_loop = uarfcn

                                            for uarfcn_intraho in uarfcn_intraho_l:

                                                teststep_idx += 1

                                                uarfcn_hho_target = uarfcn_intraho

                                                if self.intraHO:

                                                    logger_test.info(
                                                        "Intra HHO - Running step %s of %s..."
                                                        % (teststep_idx,
                                                           num_hho_steps))

                                                    logger_test.info(
                                                        "data rate =%s, band=%s"
                                                        % (data_rate, rfband) +
                                                        ", uarfcn=%s, rfpower=%s, SNR=%s"
                                                        % (uarfcn_hho_target,
                                                           rfpower_1, snr_1) +
                                                        ", modulation=%s, num HSDPA codes=%s, transport block index=%s for carrier 1"
                                                        % (modulation_1,
                                                           num_hsdpa_codes_1,
                                                           tb_index_1))

                                                    if teststep_idx == 1:
                                                        uarfcn_hho_source = uarfcn
                                                    else:
                                                        uarfcn_hho_source = uarfcn_prev_loop

                                                    logger_test.info(
                                                        "data rate =%s, band=%s,"
                                                        % (data_rate, rfband) +
                                                        " rfpower=%s, SNR=%s" %
                                                        (rfpower_2, snr_2) +
                                                        ", modulation=%s, num HSDPA codes=%s, transport block index=%s for carrier 2"
                                                        % (modulation_2,
                                                           num_hsdpa_codes_2,
                                                           tb_index_2))

                                                    logger_test.info(
                                                        "Starting blind HO from UARFCN %s (%s MHz) to target UARFCN %s (%s MHz)"
                                                        %
                                                        (uarfcn_hho_source,
                                                         get_umts_dl_freq(
                                                             uarfcn_hho_source
                                                         ), uarfcn_hho_target,
                                                         get_umts_dl_freq(
                                                             uarfcn_hho_target)
                                                         ))

                                                    self.cmw.set_uarfcn(
                                                        uarfcn=uarfcn_intraho,
                                                        carrier=1)

                                                    uarfcn_1 = self.cmw.get_uarfcn(
                                                        carrier=1)
                                                    dl_freq_1 = self.cmw.get_freq_Hz(
                                                        carrier=1)
                                                    dl_freq_1_MHz = float(
                                                        dl_freq_1) / 1000000

                                                    uarfcn_2 = self.cmw.get_uarfcn(
                                                        carrier=2)
                                                    dl_freq_2 = self.cmw.get_freq_Hz(
                                                        carrier=2)
                                                    dl_freq_2_MHz = float(
                                                        dl_freq_2) / 1000000

                                                    logger_test.info(
                                                        'cmw changed to UARFCN=%d, Freq=%.1f for carrier 1'
                                                        % (int(uarfcn_1),
                                                           dl_freq_1_MHz))
                                                    logger_test.info(
                                                        'cmw changed to UARFCN=%d, Freq=%.1f for carrier 2'
                                                        % (int(uarfcn_2),
                                                           dl_freq_2_MHz))

                                                    uarfcn_prev_loop = uarfcn_intraho

                                                    if self.cmw.readState(
                                                    ) != 'CEST':
                                                        msg = 'CONNECT ESTABLISHMENT FAILURE during INTRA HO'
                                                        logger_test.error(msg)
                                                        self.result = self.code.ERRCODE_TEST_FAILURE_INTRAHO if self.result == 0 else ERRCODE_TEST_FAILURE
                                                        sys.exit(self.result)
                                                    else:
                                                        logger_test.info(
                                                            "Blind HO SUCCESSFULL"
                                                        )
                                                        if 0:
                                                            raw_input(
                                                                "Check instrument and press [ENTER]"
                                                            )

                                                else:

                                                    logger_test.info(
                                                        "Running step %s of %s for carrier 1..."
                                                        %
                                                        (teststep_idx,
                                                         self.cur_test.
                                                         get_total_test_steps(
                                                         )))
                                                    logger_test.info(
                                                        "data rate =%s, band=%s"
                                                        % (data_rate, rfband) +
                                                        ", uarfcn=%s, rfpower=%s, SNR=%s"
                                                        % (uarfcn, rfpower_1,
                                                           snr_1) +
                                                        ", modulation=%s, num HSDPA codes=%s, transport block index=%s for carrier 1"
                                                        % (modulation_1,
                                                           num_hsdpa_codes_1,
                                                           tb_index_1))

                                                    uarfcn_2 = self.cmw.get_uarfcn(
                                                        carrier=2)
                                                    logger_test.info(
                                                        "data rate =%s, band=%s"
                                                        % (data_rate, rfband) +
                                                        ", uarfcn=%s, rfpower=%s, SNR=%s"
                                                        % (uarfcn_2, rfpower_2,
                                                           snr_2) +
                                                        ", modulation=%s, num HSDPA codes=%s, transport block index=%s for carrier 2"
                                                        % (modulation_2,
                                                           num_hsdpa_codes_2,
                                                           tb_index_2))

                                                self.start_pwr_meas()

                                                # Get bler measurements
                                                # ========================
                                                # note that 2 iterations  to cater for delay caused
                                                # by adaptive wireless switching. This can account
                                                # for high bler on the first iteration

                                                # dynamic bler tolerance
                                                dlblerTol = self.get_dlbler_tol(
                                                    tb_index=tb_index_1,
                                                    numCodes=num_hsdpa_codes_1,
                                                    modulation=modulation_1)

                                                max_num_retries = 2

                                                retryNum = 1

                                                while retryNum < (
                                                        max_num_retries + 1):

                                                    try:

                                                        ret_val = self.get_and_display_instr_meas(
                                                            max_num_retries=2,
                                                            numSubframes=self.
                                                            num_hsdpa_subframes
                                                        )

                                                    except ValueError:

                                                        print traceback.format_exc(
                                                        )

                                                        if self.get_modemLogProcessRunning(
                                                        ) == True:

                                                            self.end_modem_log_capture(
                                                                proc_id=proc_id
                                                            )

                                                        time_sec = 20

                                                        insertPause(
                                                            tsec=time_sec,
                                                            desc=
                                                            "pausing to give modem time to enter boot loader mode"
                                                        )

                                                        sys.exit(
                                                            self.code.
                                                            ERRCODE_TEST_FAILURE_CEST
                                                        )

                                                    if ret_val == self.SUCCESS:

                                                        verdict_s = self.get_test_verdict(
                                                            blerPerCentTol=
                                                            dlblerTol)

                                                        if 'PASS' in verdict_s:
                                                            break

                                                        else:
                                                            logger_test.info(
                                                                'Bler test failure - tolerance %s'
                                                                % dlblerTol)
                                                            logger_test.info(
                                                                'Iteration %s of %s'
                                                                %
                                                                (retryNum,
                                                                 max_num_retries
                                                                 ))

                                                    retryNum += 1

                                                if ret_val != self.SUCCESS:
                                                    sys.exit(ret_val)

                                                if 'FAIL' in verdict_s:
                                                    self.result = self.code.ERRCODE_TEST_FAILURE_BLER if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL

                                                schedtype = self.cur_test.schedtype[
                                                    0]

                                                if self.intraHO:
                                                    uarfcn_hho_str = str(
                                                        uarfcn_hho_source
                                                    ) + " - " + str(
                                                        uarfcn_hho_target)
                                                    param_list = [
                                                        self.testID, rfband,
                                                        uarfcn_hho_str,
                                                        self.cur_test.chtype,
                                                        data_rate, snr_1,
                                                        rfpower_1, txants,
                                                        schedtype,
                                                        modulation_1,
                                                        tb_index_1,
                                                        num_hsdpa_codes_1,
                                                        snr_2, rfpower_2,
                                                        modulation_2,
                                                        tb_index_2,
                                                        num_hsdpa_codes_2
                                                    ]

                                                else:
                                                    param_list = [
                                                        self.testID, rfband,
                                                        uarfcn,
                                                        self.cur_test.chtype,
                                                        data_rate, snr_1,
                                                        rfpower_1, txants,
                                                        schedtype,
                                                        modulation_1,
                                                        tb_index_1,
                                                        num_hsdpa_codes_1,
                                                        snr_2, rfpower_2,
                                                        modulation_2,
                                                        tb_index_2,
                                                        num_hsdpa_codes_2
                                                    ]

                                                carrier1 = 0
                                                carrier2 = 1

                                                meas_list = [
                                                    self.cmw.
                                                    get_hsdpa_measured_subframes(
                                                    ), self.cmw.
                                                    hsdpa_meas[carrier1].
                                                    get_maxTputMbps(), self.
                                                    cmw.hsdpa_meas[carrier1].
                                                    get_avgTputMbps(),
                                                    self.cmw.get_hsdpa_bler(
                                                        carrier=1), dlblerTol,
                                                    self.cmw.get_medianCqi(
                                                        carrier=1)
                                                ]

                                                first_tx = 0

                                                meas_list = meas_list + self.cmw.trans_meas_1[
                                                    first_tx].get_list()

                                                meas_list = meas_list + [
                                                    self.cmw.
                                                    hsdpa_meas[carrier2].
                                                    get_maxTputMbps(), self.
                                                    cmw.hsdpa_meas[carrier2].
                                                    get_avgTputMbps(),
                                                    self.cmw.get_hsdpa_bler(
                                                        carrier=2),
                                                    self.cmw.get_medianCqi(
                                                        carrier=2)
                                                ]

                                                meas_list = meas_list + self.cmw.trans_meas_2[
                                                    first_tx].get_list()

                                                # Add power measurements
                                                # ========================
                                                pwr_s = self.get_pwr_meas()

                                                # Update CSV report
                                                # ========================
                                                msg_s = param_list + meas_list + [
                                                    verdict_s
                                                ]

                                                if self.config.pwrmeas:
                                                    msg_s = msg_s + pwr_s

                                                self.csvReportBler.append(
                                                    msg_s)

                                                if not self.intraHO:

                                                    self.cmw.dut_disconnect()

                                                    self.end_modem_log_capture(
                                                        proc_id=proc_id)

                                                matchObj = re.match(
                                                    '\s*FAIL', verdict_s, re.I)
                                                if matchObj and self.config.msglog:
                                                    self.process_log_capture()
                                                    logger_test.info(
                                                        "Test failure, modem log %s will be kept"
                                                        % self.get_log_glp_f())
                                                elif self.config.msglog:
                                                    if os.path.isfile(
                                                            self.get_log_iom_f(
                                                            )):
                                                        logger_test.info(
                                                            "Test Pass, modem log %s will be removed"
                                                            % self.
                                                            get_log_iom_f())
                                                        try:
                                                            os.remove(
                                                                self.
                                                                get_log_iom_f(
                                                                ))
                                                        except Exception:
                                                            print traceback.format_exc(
                                                            )
                                                            print "Non fatal error, will continue anyway"

                                            if self.intraHO:

                                                self.cmw.dut_disconnect()

            self.cmw.dut_detach()

            # end of outer for loop
            # Close CMW instances
            if self.cmw:

                self.close_conn_cmw()

            self.close_pwr_meas()

            # Close COM ports
            self.modemObj.close()

            # UPDATE DATABASE
            # ==========================
            if not self.intraHO:
                self.update_database()

            # Create XLS
            # ========================
            csv2Xls(self.csvReportBlerPathName)

            # Create HTML
            # ========================
            Csv2Html(self.csvReportBlerPathName)

            #test_marker='PASS' if self.result==0 else 'FAILURE'
            test_marker = self.getVerdict(testStatus=self.result)

            self.update_summary_report(return_state=self.result,
                                       verdict_str=test_marker)

            return self.result

        except SystemExit, KeyboardInterrupt:

            # Propagate error
            exc_info = sys.exc_info()
            state = int('%s' % exc_info[1])

            test_marker = self.getVerdict(testStatus=state)

            if self.get_modemLogProcessRunning() == True:
                self.end_modem_log_capture(proc_id=proc_id)

                if test_marker.upper() == "FAILURE":
                    self.process_log_capture()

                else:
                    if os.path.isfile(self.get_log_iom_f()):
                        logger_test.info(
                            "Test Pass, modem log %s will be removed" %
                            self.get_log_iom_f())
                        try:
                            os.remove(self.get_log_iom_f())
                        except Exception:
                            print traceback.format_exc()
                            print "Non fatal error, will continue anyway"

            # Close CMW instances
            if self.cmw:
                self.cmw.write("ABORt:WCDMa:SIGN:BER")
                self.close_conn_cmw()

            # capture core dump and close modem connection

            if self.modemObj:
                if self.modemObj.check_for_crash():
                    self.capture_core_dump()
                    insertPause(tsec=30,
                                desc="waiting for modem to enter normal mode")
                else:
                    self.modemObj.close()
                    self.modemObj = None

            self.close_pwr_meas()

            self.update_summary_report(return_state=state,
                                       verdict_str=test_marker)

            return (state)
    def runTest(self):

        try:

            logger_test = logging.getLogger(__name__ + ' runTest')

            if not self.get_jenkins_regression():

                print self.cur_test

            # Open a connection to the CMW500

            # ====================================================

            cmwname = 'cmw500'

            self.cmw = cmw.CmuControl(name=cmwname, ip_addr=self.config.cmwip)

            logger_test.info("Connection to %s @ %s...OK" %
                             (cmwname, self.config.cmwip))

            self.get_cmw_sw_version()

            # switch on power

            self.setup_pwr_meas(Vmax_V=3.8, Imax_A=5)

            self.cmw.Cell_OFF()

            self.modemObj = modem.serialComms(
                timeout=2, simulate_usim=self.config.usimemu)

            modeminfo = self.modemObj.getInfo()

            self.cur_test.set_modeminfo(modeminfo=modeminfo)

            if self.get_jenkins_regression():

                newrfbandList = self.change_rf_band_list(
                    rfbandList=self.cur_test.rfband)

                self.cur_test.set_rf_band_list(bandList=newrfbandList)

                new_uarfcn_dict = self.cur_test.get_dict_from_uarfcn_dict(
                    rfbandList=newrfbandList)

                self.cur_test.set_uarcn_dict(uarfcn_dict=new_uarfcn_dict)

                print self.cur_test

            # initialise cvs report bler, must be done here to extract modeminfo

            self.csvReportBler = CsvHspaFadingReportBler(
                test_s=self.cur_test,
                test_conf=self.config,
                csv_fname=self.csvReportBlerPathName,
                pwrmeas=self.config.pwrmeas)

            # Initialise database

            # ====================================================

            if self.config.remoteDB:

                access = mysql_db.DB_mySQL_CheckPermission(
                    host=self.config.remoteDBhost,
                    dbname=self.config.remoteDBname,
                    uid=self.config.remoteDBuid,
                    pwd=self.config.remoteDBpwd)

                if access == "READ_WRITE":

                    db_write_access = 1

                elif access == None:

                    db_write_access = 0

                    remoteDB = 0

            # Local constant and variables

            # ====================================================

            self.result, self.result_msg = 0, 'OK'  # OK=0, ERROR otherwise

            teststep_idx = 0  # Test step index

            # CSV Bler report

            logger_test.debug("Total test steps = %s" %
                              self.cur_test.get_total_test_steps())

            data_rate = self.cur_test.datarate[0]

            for rfband in self.cur_test.rfband:

                self.modemObj.set_preferred_rat(rat="UTRAN", band=rfband)

                for uarfcn in self.cur_test.uarfcn_dic[rfband]:

                    for chtype in self.cur_test.chtype:

                        for rfpower in self.cur_test.rfpower:

                            for txants in self.cur_test.txants:

                                for cpich_power in self.cur_test.cpich_power:

                                    for hspdsch_power in self.cur_test.hs_pdsch_power:

                                        logger_test.info("Resetting CMW500")

                                        self.cmw.reset()

                                        self.cmw.wait_for_completion()

                                        self.cmw.hsdpa_fading_test_init_config(
                                            cpich_power, hspdsch_power, chtype)

                                        insertPause(
                                            tsec=1,
                                            desc=
                                            "short pause for cmw init config")

                                        self.cmw.set_rf_band(rfband)

                                        self.cmw.set_uarfcn(uarfcn)

                                        # Set Ior

                                        self.cmw.set_rf_power_dbm(rfpower)

                                        self.cmw.Cell_OFF()

                                        # radio off

                                        self.disable_modem_fun()

                                        # ENABLE LOG

                                        # ====================================================

                                        modemLogBaseName = ""

                                        modemLogBaseName = 'WCDMA_CMW500_test_id_%s_modem_chtype_%s_cpich_%s_hspdsch_%s' % (
                                            self.testID, chtype, cpich_power,
                                            hspdsch_power)

                                        proc_id = self.start_modem_log_capture(
                                            basefilename=modemLogBaseName)

                                        self.cmw.Cell_ON()

                                        # DUT ON

                                        self.modemObj.funcON()

                                        # DUT ATTACH

                                        # =========================================================

                                        T0 = time.time()  # Probe start time

                                        if not self.cmw.dut_attach():

                                            logger_test.debug(
                                                "ATTACH FAILURE: Skipping DL BLER test"
                                            )

                                            self.result = self.code.ERRCODE_TEST_FAILURE_ATTACH if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL

                                            sys.exit(self.result)

                                        # Check for chanelisation code conflict

                                        # =========================================================

                                        if self.cmw.check_code_conflict():

                                            logger_test.error(
                                                " code conflict detected")

                                            self.result = self.code.ERRCODE_TEST_FAILURE_TESTCONFIG if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL

                                        time_sec = 6

                                        insertPause(
                                            tsec=time_sec,
                                            desc="pausing before DUT Connect")

                                        # DUT CONNECT

                                        # =========================================================

                                        if not self.cmw.dut_connect():

                                            if not self.cmw.dut_connect(
                                            ):  # Try one more time to connect.

                                                logger_test.debug(
                                                    "DUT CONNECT FAILURE: Skipping DL BLER test"
                                                )

                                                self.result = self.code.ERRCODE_TEST_FAILURE_CEST if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL

                                                sys.exit(self.result)

                                        Tf = time.time()

                                        logger_test.debug(
                                            "DUT CONNECTION PROCEDURE: T0=%d, Tf=%d, Tf-T0[sec]=%d"
                                            % (T0, Tf, math.floor(Tf - T0)))

                                        for snr in self.cur_test.snr:

                                            teststep_idx += 1

                                            # Set Channel Type and SNR level

                                            noise_level = rfpower - snr

                                            self.cmw.reconfig_internal_fading(
                                                chtype, noise_level)

                                            print("Running step %s of %s..." %
                                                  (teststep_idx,
                                                   self.cur_test.
                                                   get_total_test_steps()))

                                            logger_test.info(
                                                "data rate =%s, band=%s" %
                                                (data_rate, rfband) +
                                                ", uarfcn=%s, rfpower=%s" %
                                                (uarfcn, rfpower) +
                                                ", CPICH Power=%s dB, HS-PDSCH Power=%s dB, Channel Type=%s, SNR = %s dB"
                                                % (cpich_power, hspdsch_power,
                                                   chtype, snr))

                                            self.start_pwr_meas()

                                            schedtype = self.cur_test.schedtype[
                                                0]

                                            param_list = [
                                                self.testID, rfband, uarfcn,
                                                chtype, data_rate, snr,
                                                rfpower, txants, schedtype,
                                                cpich_power, hspdsch_power
                                            ]

                                            # Get Reference and Best scores

                                            # ========================

                                            dlthr_ref = [None, None, None]

                                            dlth_bestscore = [None, None, None]

                                            if self.config.remoteDB:

                                                dlthr_ref, dlth_bestscore = mysql_db.DB_mySQL_wcdma_hspa_fading_SelectBestScore(
                                                    host=self.config.
                                                    remoteDBhost,
                                                    dbname=self.config.
                                                    remoteDBname,
                                                    uid=self.config.
                                                    remoteDBuid,
                                                    pwd=self.config.
                                                    remoteDBpwd,
                                                    modeminfo=self.cur_test.
                                                    modeminfo,
                                                    testparams=param_list)

                                            if (dlthr_ref[2] is None):

                                                logging.info(
                                                    "THROUGHPUT REFERENCE RESULTS NOT FOUND."
                                                )

                                                ref_dlthr = 0

                                            else:

                                                ref_dlthr = float('%.6f' %
                                                                  dlthr_ref[2])

                                                logging.info(
                                                    "DL THR REFERENCE: '%s', CL%s, %s[Mbps]"
                                                    %
                                                    (dlthr_ref[0],
                                                     dlthr_ref[1], ref_dlthr))

                                            if (dlth_bestscore[2] is None):

                                                logging.info(
                                                    "THROUGHPUT BEST SCORE RESULTS NOT FOUND."
                                                )

                                                bestscore_dlthr = 0

                                            else:

                                                bestscore_dlthr = float(
                                                    '%.6f' % dlth_bestscore[2])

                                                logging.info(
                                                    "DL THR BEST SCORE: '%s', CL%s, %s[Mbps]"
                                                    % (dlth_bestscore[0],
                                                       dlth_bestscore[1],
                                                       bestscore_dlthr))

                                            # dynamic bler tolerance

                                            dlthputTol = self.get_dlthput_tol()

                                            max_num_retries = 1

                                            retryNum = 1

                                            while retryNum < (max_num_retries +
                                                              1):

                                                try:

                                                    ret_val = self.get_and_display_instr_meas(
                                                        max_num_retries=3,
                                                        numSubframes=self.
                                                        num_hsdpa_subframes)

                                                except ValueError:

                                                    print traceback.format_exc(
                                                    )

                                                    if self.get_modemLogProcessRunning(
                                                    ) == True:

                                                        self.end_modem_log_capture(
                                                            proc_id=proc_id)

                                                    time_sec = 20

                                                    insertPause(
                                                        tsec=time_sec,
                                                        desc=
                                                        "pausing to give modem time to enter boot loader mode"
                                                    )

                                                    sys.exit(
                                                        self.code.
                                                        ERRCODE_TEST_FAILURE_CEST
                                                    )

                                                if ret_val == self.SUCCESS:

                                                    verdict_s = self.get_test_verdict(
                                                        bestscore_dlthr,
                                                        thputPerCentTol=
                                                        dlthputTol)

                                                    if 'PASS' in verdict_s:

                                                        break

                                                    else:

                                                        logger_test.info(
                                                            'Bler test failure - tolerance %s'
                                                            % dlthputTol)

                                                        logger_test.info(
                                                            'Iteration %s of %s'
                                                            %
                                                            (retryNum,
                                                             max_num_retries))

                                                retryNum += 1

                                            if ret_val != self.SUCCESS:

                                                sys.exit(ret_val)

                                            if 'FAIL' in verdict_s:

                                                self.result = self.code.ERRCODE_TEST_FAILURE_BLER if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL

                                            carrier1 = 0

                                            test_thput = self.cmw.hsdpa_meas[
                                                carrier1].get_avgTputMbps()

                                            meas_list = [
                                                self.cmw.
                                                get_hsdpa_measured_subframes(),
                                                ref_dlthr, bestscore_dlthr,
                                                test_thput,
                                                self.get_ref_percentage(
                                                    ref_dlthr, test_thput),
                                                self.get_ref_percentage(
                                                    bestscore_dlthr,
                                                    test_thput),
                                                self.cmw.get_hsdpa_bler(
                                                    carrier=1), dlthputTol,
                                                self.cmw.get_medianCqi(
                                                    carrier=1)
                                            ]

                                            first_tx = 0

                                            meas_list = meas_list + self.cmw.trans_meas_1[
                                                first_tx].get_list()

                                            # Add power measurements

                                            # ========================

                                            pwr_s = self.get_pwr_meas()

                                            # Update CSV report

                                            # ========================

                                            msg_s = param_list + meas_list + [
                                                verdict_s
                                            ]

                                            if self.config.pwrmeas:

                                                msg_s = msg_s + pwr_s

                                            self.csvReportBler.append(msg_s)

                                        # TURN OFF MEASUREMENTS

                                        # ========================

                                        self.cmw.abort_hsdpa_ack_meas()

                                        self.cmw.wait_for_completion()

                                        self.cmw.dut_disconnect()

                                        # DUT DETACH

                                        # ========================

                                        self.cmw.dut_detach()

                                        self.cmw.wait_for_completion()

                                        self.end_modem_log_capture(
                                            proc_id=proc_id)

                                        matchObj = re.match(
                                            '\s*FAIL', verdict_s, re.I)

                                        if matchObj and self.config.msglog:

                                            self.process_log_capture()

                                            logger_test.info(
                                                "Test failure, modem log %s will be kept"
                                                % self.get_log_glp_f())

                                        elif self.config.msglog:

                                            if os.path.isfile(
                                                    self.get_log_iom_f()):

                                                logger_test.info(
                                                    "Test Pass, modem log %s will be removed"
                                                    % self.get_log_iom_f())

                                                try:

                                                    os.remove(
                                                        self.get_log_iom_f())

                                                except Exception:

                                                    print traceback.format_exc(
                                                    )

                                                    print "Non fatal error, will continue anyway"

            # end of outer for loop

            # Close CMW instances

            if self.cmw:

                self.close_conn_cmw()

            self.close_pwr_meas()

            # Close COM ports

            self.modemObj.close()

            # UPDATE DATABASE

            # ==========================

            if self.config.remoteDB and db_write_access:

                mysql_db.DB_mySQL_wcdma_import_from_file_meas(
                    filename=self.csvReportBlerPathName,
                    testType=self.cur_test.testtype,
                    host=self.config.remoteDBhost,
                    dbname=self.config.remoteDBname,
                    uid=self.config.remoteDBuid,
                    pwd=self.config.remoteDBpwd,
                    config_pwr_meas=self.config.pwrmeas)

            # Create XLS

            # ========================

            csv2Xls(self.csvReportBlerPathName)

            # Create HTML

            # ========================

            Csv2Html(self.csvReportBlerPathName)

            #test_marker='PASS' if self.result==0 else 'FAILURE'

            test_marker = self.getVerdict(testStatus=self.result)

            self.update_summary_report(return_state=self.result,
                                       verdict_str=test_marker)

            return self.result

        except SystemExit, KeyboardInterrupt:

            # Propagate error

            exc_info = sys.exc_info()

            state = int('%s' % exc_info[1])

            test_marker = self.getVerdict(testStatus=state)

            if self.get_modemLogProcessRunning() == True:

                self.end_modem_log_capture(proc_id=proc_id)

                if test_marker.upper() == "FAILURE":

                    self.process_log_capture()

                else:

                    if os.path.isfile(self.get_log_iom_f()):

                        logger_test.info(
                            "Test Pass, modem log %s will be removed" %
                            self.get_log_iom_f())

                        try:

                            os.remove(self.get_log_iom_f())

                        except Exception:

                            print traceback.format_exc()

                            print "Non fatal error, will continue anyway"

            # Close CMW instances

            if self.cmw:

                self.cmw.abort_hsdpa_ack_meas()

                self.close_conn_cmw()

                self.cmw = None

            # capture core dump and close modem connection

            if self.modemObj:

                if self.modemObj.check_for_crash():

                    self.capture_core_dump()

                    insertPause(tsec=30,
                                desc="waiting for modem to enter normal mode")

                else:

                    self.modemObj.close()

                    self.modemObj = None

            self.close_pwr_meas()

            self.update_summary_report(return_state=state,
                                       verdict_str=test_marker)

            return (state)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
        os.environ['TEST_SYSTEM_ROOT_FOLDER'].split(os.sep)[:] + ['results'])

    if not os.path.isdir(results_dir):

        print "Creating local build folder: %s" % results_dir

        os.makedirs(results_dir)

    icera_tools_path = os.sep.join(
        os.environ['PL1TESTBENCH_ROOT_FOLDER'].split(os.sep)[:] +
        ['common', 'icera'])

    get_crash_dump_log(core_dump_dir=results_dir,
                       icera_utils_path=icera_tools_path)

    insertPause(tsec=10,
                desc="waiting for short time after coredump extraction")

    set_modem_mode(mode=0)

    modemInfo = get_modem_info()

    print modemInfo

    modem_p4WebRevStr = reg_expr.get_p4webrevStringfrom_modem(modemInfo)

    modem_build_cl = reg_expr.get_build_cl_from_modem(modemInfo)

    get_chip_id_wrapper()

    build_cl = get_build_info_wrapper()
    def runTest(self):

        try:

            logger_test = logging.getLogger(__name__ + ' runTest')

            print self.cur_test

            if self.config.database:
                logger_test.info(
                    'Addition of results to local database is currently not supported!'
                )
                self.config.database = 0

            if self.config.remoteDB:
                logger_test.info(
                    'Addition of results to remote database is currently not supported!'
                )
                self.config.remoteDB = 0

            # Open a connection to the CMW500
            # ====================================================
            cmwname = 'cmw500'
            self.cmw = cmw.CmuControl(name=cmwname, ip_addr=self.config.cmwip)
            logger_test.info("Connection to %s @ %s...OK" %
                             (cmwname, self.config.cmwip))

            self.get_cmw_sw_version()

            # switch on power
            self.setup_pwr_meas(Vmax_V=3.8, Imax_A=5)

            self.cmw.Cell_OFF()

            self.modemObj = custom_modem(timeout=2,
                                         simulate_usim=self.config.usimemu)
            modeminfo = self.modemObj.getInfo()
            self.cur_test.set_modeminfo(modeminfo=modeminfo)

            # initialise cvs report bler, must be done here to extract modeminfo
            self.csvReportBler = CsvHspaReportBler(
                test_s=self.cur_test,
                test_conf=self.config,
                csv_fname=self.csvReportBlerPathName,
                pwrmeas=self.config.pwrmeas)
            # Initialise database
            # ====================================================
            self.init_database()

            # Local constant and variables
            # ====================================================
            self.result, self.result_msg = 0, 'OK'  # OK=0, ERROR otherwise
            teststep_idx = 0  # Test step index

            # CSV Bler report
            logger_test.debug("Total test steps = %s" %
                              self.cur_test.get_total_test_steps())

            data_rate = self.cur_test.datarate[0]

            (band, descr,
             uarfcn) = self.cur_test.get_band_desc_uarfcn_tuple()[0]

            # this is in initial rf band
            rfband_init = band
            uarfcn_init = uarfcn
            descr_init = descr

            #for rfband in self.cur_test.rfband:

            self.modemObj.set_preferred_rat(rat="UTRAN")

            logger_test.debug("Selected RF_BAND=%s, DL_UARFCN=%s" %
                              (rfband_init, uarfcn))

            for rfpower in self.cur_test.rfpower:

                for txants in self.cur_test.txants:

                    for snr in self.cur_test.snr:

                        for modulation in self.cur_test.modulation:

                            for num_hsdpa_codes in self.cur_test.num_hsdsch_codes:

                                for tb_index in self.cur_test.ki:

                                    logger_test.info("Resetting CMW500")

                                    self.cmw.reset()

                                    self.cmw.max_hspa_tputConfig(
                                        modulation='64-QAM',
                                        numHsdschCodes=15,
                                        ki=62,
                                        hsupa_cat=6,
                                        tti_ms=10)

                                    insertPause(
                                        tsec=1,
                                        desc="short pause for cmw init config")

                                    self.cmw.set_rf_band(rfband_init)

                                    self.cmw.set_uarfcn(uarfcn_init)

                                    self.cmw.set_rf_power_dbm(rfpower)

                                    self.cmw.set_hsdpa_modulation(
                                        modulation=modulation)

                                    chan_code = self.calc_suitable_hsdsch_code(
                                        num_hsdpa_codes)

                                    self.cmw.set_hsdsch_num_codes(
                                        numCodes=num_hsdpa_codes)

                                    self.cmw.set_hsdsch_chanelisation_code(
                                        code=chan_code, carrier=1)

                                    if num_hsdpa_codes == 1:

                                        self.cmw.set_hsdsch_level(leveldB=-4)

                                    else:

                                        self.cmw.set_hsdsch_level(leveldB=-1)

                                    self.cmw.set_hsdpa_tbi(ki=tb_index)

                                    self.cmw.Cell_OFF()

                                    # radio off
                                    self.disable_modem_fun()

                                    # ENABLE LOG
                                    # ====================================================
                                    modemLogBaseName = ""
                                    modemLogBaseName = 'WCDMA_CMW500_test_id_%s_modem_tbi_%s_mod_%s_numCodes_%s' % (
                                        self.testID, tb_index, modulation,
                                        num_hsdpa_codes)

                                    proc_id = self.start_modem_log_capture(
                                        basefilename=modemLogBaseName)

                                    self.cmw.Cell_ON()

                                    # DUT ON
                                    self.modemObj.funcON()

                                    # DUT ATTACH
                                    # =========================================================
                                    T0 = time.time()  # Probe start time
                                    if not self.cmw.dut_attach():
                                        logger_test.debug(
                                            "ATTACH FAILURE: Skipping DL BLER test"
                                        )
                                        self.result = self.code.ERRCODE_TEST_FAILURE_ATTACH if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL
                                        sys.exit(self.result)

                                    # Check for chanelisation code conflict
                                    # =========================================================
                                    if self.cmw.check_code_conflict():
                                        logger_test.error(
                                            " code conflict detected")
                                        self.result = self.code.ERRCODE_TEST_FAILURE_TESTCONFIG if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL

                                    # DUT CONNECT
                                    # =========================================================
                                    if not self.cmw.dut_connect():
                                        logger_test.debug(
                                            "CONNECT FAILURE: Skipping DL BLER test"
                                        )
                                        self.result = self.code.ERRCODE_TEST_FAILURE_CEST if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL
                                        sys.exit(self.result)
                                    Tf = time.time()

                                    logger_test.debug(
                                        "DUT CONNECTION PROCEDURE: T0=%d, Tf=%d, Tf-T0[sec]=%d"
                                        % (T0, Tf, math.floor(Tf - T0)))

                                    num_hho_steps = self.cur_test.get_total_test_steps(
                                    )

                                    # ignore the first tuple in the list as this is the same band
                                    for (
                                            band, desc, uarfcn_interband_hho
                                    ) in self.cur_test.get_band_desc_uarfcn_tuple(
                                    )[1:]:

                                        teststep_idx += 1

                                        uarfcn_hho_target = uarfcn_interband_hho
                                        rf_band_hho_target = band
                                        desc_hho_target = desc

                                        logger_test.info(
                                            "Interband HHO - Running step %s of %s..."
                                            % (teststep_idx, num_hho_steps))

                                        logger_test.info(
                                            "data rate =%s" % (data_rate) +
                                            ",rfpower=%s, SNR=%s" %
                                            (rfpower, snr) +
                                            ", modulation=%s, num HSDPA codes=%s, transport block index=%s"
                                            % (modulation, num_hsdpa_codes,
                                               tb_index))

                                        if teststep_idx == 1:
                                            uarfcn_hho_source = uarfcn_init
                                            rf_band_source = rfband_init
                                            desc_source = descr_init
                                        else:
                                            uarfcn_hho_source = uarfcn_prev_loop
                                            rf_band_source = rf_band_prev_loop
                                            desc_source = desc_prev_loop

                                        logger_test.info(
                                            "Starting blind Interband HO from (%s) band %s, UARFCN %s (%s MHz) to target (%s) band %s UARFCN %s (%s MHz)"
                                            % (desc_source, rf_band_source,
                                               uarfcn_hho_source,
                                               umts.get_umts_dl_freq(
                                                   uarfcn_hho_source),
                                               desc_hho_target,
                                               rf_band_hho_target,
                                               uarfcn_hho_target,
                                               umts.get_umts_dl_freq(
                                                   uarfcn_hho_target)))

                                        self.cmw.set_rf_band(
                                            band=rf_band_hho_target)
                                        self.cmw.set_uarfcn(
                                            uarfcn=uarfcn_hho_target,
                                            carrier=1)

                                        target_freqMHz = umts.get_umts_dl_freq(
                                            uarfcn_hho_target)

                                        self.check_cmw_uarfcn_freqMHz(
                                            carrier=1,
                                            uarfcn=uarfcn_hho_target,
                                            freqMHz=target_freqMHz)

                                        uarfcn_prev_loop = uarfcn_interband_hho
                                        rf_band_prev_loop = band
                                        desc_prev_loop = desc

                                        if self.cmw.readState() != 'CEST':
                                            msg = 'CONNECT ESTABLISHMENT FAILURE during INTERBAND HO'
                                            logger_test.error(msg)
                                            self.result = self.code.ERRCODE_TEST_FAILURE_INTERBANDHO if self.result == 0 else ERRCODE_TEST_FAILURE
                                            sys.exit(self.result)
                                        else:
                                            logger_test.info(
                                                "Blind Interband HO SUCCESSFULL"
                                            )

                                        if 0:
                                            raw_input(
                                                "Check instrument and press [ENTER]"
                                            )

                                        self.start_pwr_meas()

                                        # Get bler measurements
                                        # ========================

                                        # dynamic bler tolerance
                                        dlblerTol = self.get_dlbler_tol(
                                            tb_index=tb_index,
                                            numCodes=num_hsdpa_codes,
                                            modulation=modulation)

                                        max_num_retries = 2

                                        retryNum = 1

                                        while retryNum < (max_num_retries + 1):

                                            try:

                                                ret_val = self.get_and_display_instr_meas(
                                                    max_num_retries=2,
                                                    numSubframes=self.
                                                    num_hsdpa_subframes)

                                            except ValueError:

                                                print traceback.format_exc()

                                                if self.get_modemLogProcessRunning(
                                                ) == True:

                                                    self.end_modem_log_capture(
                                                        proc_id=proc_id)

                                                time_sec = 20

                                                insertPause(
                                                    tsec=time_sec,
                                                    poll_time_sec=2,
                                                    desc=
                                                    "pausing to give modem time to enter boot loader mode"
                                                )

                                                sys.exit(
                                                    self.code.
                                                    ERRCODE_TEST_FAILURE_CEST)

                                            if ret_val == self.SUCCESS:

                                                verdict_s = self.get_test_verdict(
                                                    blerPerCentTol=dlblerTol)

                                                if 'PASS' in verdict_s:
                                                    break

                                                else:
                                                    logger_test.info(
                                                        'Bler test failure - tolerance %s'
                                                        % dlblerTol)
                                                    logger_test.info(
                                                        'Iteration %s of %s' %
                                                        (retryNum,
                                                         max_num_retries))

                                            retryNum += 1

                                        if ret_val != self.SUCCESS:
                                            sys.exit(ret_val)

                                        if 'FAIL' in verdict_s:
                                            self.result = self.code.ERRCODE_TEST_FAILURE_BLER if self.result == 0 else self.code.ERRCODE_TEST_FAILURE_GENERAL

                                        schedtype = self.cur_test.schedtype[0]

                                        uarfcn_hho_str = str(
                                            uarfcn_hho_source) + " - " + str(
                                                uarfcn_hho_target)
                                        rf_band_hho_str = str(
                                            rf_band_source) + " - " + str(
                                                rf_band_hho_target)
                                        param_list = [
                                            self.testID, rf_band_hho_str,
                                            uarfcn_hho_str,
                                            self.cur_test.chtype, data_rate,
                                            snr, rfpower, txants, schedtype,
                                            modulation, tb_index,
                                            num_hsdpa_codes
                                        ]

                                        carrier1 = 0
                                        meas_list = [
                                            self.cmw.
                                            get_hsdpa_measured_subframes(),
                                            self.cmw.hsdpa_meas[carrier1].
                                            get_maxTputMbps(),
                                            self.cmw.hsdpa_meas[carrier1].
                                            get_avgTputMbps(),
                                            self.cmw.get_hsdpa_bler(carrier=1),
                                            dlblerTol,
                                            self.cmw.get_medianCqi(carrier=1)
                                        ]
                                        first_tx = 0
                                        meas_list = meas_list + self.cmw.trans_meas_1[
                                            first_tx].get_list()

                                        # Add power measurements
                                        # ========================
                                        pwr_s = self.get_pwr_meas()

                                        # Update CSV report
                                        # ========================
                                        msg_s = param_list + meas_list + [
                                            verdict_s
                                        ]

                                        if self.config.pwrmeas:
                                            msg_s = msg_s + pwr_s

                                        self.csvReportBler.append(msg_s)
                                        '''
                                        if not self.intraHO :

                                            self.cmw.dut_disconnect()

                                            self.end_modem_log_capture(proc_id=proc_id)
                                        '''

                                        matchObj = re.match(
                                            '\s*FAIL', verdict_s, re.I)
                                        if matchObj and self.config.msglog:
                                            self.process_log_capture()
                                            logger_test.info(
                                                "Test failure, modem log %s will be kept"
                                                % self.get_log_glp_f())
                                        elif self.config.msglog:
                                            if os.path.isfile(
                                                    self.get_log_iom_f()):
                                                logger_test.info(
                                                    "Test Pass, modem log %s will be removed"
                                                    % self.get_log_iom_f())
                                                try:
                                                    os.remove(
                                                        self.get_log_iom_f())
                                                except Exception:
                                                    print traceback.format_exc(
                                                    )
                                                    print "Non fatal error, will continue anyway"

                                    self.cmw.dut_disconnect()

            self.cmw.dut_detach()

            # end of outer for loop
            # Close CMW instances
            if self.cmw:

                self.close_conn_cmw()

            self.close_pwr_meas()

            # Close COM ports
            self.modemObj.close()

            # UPDATE DATABASE
            # ==========================
            self.update_database()

            # Create XLS
            # ========================
            csv2Xls(self.csvReportBlerPathName)

            # Create HTML
            # ========================
            Csv2Html(self.csvReportBlerPathName)

            #test_marker='PASS' if self.result==0 else 'FAILURE'
            test_marker = self.getVerdict(testStatus=self.result)

            self.update_summary_report(return_state=self.result,
                                       verdict_str=test_marker)

            return self.result

        except SystemExit, KeyboardInterrupt:

            # Propagate error
            exc_info = sys.exc_info()
            state = int('%s' % exc_info[1])

            test_marker = self.getVerdict(testStatus=state)

            if self.get_modemLogProcessRunning() == True:
                self.end_modem_log_capture(proc_id=proc_id)

                if test_marker.upper() == "FAILURE":
                    self.process_log_capture()

                else:
                    if os.path.isfile(self.get_log_iom_f()):
                        logger_test.info(
                            "Test Pass, modem log %s will be removed" %
                            self.get_log_iom_f())
                        try:
                            os.remove(self.get_log_iom_f())
                        except Exception:
                            print traceback.format_exc()
                            print "Non fatal error, will continue anyway"

            # Close CMW instances
            if self.cmw:
                self.cmw.abort_hsdpa_ack_meas()
                self.close_conn_cmw()
                self.cmw = None

            # capture core dump and close modem connection
            if self.modemObj:
                if self.modemObj.check_for_crash():
                    self.capture_core_dump()
                    insertPause(tsec=30,
                                desc="waiting for modem to enter normal mode")
                else:
                    self.modemObj.close()
                    self.modemObj = None

            self.close_pwr_meas()

            self.update_summary_report(return_state=state,
                                       verdict_str=test_marker)

            return (state)
        psu_bench._reset()
        psu_bench.on()
        time.sleep(1)

        psu_bench._set(channel='P6V', voltage=Vmax_V, current=Imax_A)

        reading=psu_bench.read()
        logger.info("PSU bench configuration: Vmax[V]=%s, Imax[A]=%s, read back Voltage=%s" % (Vmax_V, Imax_A, reading))

        if poll_for_port(portName="Modem_port", timeout_sec=60, poll_time_sec=5):

            print "modem com port successfully found"

            time_secs = 5
            txt = "pausing for %s secs ..." %time_secs
            insertPause(tsec=time_secs, desc=txt)

        else:

            print "modem com port not found after power cycle"

            sys.exit(code.ERRCODE_SYS_MODEM_NO_COM)

    reading=psu_bench.read()

    logger.info("PSU bench configuration: Vmax[V]=%s, Imax[A]=%s, read back Voltage=%s" % (Vmax_V, Imax_A, reading))




Ejemplo n.º 9
0
        psu_h.close()
    else:
        psu_state_on = PsuCheckOn(psu_gwip=psu_gwip,
                                  psu_gpib=psu_gpib,
                                  check_volts = 3.8,
                                  check_curr_amps=5)
        if psu_state_on:
            print "psu is already switched on - no action required"
            pass
        else:
            PsuBenchOn(psu_gwip=psu_gwip, psu_gpib=5)

            if poll_for_port(portName="Modem_port", timeout_sec=60, poll_time_sec=5):
                print "modem com port successfully found"
            else:
                print "modem com port not found"
                assert False, 'Modem com port is not found after power cycle'
        if 0:
            logger.info("Simulate timeout")
            insertPause(tsec=300)

        insertPause(tsec=10)
        (volt, curr)=PsuBenchRead(psu_gwip, psu_gpib)
        insertPause(tsec=10)

        PsuBenchOff(psu_gwip, psu_gpib)

    logger.debug('END')