示例#1
0
    def printStreamResults_WMM(self):
        """Prints stream results of WMM"""
        summaryList = {}
        summaryStreamDisplay = {}
        maxRTP = 1
        i = 1

        if not self.test_mngr_initr.test_data_strm_mngr.data_strm.streamSendResultArray:
            self.test_mngr_initr.test_data_strm_mngr.resultPrinted = 0
        else:
            self.test_mngr_initr.test_data_strm_mngr.resultPrinted = 1

        for tbd in self.test_mngr_initr.test_prog_mngr.test_prog.testbed_dev_list:
            self.DisplayNameTable.setdefault(tbd.ctrlipaddr, tbd.displayname)

        logging.info("\n\r %-7s --------------------STREAM RESULTS-----------------------" % "")

        for s in self.test_mngr_initr.test_data_strm_mngr.data_strm.streamSendResultArray:
            sDisplayAddress = s.IPAddress
            if s.IPAddress in self.DisplayNameTable:
                sDisplayAddress = self.DisplayNameTable[s.IPAddress]
            for r in self.test_mngr_initr.test_data_strm_mngr.data_strm.streamInfoArray:
                if r.streamID == s.streamID and r.IPAddress == s.IPAddress and r.phase == s.phase:
                    recv_id = r.pairID
                    trafficClass = r.trafficClass
                    phase = r.phase
                    break
            for p in self.test_mngr_initr.test_data_strm_mngr.data_strm.streamRecvResultArray:
                pDisplayAddress = p.IPAddress
                if p.IPAddress in self.DisplayNameTable:
                    pDisplayAddress = self.DisplayNameTable[p.IPAddress]
                if p.streamID == recv_id and p.phase == s.phase:
                    logging.info("\n\r %-7s ----- RTP_%s-%s ( %s --> %s ) PHASE  = %s -----" %("", r.RTPID, trafficClass, sDisplayAddress, pDisplayAddress, p.phase))
                    logging.info("\n%s" % s)
                    summaryList.setdefault("%s:%s"%(int(r.RTPID), int(phase)), p.rxBytes)
                    summaryStreamDisplay.setdefault("%s:%s" % (int(r.RTPID), int(phase)), "RTP%-1s_%-10s [%s-->%s]" % (r.RTPID, trafficClass, sDisplayAddress, pDisplayAddress))
                    if maxRTP < int(r.RTPID):
                        maxRTP = int(r.RTPID)
                    logging.info("\n%s" % p)
                    break
        Util.set_color(Util.FOREGROUND_WHITE)
        logging.info("--------------------------SUMMARY----------------------------------")
        logging.info(" %46s %10s | %10s" % ("|", "Phase1 (Bytes)", "Phase2 (Bytes)"))
        logging.info("-------------------------------------------------------------------")
        while i <= maxRTP:
            str1 = ""
            str2 = ""
            stremDisplay = ""
            if "%s:%s"%(i, "1") in summaryList:
                str1 = summaryList["%s:%s" % (i, "1")]
                stremDisplay = summaryStreamDisplay["%s:%s"%(i, "1")]
            if "%s:%s"%(i, "2") in summaryList:
                str2 = summaryList["%s:%s" % (i, "2")]
                stremDisplay = summaryStreamDisplay["%s:%s"%(i, "2")]

            logging.info("\n%6s %-43s %5s %10s | %10s" % (" ", stremDisplay, "|", str1, str2))
            i = i + 1
        Util.set_color(Util.FOREGROUND_INTENSITY)
