def enable_logging(loglevel="Info"):

    logname = os.path.splitext(os.path.basename(__file__))[0]

    logfile = logname + '.LOG'

    loglevel = loglevel.upper()

    cfg_multilogging(loglevel, logfile)
Exemplo n.º 2
0
    def runTest(self):

        curr_f = os.sep.join(
            os.environ['PL1_RF_SYSTEM_ROOT'].split(os.sep)[:] +
            ['results', 'current'])
        latest_f = os.sep.join(
            os.environ['PL1_RF_SYSTEM_ROOT'].split(os.sep)[:] +
            ['results', 'latest'])

        overall_result_str = rf_global.verdict_dict[rf_global.PASS]

        try:

            if self.config.instr_ip == "ww.xx.yy.zz":
                ErrMsg = "ERROR: runTest() : specify a valid Instrument IP address"
                raise ExRunTest(ErrMsg)

            test_selection = self.config.test_selection
            test_exec_dic = OrderedDict()
            total_test_count = 0
            current_test_count = 0

            #Build up list of tests to execute
            curr_test_p = tp.test_plan[test_selection]
            num_tests = len(curr_test_p)
            test_id_index_list = range(0, num_tests, 2)

            for test_id_idx in test_id_index_list:
                test_id = curr_test_p[test_id_idx]
                num_param_sets = len(curr_test_p[test_id_idx + 1])
                test_exec_dic[test_id] = {'param_idx': test_id_idx + 1}
                test_exec_dic[test_id]['total_iterations'] = num_param_sets
                test_exec_dic[test_id]['curr_iteration'] = 0
                test_exec_dic[test_id]['test_file'] = tp.testFilefromID(
                    test_id)
                test_exec_dic[test_id]['test_func'] = tp.testFuncfromID(
                    test_id)
                test_exec_dic[test_id]['test_rat'] = 'Undef'
                total_test_count += num_param_sets

            func_name = sys._getframe(0).f_code.co_name
            logfilename = os.sep.join(
                os.environ['PL1_RF_SYSTEM_ROOT'].split(os.sep)[:] +
                ['%s.LOG' % func_name])
            cfg_multilogging(log_level=self.config.log, log_file=logfilename)
            logger_test = logging.getLogger('runTest')

            resultStrDic = OrderedDict()
            verdictObjDic = OrderedDict()
            startTimeDic = {}
            endTimeDic = {}

            if self.config.psugwip != 'ww.xx.yy.zz':
                '''
                if check_output_state_on(psu_gwip=self.config.psugwip,
                                         psu_gpib=self.config.psugpib,
                                         psu_name='E3631A_0',
                                         check_volts = self.config.psuvolt,
                                         check_curr_amps=2):
                '''
                if PsuCheckOn(psu_gwip=self.config.psugwip,
                              psu_gpib=self.config.psugpib,
                              check_volts=self.config.psuvolt,
                              check_curr_amps=2):

                    print "PSU is already switched on"
                else:
                    PsuBenchOn(psu_gwip=self.config.psugwip,
                               psu_gpib=self.config.psugpib,
                               setVolts=self.config.psuvolt,
                               Imax_A=2)

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

                        print "modem com port successfully found"

                        time_secs = 10

                        print "pausing for %s secs ..." % time_secs

                        time.sleep(time_secs)

                    else:
                        ErrMsg = "ERROR: runTest() : modem com port not found after switching on the PSU"
                        raise ExRunTest(ErrMsg)

            #Initiate CMW control

            if self.config.instr_ip == "no_instr":
                no_tester = True
            else:
                no_tester = False

            self.instr = cmw500.CmwControl(name=self.config.instr_name,
                                           ip_addr=self.config.instr_ip,
                                           NoTester=no_tester)

            for testID in test_exec_dic:

                while test_exec_dic[testID]['curr_iteration'] < test_exec_dic[
                        testID]['total_iterations']:

                    testfile = test_exec_dic[testID]['test_file']
                    testfunc = test_exec_dic[testID]['test_func']
                    testparams = tp.test_plan[test_selection][
                        test_exec_dic[testID]['param_idx']][
                            test_exec_dic[testID]['curr_iteration']]
                    finalTest = ((current_test_count + 1) == total_test_count)

                    self.print_pre_test_information(testID,
                                                    test_exec_dic[testID],
                                                    testparams)

                    if testfile == "wcdma_tx.py":

                        test_exec_dic[testID]['test_rat'] = 'WCDMA'
                        test_rf = Wcdma_tx(
                            testID=testID,
                            testConfig_s=self.config,
                            results_f=curr_f,
                            test_func=testfunc,
                            test_params=testparams,
                            test_rat='WCDMA',
                            final_test=finalTest,
                            unittest_enabled=self.unittest_enabled)

                    elif testfile == "lte_tx.py":

                        test_exec_dic[testID]['test_rat'] = 'LTE'

                        test_rf = Lte_tx(
                            testID=testID,
                            testConfig_s=self.config,
                            results_f=curr_f,
                            test_func=testfunc,
                            test_params=testparams,
                            test_rat='LTE',
                            final_test=finalTest,
                            unittest_enabled=self.unittest_enabled)

                    elif testfile == "general_purpose.py":

                        try:
                            testrat = tp.test_plan[test_selection][
                                test_exec_dic[testID]['param_idx']][
                                    test_exec_dic[testID]
                                    ['curr_iteration']]['rat']
                        except KeyError:
                            testrat = "None"

                        test_exec_dic[testID]['test_rat'] = testrat

                        test_rf = General_Purpose(
                            testID=testID,
                            testConfig_s=self.config,
                            results_f=curr_f,
                            test_func=testfunc,
                            test_params=testparams,
                            test_rat=testrat,
                            final_test=finalTest,
                            unittest_enabled=self.unittest_enabled)

                    else:

                        logger_test.warning(
                            "Test file %s does not exist. TestID %s SKIPPED" %
                            (testfile, testID))

                    test_param_idx = "%-08s  %s" % (
                        testID, str(test_exec_dic[testID]['curr_iteration']))
                    startTimeDic[test_param_idx] = time.localtime()
                    resultStrDic[test_param_idx], verdictObjDic[
                        test_param_idx] = test_rf.executeTest(self.instr)
                    endTimeDic[test_param_idx] = time.localtime()

                    test_exec_dic[testID]['curr_iteration'] = test_exec_dic[
                        testID]['curr_iteration'] + 1

                    if resultStrDic[test_param_idx] != rf_global.verdict_dict[
                            rf_global.PASS]:

                        overall_result_str = resultStrDic[test_param_idx]

                    current_test_count += 1

        except ExGeneral, e:
            print '%s' % e.message
            overall_result_str = rf_global.verdict_dict[rf_global.INCONC]