示例#2
0
    def log_currObj(self, curr_obj):
        """Logs an outgoing CAPI in the style of old UCC"""
        displaynamevalue = self.get_displayname(curr_obj)
        print_set = {'info', 'echo', 'AddSTAVersionInfo'}
        no_log_set = {'sleep', 'Phase'}
        stream_messages = {
            'max_throughput': 'Maximum Throughput %s Mbps',
            'payloadvalue': 'Payload = %s Bytes',
            'stream1': 'stream1 %s Frames / second',
            'stream2': 'stream2 %s Frames / second',
            'stream3': 'stream3 %s Frames / second',
            'stream_mt': 'stream_mt %s Frames / second',
            'stream_trans': 'stream_trans %s Frames / second'
        }
        if curr_obj.get_cmd().lower() in print_set:
            Util.set_color(Util.FOREGROUND_CYAN | Util.FOREGROUND_INTENSITY)
            logging.info('\n%s%s %s %s\n' %
                         (' ' * 8, '~' * 5, curr_obj.param, '~' * 5))
            Util.set_color(Util.FOREGROUND_WHITE)
        elif curr_obj.get_cmd().lower() in stream_messages:
            logging.info(stream_messages[curr_obj.get_cmd().lower()] %
                         (curr_obj.get_param()))
        elif curr_obj.get_cmd().lower() in no_log_set:
            logging.debug('%s %s' %
                          (curr_obj.get_cmd().lower(), curr_obj.get_param()))
        else:
            if (displaynamevalue is None
                    or displaynamevalue == '') and curr_obj.get_ipport() != '':
                displaynamevalue = curr_obj.get_ipport()
            if displaynamevalue is not None and displaynamevalue != '':
                if curr_obj.get_param() != '':
                    logging.info('%s (%s) ---> %s,%s' %
                                 (displaynamevalue, curr_obj.get_ipport(),
                                  curr_obj.get_cmd(), curr_obj.get_param()))
                else:
                    logging.info('%s (%s) ---> %s' %
                                 (displaynamevalue, curr_obj.get_ipport(),
                                  curr_obj.get_cmd()))

                if displaynamevalue == "SNIFFER":
                    TestLogFileSource.log_file_source_obj_list[
                        2].write_log_message(
                            "%s ---> %s,%s" %
                            (displaynamevalue, curr_obj.get_cmd(),
                             curr_obj.get_param()),
                            TestLogFileSource.log_file_hdl_list[2],
                            "SNIFFERLOG")
示例#3
0
    def process_CheckThroughput(self, line, Trans):
        """Determines throughput and prints the results and expected to logs"""
        try:
            cmd = line.split(',')

            duration = cmd[2]
            expected = cmd[3]
            id = cmd[0]


            P1 = -1
            logging.debug("Processing Throughput Check...")
            if Trans:
                for p in self.test_mngr_initr.test_data_strm_mngr.data_strm.streamSendResultArray:
                    if p.streamID == id and int(p.phase) == int(cmd[1]):
                        P1 = p.rxBytes
                        break
            else:
                for p in self.test_mngr_initr.test_data_strm_mngr.data_strm.streamRecvResultArray:
                    if p.streamID == id and int(p.phase) == int(cmd[1]):
                        P1 = p.rxBytes
                        if not P1:
                            P1 = -1
                        break

            if int(P1) <= 0:
                actual = -1
            else:
                actual = ((float(P1) * 8))/(1000000 * int(duration))

            if float(actual) >= float(expected):
                result = cmd[4]
            else:
                result = cmd[5]
            
            Util.set_color(Util.FOREGROUND_YELLOW | Util.FOREGROUND_INTENSITY)
            logging.debug(" Received = %s Bytes Duration = %s Seconds Expected = %s Mbps " % (P1, duration, expected))
            logging.info("\n Expected >= %s Mbps Actual = %s Mbps" % (expected, actual))
            
            if 'PASS' in result:
                Util.set_color(Util.FOREGROUND_GREEN | Util.FOREGROUND_INTENSITY)
                logging.info ("CHECK %s" % result)
                result = 'PASS'
            else :
                Util.set_color(Util.FOREGROUND_RED | Util.FOREGROUND_INTENSITY)
                logging.info ("CHECK %s" % result)
                result = 'FAIL'

            Util.set_color(Util.FOREGROUND_WHITE)
            return result
            
        except:
            exc_info = sys.exc_info()
            logging.error('Invalid Pass/Fail Formula - %s' % exc_info[1])
示例#4
0
    def printStreamResults_WPA2(self):
        """Prints stream results of WPA2"""
        maxRTP = 1
        Util.set_color(Util.FOREGROUND_WHITE)

        if not self.test_mngr_initr.test_data_strm_mngr.data_strm.streamSendResultArray:
            self.test_mngr_initr.test_data_strm_mngr.resultPrinted = 0
        else:
            self.test_mngr_initr.test_data_strm_mngr.resultPrinted = 1
        logging.info("\n\r %-7s --------------------STREAM RESULTS-----------------------" % "")

        for tbd in self.test_mngr_initr.test_prog_mngr.test_prog.testbed_dev_list:
            self.DisplayNameTable.setdefault(tbd.ctrlipaddr, tbd.displayname)

        for s in self.test_mngr_initr.test_data_strm_mngr.data_strm.streamSendResultArray:
            sDisplayAddress = s.IPAddress
            if s.IPAddress in self.DisplayNameTable:
                sDisplayAddress = self.DisplayNameTable[s.IPAddress]
            for r in self.test_mngr_initr.test_data_strm_mngr.data_strm.streamInfoArray:
                if r.streamID == s.streamID and r.IPAddress == s.IPAddress and r.phase == s.phase:
                    recv_id = r.pairID
                    trafficClass = r.trafficClass
                    phase = r.phase
                    break
            for p in self.test_mngr_initr.test_data_strm_mngr.data_strm.streamRecvResultArray:
                pDisplayAddress = p.IPAddress
                if p.IPAddress in self.DisplayNameTable:
                    pDisplayAddress = self.DisplayNameTable[p.IPAddress]
                if p.streamID == recv_id and p.phase == s.phase:
                    logging.info("\n\r %-7s -----  %s --> %s -----" %
                                 ("", sDisplayAddress, pDisplayAddress))
                    logging.info("\n%s" % s)
                    if maxRTP < int(r.RTPID):
                        maxRTP = int(r.RTPID)
                    logging.info("\n%s" % p)
                    break
        Util.set_color(Util.FOREGROUND_INTENSITY)
示例#5
0
    def init_logging(self, log_level):
        """Initializes loggers and assign them to corresponding log files.

        Args:
            log_level (str): The logging level to be set.
        """
        p = self.file_name.replace(".log", "").split('\\')
        #resultCollectionFile = open("TestResults", "a")
        for s in p:
            t_file_name = s

        tms_time_stamp = time.strftime("%b-%d-%Y__%H-%M-%S", time.localtime())
        directory = "./log/%s_%s" % (t_file_name.rstrip(".txt"), tms_time_stamp)
        #tmsLogLocation = directory
        os.makedirs(directory)

        TestScriptSymbolTable.insert_sym_tab("$logDir", directory.replace("log/", ""), TestScriptSymbolTable.test_script_sym_tab)

        os.system("echo %s > p" % directory)

        fname = "%s/log_%s.log" % (directory, t_file_name.rstrip(".txt"))
        TestScriptSymbolTable.insert_sym_tab("$logFullPath", fname, TestScriptSymbolTable.test_script_sym_tab)

        fname_sniffer = "%s/sniffer_log_%s.log" % (directory, t_file_name.rstrip(".txt"))

        logging.getLogger().handlers = []
        
        #tmsPacket.TestCaseId = tFileName.rstrip(".txt")
        #tmsPacket.LogFileName = fname

        self.create_log_file(fname_sniffer, ("SNIFFER CHECKS LOG - Testcase: %s \n\n" % t_file_name.rstrip(".txt")), 'a')
        
        color_stream = None
        if os.path.exists(GlobalConfigFiles.logging_config_file):
            with open(GlobalConfigFiles.logging_config_file, 'r') as f:
                config = json.load(f)
                file_handler = config['handlers']['file_handler']
                file_handler['filename'] = fname
                logging.config.dictConfig(config)
                
                file_lock = FileLocker()
                file_lock.add_logger()
        else:
            file_lock = FileLocker()
            file_lock.add_logger()
        
            fh = logging.FileHandler(fname, mode='w')
            #fh.setLevel(logging.DEBUG)
            fh.setLevel(logging.INFO)
        
            #a Handler which writes INFO messages or higher to the sys.stderr
            console = logging.StreamHandler()
            console.setLevel(logging.INFO)
    
            # set a format which is simpler for console use
            formatter = logging.Formatter('%(levelname)-8s %(message)s')
            formatter1 = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
            # tell the handler to use this format
            console.setFormatter(formatter)
            fh.setFormatter(formatter1)
            
            logging.getLogger().addHandler(console)
            logging.getLogger().addHandler(fh)            
            
        Util.set_color(Util.FOREGROUND_INTENSITY, color_stream)        

        #tmsPacket.getTestID(GlobalConfigFiles.VERSION)
        
        logging.info("###########################################################\n")
        logging.info("UWTS Version [%s]",GlobalConfigFiles.VERSION)
        logging.info('Logging started in file - %s' % (fname))