Exemplo n.º 3
0
    try:

        os.environ['PL1_WCDMA_TEST_ROOT']

    except:

        os.environ['PL1_WCDMA_TEST_ROOT'] = os.sep.join(
            abs_path.split(os.sep)[:-2] + ['pl1_wcdma_testbench'])

        print "os.environ[''PL1_WCDMA_TEST_ROOT']=%s" % os.environ[
            'PL1_WCDMA_TEST_ROOT']

    from pl1_testbench_framework.common.config.cfg_multilogging import cfg_multilogging

    cfg_multilogging(log_level="debug")

    band = 1

    modemObj = serialComms(timeout=15)

    modemObj.crash_simulation()

    modemObj.close()

    results_dir = os.sep.join(
        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
Exemplo n.º 4
0
            return (ec.ERRCODE_FLASH_FAILURE)


if __name__ == '__main__':

    import logging

    from pl1_testbench_framework.common.config.cfg_multilogging import cfg_multilogging

    logname = os.path.splitext(os.path.basename(__file__))[0]

    logfile = logname + '.LOG'

    loglevel = 'DEBUG'

    cfg_multilogging(loglevel, logfile)

    logger = logging.getLogger(logname)

    (cmdpath, cmdname) = os.path.split(os.path.abspath(__file__))

    results_dir = cmdpath

    SUCCESS = 0

    variant = {
        1: 'i500-121-1725-ti-att-mbim',
        2: 'nvidia-p2341-win7_internal'
    }[2]

    branch = {1: 'main.br', 2: 'pl1_dev.br', 3: 'cr4.br'}[2]
Exemplo n.º 5
0
    def runTest(self):

        code = CfgError()

        state = 0

        if self.cmwip == "x.y.w.z":

            print "ERROR: runme() : specify a valid CMW500 IP address"

            exit(code.ERRCODE_TEST_FAILURE_PARAMCONFIG)

        if self.test2execute.upper() == 'ALL':

            test2execute_l = sorted(test_plan.keys())

        else:

            test2execute_l = re.sub(r'[\[\]\s]', '',
                                    self.test2execute).split(',')

        logfilename = os.sep.join(
            os.environ['PL1TESTBENCH_ROOT_FOLDER'].split(os.sep)[:] +
            ['wcdma', 'runTest.LOG'])

        cfg_multilogging(log_level=self.log, log_file=logfilename)

        logger_test = logging.getLogger('runTest')

        curr_f = os.sep.join(
            os.environ['PL1TESTBENCH_ROOT_FOLDER'].split(os.sep)[:] +
            ['wcdma', 'results', 'current'])

        latest_f = os.sep.join(
            os.environ['PL1TESTBENCH_ROOT_FOLDER'].split(os.sep)[:] +
            ['wcdma', 'results', 'latest'])

        ts = time.strftime("%Y%m%d_%H%M%S", time.localtime())

        final_f = os.sep.join(
            os.environ['PL1TESTBENCH_ROOT_FOLDER'].split(os.sep)[:] +
            ['wcdma', 'results', ts + '_WCDMA_TestReport'])

        self.set_final_f(dst_folder=final_f)

        try:

            # Clean any curr_f from previous run

            if os.path.exists(curr_f):

                shutil.rmtree(curr_f)

            if os.path.exists(latest_f):

                shutil.rmtree(latest_f)

            for testID in test2execute_l:

                result = 0

                t0 = time.localtime()  # Probe start time

                testID = int(testID)

                curr_test_testtype = test_plan[testID]['TESTTYPE']

                self.msglog = self.stored_msg_log

                if curr_test_testtype == 'BLER_PERF':

                    testbler = Testbler(testID=testID, results_f=curr_f)

                elif curr_test_testtype == 'HSPA_BLER_PERF':

                    testbler = HspaTestbler(testID=testID, results_f=curr_f)

                elif curr_test_testtype == 'DCHSDPA_BLER_PERF':

                    # choose the correct object

                    testbler = DualCellHsdpaTestbler(testID=testID,
                                                     results_f=curr_f)

                elif curr_test_testtype == 'HSPA_FADING_PERF':

                    testbler = HspaFadingTestbler(testID=testID,
                                                  results_f=curr_f)

                    if self.unittest:

                        regression = 1

                        testbler.set_jenkins_regression(regression=regression)

                elif curr_test_testtype in [
                        'BLER_INTRAHO_ALL', 'BLER_INTRAHO_DEFAULT'
                ]:

                    testbler = Testbler(testID=testID,
                                        results_f=curr_f,
                                        intraHO=1)

                    if self.msglog:

                        logger_test.info(
                            "Intra HHO test auto modem logging will be disabled!"
                        )

                        self.msglog = 0

                elif curr_test_testtype in [
                        'HSPA_BLER_INTRAHO_DEFAULT',
                        'HSPA_BLER_INTRAHO_ALL',
                ]:

                    testbler = HspaTestbler(testID=testID,
                                            results_f=curr_f,
                                            intraHO=1)

                    if self.msglog:

                        logger_test.info(
                            "Intra HHO test auto modem logging will be disabled!"
                        )

                        self.msglog = 0

                elif curr_test_testtype in [
                        'DCHSDPA_BLER_INTRAHO_DEFAULT',
                        'DCHSDPA_BLER_INTRAHO_ALL'
                ]:

                    testbler = DualCellHsdpaTestbler(testID=testID,
                                                     results_f=curr_f,
                                                     intraHO=1)

                    if self.msglog:

                        logger_test.info(
                            "Intra HHO test auto modem logging will be disabled!"
                        )

                        self.msglog = 0

                elif curr_test_testtype in ['BLER_INTERBAND_DEFAULT']:

                    testbler = HspaInterBandHHO_testbler(testID=testID,
                                                         results_f=curr_f)

                    if self.msglog:

                        logger_test.info(
                            "Interband HHO test auto modem logging will be disabled!"
                        )

                        self.msglog = 0

                else:

                    logger_test.warning(
                        "Unknown test type %s. TestID %s SKIPPED" %
                        (curr_test.testtype, curr_test.testID))

                    continue

                testbler.set_test_config(log=self.log.upper(),
                                         cmwip=self.cmwip,
                                         ctrlif=self.ctrlif,
                                         test2execute=testID,
                                         pwrmeas=self.pwrmeas,
                                         usimemu=self.usimemu,
                                         psugwip=self.psugwip,
                                         psugpib=self.psugpib,
                                         msglog=self.msglog,
                                         database=self.database,
                                         remoteDB=self.remoteDB,
                                         remoteDBhost=self.remoteDBhost,
                                         remoteDBuid=self.remoteDBuid,
                                         remoteDBpwd=self.remoteDBpwd,
                                         remoteDBname=self.remoteDBname)

                result = testbler.runTest()

                if state == 0:

                    state = result

                else:

                    if result == state:

                        pass

                    else:

                        if result == 0:

                            pass

                        else:

                            # must be a new error

                            state = code.ERRCODE_TEST_FAILURE_GENERAL

        # end of for loop

        except SystemExit:

            exc_info = sys.exc_info()

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

            return (state)

        if self.get_numIterations > self.LOG_FILE_MIN_LIMIT:

            self.writeLogSummaryFile(
                testbler.csvSummaryReport.get_full_path_name())

        # Rename test result folder before exiting

        if os.path.isdir(latest_f):

            remove_dir(latest_f)

        if os.path.isdir(curr_f):

            shutil.copytree(curr_f, latest_f)

            os.rename(curr_f, final_f)

        return (state)