def main():
    fec = FrontendCli(
        'AC-11AG AC-11B AC-11N HS2 HS2-R2 N P2P PMF TDLS WFD WMM WPA2 WFDS VHT WMMPS NAN VE'
    )
    #sys.argv = ['uwts_ucc.exe', 'WFD', 'WFD-6.1.21B'] #HS2-4.15 HS2-5.6-A
    #sys.argv = ['uwts_ucc.exe', '-p', 'VHT', '-t', 'VHT-5.2.1']
    #sys.argv = ['uwts_ucc.exe', '-p', 'VHT', '-val']
    #sys.argv = ['uwts_ucc.exe', '-p', 'VHT', '-t', 'VHT-5.2.1', '--set-current-usermode', 'matl-mrcl']
    #sys.argv = ['uwts_ucc.exe', '-p', 'VHT', '--set-current-usermode', 'atl']
    #sys.argv = ['uwts_ucc.exe', '-p', 'VHT', '-t', 'VHT-5.2.1', '-val']
    #sys.argv = ['uwts_ucc.exe', '--show-usermode']
    #sys.argv = ['uwts_ucc.exe', '-v']
    #sys.argv = ['uwts_ucc.exe', '--get-current-usermode']
    #sys.argv = ['uwts_ucc.exe', '--set-default-usermode', 'atl']
    #sys.argv = ['uwts_ucc.exe', '--set-current-usermode', 'atl']

    #print sys.argv

    check_cmd_result = fec.fec_register_cmd().fec_check_cli_cmd(sys.argv)
    if check_cmd_result is not None and not isinstance(check_cmd_result,
                                                       argparse.Namespace):
        logging.error("Error in command line parse")
        exit(1)

    GlobalConfigFiles.usr_req_que = UserInteractQueue("REQUEST")
    GlobalConfigFiles.usr_resp_que = UserInteractQueue("RESPONSE")

    output_str = fec.check_instance(sys.argv)
    if output_str != "Start":
        return

    #register the Queue for FrontendCli
    if fec is not None:
        #start the tcp server here after one successful cli command
        fec_server = FrontendCliServer()
        fec_server.register_parent(fec).register_QCB(Cli_Fl_ctrl_req_Q=GlobalConfigFiles.usr_req_que, \
            Cli_Fl_ctrl_resp_Q=GlobalConfigFiles.usr_resp_que)
        fec_server.start()
    else:
        logging.error("Remote command not able to activate")

    if fec.testProgName is not None:
        prog_name = fec.testProgName[0]
        #print "progName : " + prog_name

    if fec.testCaseName is not None:
        script_name = fec.testCaseName[0]
        #print "scriptName : " + script_name

    Util.get_wts_build_version()

    TestFlowController.usr_action_cls = UserRequestAction()
    TestFlowController.usr_input_handle_thr = threading.Thread(
        target=TestFlowController.usr_action_cls.user_request_dispatcher)
    TestFlowController.usr_input_handle_thr.start()

    fec.handle_cli_cmd(sys.argv)

    TestFlowController.start_time = time.time()
    timeout = 5

    while time.time() < TestFlowController.start_time + timeout:
        #print "diff time %s" % (time.time() - start_time)
        if TestFlowController.usr_action_cls.usr_in_cmd is not None:
            #if prog_name == "AC-11AG" or prog_name == "AC-11B" or prog_name == "AC-11N":
            #    TestFlowController.usr_action_cls.usr_in_cmd.prog_name = "WMM-AC"
            #    prog_name = "WMM-AC"

            GlobalConfigFiles.init_cmd_file = GlobalConfigFiles.init_cmd_file.replace(
                "##", prog_name)
            GlobalConfigFiles.init_config_file = GlobalConfigFiles.init_config_file.replace(
                "##", prog_name)

            try:
                TestFlowController.start_test_execution_controller(
                    TestFlowController.usr_action_cls.usr_in_cmd)
                if TestFlowController.usr_action_cls.usr_in_cmd.is_testbed_val or TestFlowController.usr_action_cls.usr_in_cmd.is_testcase_val:
                    break
            except TestScriptVerificationError:
                logging.error("Aborting the test....", exc_info=False)
                #logging.error("%s Aborting the test...." % sys.exc_info()[1])
                break
            except:
                logging.error('caught:', exc_info=True)
                break
        else:
            break

    TestFlowController.usr_action_cls.is_running = False
    TestFlowController.usr_input_handle_thr.join()

    if fec_server is not None:
        fec_server.stop_server()
        fec_server.join()
    def generateFinalResult(self):
        """
        Print ending result to console
        """
        if self.__testResult == 'FAIL':
            Util.set_color(Util.FOREGROUND_RED | Util.FOREGROUND_INTENSITY)
        elif self.__testResult == 'PASS':
            Util.set_color(Util.FOREGROUND_GREEN | Util.FOREGROUND_INTENSITY)
        elif self.__testResult == 'NONE':
            Util.set_color(Util.FOREGROUND_GREEN | Util.FOREGROUND_INTENSITY) 
            self.__testResult = 'PASS'
        #else:
        total_count = int(TestScriptSymbolTable.get_value_from_sym_tab("total_count", TestScriptSymbolTable.test_result_tab))
        pass_count = int(TestScriptSymbolTable.get_value_from_sym_tab("pass_count", TestScriptSymbolTable.test_result_tab))
        fail_count = int(TestScriptSymbolTable.get_value_from_sym_tab("fail_count", TestScriptSymbolTable.test_result_tab))
        conditional_chk_flag = int(TestScriptSymbolTable.get_value_from_sym_tab("conditional_chk_flag", TestScriptSymbolTable.test_result_tab))
        num_of_pass_required = int(TestScriptSymbolTable.get_value_from_sym_tab("num_of_pass_required", TestScriptSymbolTable.test_result_tab))
            
        if total_count >= 1:
            if conditional_chk_flag == 1:
                if num_of_pass_required <= pass_count:
                    Util.set_color(Util.FOREGROUND_GREEN | Util.FOREGROUND_INTENSITY)
                    self.__testResult = 'PASS'
                else:
                    Util.set_color(Util.FOREGROUND_RED | Util.FOREGROUND_INTENSITY)
                    self.__testResult = 'FAIL'
            else:
                if fail_count > 0:
                    Util.set_color(Util.FOREGROUND_RED | Util.FOREGROUND_INTENSITY)
                    self.__testResult = 'FAIL'
                else:
                    Util.set_color(Util.FOREGROUND_GREEN | Util.FOREGROUND_INTENSITY)
                    self.__testResult = 'PASS'
        else:
            if GlobalConfigFiles.curr_tc_name != "":
                Util.set_color(Util.FOREGROUND_RED | Util.FOREGROUND_INTENSITY)
                logging.debug("\n   TEST COMPLETED without FINAL RESULT...")

            self.__testResult = 'FAIL'

        self.tmsPacket.TestResult = self.__testResult
        if GlobalConfigFiles.curr_tc_name != "":
            logging.info("\n    FINAL TEST RESULT  ---> %15s", self.__testResult)
            logging.info('     END: TEST CASE [%s]', GlobalConfigFiles.curr_tc_name)

        Util.set_color(Util.FOREGROUND_WHITE)
        GlobalConfigFiles.test_result = self.__testResult

        self.tmsPacket.TimeStamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.localtime())
        if GlobalConfigFiles.curr_tc_name != "":
            self.tmsPacket.writeTMSJson()

        return
def main():
    fec = FrontendCli('AC-11AG AC-11B AC-11N HS2 HS2-R2 N P2P PMF TDLS WFD WMM WPA2 WFDS VHT WMMPS NAN VE')
    #sys.argv = ['uwts_ucc.exe', 'WFD', 'WFD-6.1.21B'] #HS2-4.15 HS2-5.6-A
    #sys.argv = ['uwts_ucc.exe', '-p', 'VHT', '-t', 'VHT-5.2.1']
    #sys.argv = ['uwts_ucc.exe', '-p', 'VHT', '-val']
    #sys.argv = ['uwts_ucc.exe', '-p', 'VHT', '-t', 'VHT-5.2.1', '--set-current-usermode', 'matl-mrcl']
    #sys.argv = ['uwts_ucc.exe', '-p', 'VHT', '--set-current-usermode', 'atl']
    #sys.argv = ['uwts_ucc.exe', '-p', 'VHT', '-t', 'VHT-5.2.1', '-val']
    #sys.argv = ['uwts_ucc.exe', '--show-usermode']
    #sys.argv = ['uwts_ucc.exe', '-v']
    #sys.argv = ['uwts_ucc.exe', '--get-current-usermode']
    #sys.argv = ['uwts_ucc.exe', '--set-default-usermode', 'atl']
    #sys.argv = ['uwts_ucc.exe', '--set-current-usermode', 'atl']

    #print sys.argv
     
    check_cmd_result = fec.fec_register_cmd().fec_check_cli_cmd(sys.argv)
    if check_cmd_result is not None and not isinstance(check_cmd_result, argparse.Namespace):
        logging.error("Error in command line parse")
        exit(1)

    GlobalConfigFiles.usr_req_que = UserInteractQueue("REQUEST")
    GlobalConfigFiles.usr_resp_que = UserInteractQueue("RESPONSE")

    output_str = fec.check_instance(sys.argv)
    if output_str != "Start":
        return

    #register the Queue for FrontendCli
    if fec is not None:
        #start the tcp server here after one successful cli command
        fec_server = FrontendCliServer()
        fec_server.register_parent(fec).register_QCB(Cli_Fl_ctrl_req_Q=GlobalConfigFiles.usr_req_que, \
            Cli_Fl_ctrl_resp_Q=GlobalConfigFiles.usr_resp_que)
        fec_server.start()
    else:
        logging.error("Remote command not able to activate")

    if fec.testProgName is not None:
        prog_name = fec.testProgName[0]
        #print "progName : " + prog_name

    if fec.testCaseName is not None:
        script_name = fec.testCaseName[0]
        #print "scriptName : " + script_name 

    Util.get_wts_build_version()
    
    TestFlowController.usr_action_cls = UserRequestAction()
    TestFlowController.usr_input_handle_thr = threading.Thread(target=TestFlowController.usr_action_cls.user_request_dispatcher)
    TestFlowController.usr_input_handle_thr.start()

    fec.handle_cli_cmd(sys.argv)

    TestFlowController.start_time = time.time()
    timeout = 5
    
    while time.time() < TestFlowController.start_time + timeout:
        #print "diff time %s" % (time.time() - start_time)
        if TestFlowController.usr_action_cls.usr_in_cmd is not None:
            #if prog_name == "AC-11AG" or prog_name == "AC-11B" or prog_name == "AC-11N":
            #    TestFlowController.usr_action_cls.usr_in_cmd.prog_name = "WMM-AC"
            #    prog_name = "WMM-AC"
            
            GlobalConfigFiles.init_cmd_file = GlobalConfigFiles.init_cmd_file.replace("##", prog_name)
            GlobalConfigFiles.init_config_file = GlobalConfigFiles.init_config_file.replace("##", prog_name)

            try:
                TestFlowController.start_test_execution_controller(TestFlowController.usr_action_cls.usr_in_cmd)
                if TestFlowController.usr_action_cls.usr_in_cmd.is_testbed_val or TestFlowController.usr_action_cls.usr_in_cmd.is_testcase_val:
                    break
            except TestScriptVerificationError:
                logging.error("Aborting the test....", exc_info=False)
                #logging.error("%s Aborting the test...." % sys.exc_info()[1])
                break
            except:
                logging.error('caught:', exc_info=True)
                break
        else:
            break

    TestFlowController.usr_action_cls.is_running = False
    TestFlowController.usr_input_handle_thr.join()

    if fec_server is not None:
        fec_server.stop_server()
        fec_server.join()
示例#9
0
    def process_passFailWMM(self, line, case):
        """Determines pass or fail for WMM based on two phases result and what is expected"""
        try:
            cmd = line.split(',')
            P1 = -1
            P2 = -1

            id = cmd[0]
            id1 = cmd[1]
            expectedVal = cmd[2]
            #print "wmm stream ids and expectedval:%s***%s***%s" % (id,id1,expectedVal)
            for p in self.test_mngr_initr.test_data_strm_mngr.data_strm.streamRecvResultArray:
                #print "in for loop ---> p.streamID / p.phase / p.rxBytes :" + str(p.streamID) +'/'+  p.phase + '/' + str(p.rxBytes)
                if p.streamID == id and int(p.phase) == 1:#int(self.running_phase):
                    P1 = p.rxBytes
                elif p.streamID == id1 and int(p.phase) == 2:#int(self.running_phase):
                    P2 = p.rxBytes

            if (int(P2) <= 0) or (int(P1) <= 0):
                actual = -1
            else:
                actual = (float(P2) / float(P1)) * 100

            if case == 0:
                if actual > long(expectedVal):
                    Util.set_color(Util.FOREGROUND_GREEN | Util.FOREGROUND_INTENSITY)
                    result = cmd[3]
                else:
                    Util.set_color(Util.FOREGROUND_RED | Util.FOREGROUND_INTENSITY)
                    result = cmd[4]

                logging.info("\n       ----------------RESULT---------------------------\n")
                logging.info("%s Phase 1 = %s Bytes | %s Phase 2 = %s Bytes " %(cmd[5], P1, cmd[5], P2))
                logging.info("Expected  > %s %s" % (expectedVal, "%"))
                logging.info("Actual -  %6.6s %s" % (actual, "%"))
                logging.info("TEST RESULT ---> %s" % result)
                logging.info("\n       ------------------------------------------------")

            elif case == 1:
                if actual <= long(expectedVal):
                    Util.set_color(Util.FOREGROUND_GREEN | Util.FOREGROUND_INTENSITY)
                    result = cmd[3]
                else:
                    Util.set_color(Util.FOREGROUND_RED | Util.FOREGROUND_INTENSITY)
                    result = cmd[4]

                logging.info("\n       ----------------RESULT---------------------------\n")
                logging.info("Expected  <= %s %s" % (expectedVal, "%"))
                logging.info("Actual -  %6.6s %s" % (actual, "%"))
                logging.info("TEST RESULT ---> %s" % result)
                logging.info("\n       ------------------------------------------------")
            elif case == 2:
                if actual >= long(expectedVal):
                    Util.set_color(Util.FOREGROUND_GREEN | Util.FOREGROUND_INTENSITY)
                    result = cmd[3]
                else:
                    Util.set_color(Util.FOREGROUND_RED | Util.FOREGROUND_INTENSITY)
                    result = cmd[4]

                logging.info("\n       ----------------RESULT---------------------------\n")
                logging.info("Expected  >= %s %s" % (expectedVal, "%"))
                logging.info("Actual -  %6.6s %s" % (actual, "%"))
                logging.info("TEST RESULT ---> %s" % result)
                logging.info("\n       ------------------------------------------------")

            Util.set_color(Util.FOREGROUND_WHITE)
            
            return result

        except:
            exc_info = sys.exc_info()
            logging.error('Invalid Pass/Fail Formula - %s' % exc_info[1])
示例#10
0
    def generateFinalResult(self):
        """
        Print ending result to console
        """
        if self.__testResult == 'FAIL':
            Util.set_color(Util.FOREGROUND_RED | Util.FOREGROUND_INTENSITY)
        elif self.__testResult == 'PASS':
            Util.set_color(Util.FOREGROUND_GREEN | Util.FOREGROUND_INTENSITY)
        elif self.__testResult == 'NONE':
            Util.set_color(Util.FOREGROUND_GREEN | Util.FOREGROUND_INTENSITY)
            self.__testResult = 'PASS'
        #else:
        total_count = int(
            TestScriptSymbolTable.get_value_from_sym_tab(
                "total_count", TestScriptSymbolTable.test_result_tab))
        pass_count = int(
            TestScriptSymbolTable.get_value_from_sym_tab(
                "pass_count", TestScriptSymbolTable.test_result_tab))
        fail_count = int(
            TestScriptSymbolTable.get_value_from_sym_tab(
                "fail_count", TestScriptSymbolTable.test_result_tab))
        conditional_chk_flag = int(
            TestScriptSymbolTable.get_value_from_sym_tab(
                "conditional_chk_flag", TestScriptSymbolTable.test_result_tab))
        num_of_pass_required = int(
            TestScriptSymbolTable.get_value_from_sym_tab(
                "num_of_pass_required", TestScriptSymbolTable.test_result_tab))

        if total_count >= 1:
            if conditional_chk_flag == 1:
                if num_of_pass_required <= pass_count:
                    Util.set_color(Util.FOREGROUND_GREEN
                                   | Util.FOREGROUND_INTENSITY)
                    self.__testResult = 'PASS'
                else:
                    Util.set_color(Util.FOREGROUND_RED
                                   | Util.FOREGROUND_INTENSITY)
                    self.__testResult = 'FAIL'
            else:
                if fail_count > 0:
                    Util.set_color(Util.FOREGROUND_RED
                                   | Util.FOREGROUND_INTENSITY)
                    self.__testResult = 'FAIL'
                else:
                    Util.set_color(Util.FOREGROUND_GREEN
                                   | Util.FOREGROUND_INTENSITY)
                    self.__testResult = 'PASS'
        else:
            if GlobalConfigFiles.curr_tc_name != "":
                Util.set_color(Util.FOREGROUND_RED | Util.FOREGROUND_INTENSITY)
                logging.debug("\n   TEST COMPLETED without FINAL RESULT...")

            self.__testResult = 'FAIL'

        self.tmsPacket.TestResult = self.__testResult
        if GlobalConfigFiles.curr_tc_name != "":
            logging.info("\n    FINAL TEST RESULT  ---> %15s",
                         self.__testResult)
            logging.info('     END: TEST CASE [%s]',
                         GlobalConfigFiles.curr_tc_name)

        Util.set_color(Util.FOREGROUND_WHITE)
        GlobalConfigFiles.test_result = self.__testResult

        self.tmsPacket.TimeStamp = time.strftime('%Y-%m-%dT%H:%M:%SZ',
                                                 time.localtime())
        if GlobalConfigFiles.curr_tc_name != "":
            self.tmsPacket.writeTMSJson()

        return