Exemplo n.º 1
0
    def export_pcap( self, source_file, dest_file , format = FILE_DEFAULT_FORMAT, frames_to_export = -1):
        
        frames_range = ''

        if  not(os.path.exists(source_file)):
            globals.Error("File not exists")

        if type(frames_to_export) == int:
            if frames_to_export == '-1':
                frame_range = ""
            elif frames_to_export > 0:
                frames_range = '-R frame.number == %d' % frames_to_export
        elif type(frams_to_export) == string:
            if len(frames_to_export.split('-'))>1:
                frames_range = "-R \"frame.number>=%s && frame.number<=%s\"" % ( frames_to_export.split('-')[0].strip(),  frames_to_export.split('-')[1].strip() )
            else:
                Error("frames_to_export value is mismatch, either number or range etc: 1 or 1-5")

        file_args =  ' -r %s -T %s %s >%s' % ( source_file, format, frames_range, dest_file ) 

        cmd = "\"" + self.tsharks_file + "\"" + file_args
        try:
            data =  subprocess.check_output(cmd, shell = True)
        except WindowsError as e:
            raise globals.Error("FAILED : Please make sure the path are correct")
        except subprocess.CalledProcessError as e:
            raise globals.Error("FAILD : Process failed with return value diffrent from 0")

        return globals.EXIT_OK
Exemplo n.º 2
0
    def __init__(self):
        # Store handler for function
        self.pckt_handler = None
        self.num_packets = 0
        # Set Max recursion limit for parse_file
        # sys.setrecursionlimit(10)

        # Process os 
        if 'win32' in sys.platform:
            import win32process
            if win32process.IsWow64Process () == True:
                self.capinfos_file = 'c:\\Program Files (x86)\\Wireshark\\capinfos.exe'
                self.tsharks_file = 'c:\\Program Files (x86)\\Wireshark\\tshark.exe'
            else:
                self.capinfos_file = 'c:\\Program Files\\Wireshark\\capinfos.exe'
                self.tsharks_file = 'c:\\Program Files\\Wireshark\\tshark.exe'
 
        elif 'linux' in sys.platform:
            self.capinfos_file = "./capinfos"
            self.tsharks_file = "./tshark"
        else:
            raise globals.Error("Unknown os type, where is capinfos.exe")
        
        if not( os.path.exists(self.capinfos_file) or os.path.exists(self.tsharks_file) ):
            raise globals.Error("Tshark or capinfos file not found, please make sure you have a full WireShark full installtion")
Exemplo n.º 3
0
    def initialization(self):

        self.status_tx_power = False
        self.status_tx_evm = False
        self.status_tx_iq_ampl_imbalance = False
        self.status_tx_iq_phase_imbalance = False
        self.status_dc_lo_leakage = False
        self.status_freq_error = False
        self.status_sym_clock_error = False


        # Verify uut idx exits
        try:
            self.uut = globals.setup.units.unit(self._uut_id[0])
            self.uut.create_fw_cli()                                # create cli connection for (23,1123,terminal)
            self.fw_cli = self.uut.fw_cli('23')                     # get cli from telnet port 23
            self.uboot = self.uut.fw_cli('terminal').u_boot
            self.consts = setup_consts.CONSTS[globals.setup.station_parameters.station_name]
        except KeyError as e:
            raise globals.Error("uut index and interface input is missing or currpted, usage : uut_id=(0,1)")

        # Get RF switch handle from setup
        log.info("RF switch configuration")
        if globals.setup.instruments.rf_switch_box is None:
           raise globals.Error("RF switch is not initilized, please check your configuration")

        # Get pointer to object
        self.rf_switch_box = globals.setup.instruments.rf_switch_box

        # VSA select switch
        self.rf_switch_box.set_switch('A',self.param['rf_if']+1) # setup RF Switch A to com 1/2   (com1 selection for chA,com2 selection for chB)
        self.rf_switch_box.set_switch('B',1) # Switch B to com 1 

        # Set frequency
        self.uut.managment.set_rf_frequency( self.param['ch_freq'], self.rf_if )

        # Set rate
        self.uut.managment.set_rf_rate( self.param['snmp_rate'], self.rf_if )
        
        # Compensator connected/disconnected
        self.uut.managment.set_rf_frontend_enable( self.param['rf_front_end_compensator'], self.rf_if )

        # Set tx power
        self.uut.managment.set_tx_power( self.param['tx_power'], self.rf_if )    #Set tx power to 20dBm

        # Set RF OFDM channel bandwidth
        self.uut.managment.set_rf_ofdm_chan_bandwidth( self.param["bandwidth"], self.rf_if )

        # Get Signal tester VSG/MXG handle from setup
        log.info("Signal tester VSA/VSG/MXG configuration")
        if globals.setup.instruments.rf_vector_signal is None:
            raise globals.Error("Signal tester is not initilized, please check your configuration")

        self.vsa = globals.setup.instruments.rf_vector_signal['vsa']

        # VSA settings
        port = 2 # left port VSA mode
        atten = self.consts.common[ 'TX_PATH_SETUP_ATTENUATION_DB' + "_" + str( self.rf_if ) + "_" + self.param['board_type'] ] 
        self.vsa.vsa_settings(self.param['ch_freq'], self.consts.common['VSA_MAX_SIGNAL_LEVEL_DBM'], port, atten, self.consts.common['VSA_TRIGGER_LEVEL_DB'], self.consts.common['VSA_CAPTURE_WINDOW'] )
        time.sleep(0.5)
Exemplo n.º 4
0
    def unit_configuration(self):
        super(TC_CAN_LOAD_2DEVICES, self).unit_configuration()

        self.uut_can_if.append(self.uut.can_interfaces[self.uut_id[2]])
        if not self.uut_can_if[1].active:
            raise globals.Error("CAN device {} is not active.".format(
                self.uut_can_if[1].device_id))

        self.can_cli2 = self.uut.create_qa_cli("can_cli2",
                                               target_cpu=self.target_cpu)
        ret = self.can_cli2.can.socket_create(self.uut_can_if[1].device_id, {})
        if "ERROR :" in ret:
            raise globals.Error(
                "Can socket create received error {}".format(ret))

        self.can_cli2.can.reset_counters()

        self.can_cli_rx2 = self.uut.create_qa_cli("can_cli_rx2",
                                                  target_cpu=self.target_cpu)
        ret = self.can_cli_rx2.can.socket_create(self.uut_can_if[1].device_id,
                                                 {})
        if "ERROR :" in ret:
            raise globals.Error(
                "Can socket create received error {}".format(ret))

        self.can_cli_rx2.can.reset_counters()
Exemplo n.º 5
0
        def test_initilization(self):

            # Get sniffer handle from setup
            log.info("Getting Sniffer info")
            if globals.setup.instruments.sniffer is None:
                raise globals.Error("Sniffer is not initilize or define in setup, please check your configuration")
            else:
                # Get pointer to object
                sniffer = globals.setup.instruments.sniffer

            # initlize sniffer
            sniffer.initialize()


            log.info("Getting GPS simulator in config")
            if globals.setup.instruments.gps_simulator is None:
                raise globals.Error("gps simulator is not initilize, please check your configuration")
            else:
                # Get pointer to object
                gps_sim = globals.setup.instruments.gps_simulator

            # set general tx power
            gps_sim.tx_power( self._gps_tx_power )  
            #load scenario
            gps_sim.load( self._gps_scenario )



            dir_name = tempfile.gettempdir()
            timestr = time.strftime("%Y%m%d-%H%M%S")
            self.test_file_name = 'tc_bsm_hardbake_rec'
            self.gps_file = os.path.join( tempfile.gettempdir(), self.test_file_name + "_" + time.strftime("%Y%m%d-%H%M%S") + "." + 'txt')
            self.sniffer_file = os.path.join( common.SNIFFER_DRIVE , self.test_file_name + "_" + time.strftime("%Y%m%d-%H%M%S") + "." + 'pcap')
Exemplo n.º 6
0
    def unit_configuration(self):
        self.uut_index = self.uut_id[0]

        # Verify uut idx exits
        try:
            self.uut = globals.setup.units.unit(self.uut_index)
        except KeyError as e:
            raise globals.Error(
                "uut index and interface input is missing or corrupted, usage : uut_id=(0,1)"
            )

        self.uut_can_if.append(self.uut.can_interfaces[self.uut_id[1]])
        if not self.uut_can_if[0].active:
            raise globals.Error("CAN device {} is not active.".format(
                self.uut_can_if[0].device_id))

        # Open new v2x-cli
        self.can_cli = self.uut.create_qa_cli("can_cli",
                                              target_cpu=self.target_cpu)
        self.can_cli.can.service_create()
        ret = self.can_cli.can.socket_create(self.uut_can_if[0].device_id, {})
        if "ERROR :" in ret:
            raise globals.Error(
                "Can socket create received error {}".format(ret))

        self.can_cli.can.reset_counters()
Exemplo n.º 7
0
    def test_nav_api(self):
        """ Test nav api correctness
            @fn         test_nav_api_1
            @brief      Verify nav api data and accurecy correctness 
            @details    Test ID	: TC_SDK2.1_NAV_01\n
                        Test Name 	: NAV API\n
                        Objective 	: Validate correct positioning data reported by NAV API\n
                        Reference	: REQ_SDK2.1_NAVAPI_01\n
            @see Test Plan	: \\fs01\docs\system\Integration\Test_Plans\SW_Releases\SDK2.1\SDK2_1_Test_Plan_v2.docx\n
        """

        # unit configuration
        print >> self.result._original_stdout, "Starting : {}".format(
            self._testMethodName)

        #Test scenario shall include the following driving segments (derived from SafetyPilot test scenario), played by GNSS simulator:
        #Each test case should be executed at least 5 minutes.
        #Segment	Detail
        #Straight line	Straight line, driving speed 50kph ? 100kph.
        #Elliptic track course	50, 100,150 kph driving speed
        #Figure ? 8	50, 100,150 kph driving speed

        #Additional scenario details:
        #HDOP < 5

        #Get position data that described in table below via NAV API.

        self.get_test_parameters()
        # Verify uut input exists and active
        self._uut_id = self.param.get('uut_id', None)
        if self._uut_id is None:
            raise globals.Error(
                "uut index and interface input is missing or currpted, usage : uut_id=(0,1)"
            )

        # Verify uut idx exits
        try:
            self.uut = globals.setup.units.unit(self._uut_id[0])
        except KeyError as e:
            raise globals.Error(
                "uut index and interface input is missing or currpted, usage : uut_id=(0,1)"
            )

        self.uut_channel = self._uut_id[1]

        # self.debug_override()

        self.instruments_initilization()

        rv = self.unit_configuration()
        # Check if unit is locked
        if rv == True:
            self.main()

        self.analyze_results()

        self.print_results()
        print >> self.result._original_stdout, "test, {} completed".format(
            self._testMethodName)
Exemplo n.º 8
0
    def initialization(self):
        # Verify uut idx exits
        try:
            self.uut = globals.setup.units.unit(self._uut_id[0])
            self.uut.create_fw_cli(
            )  # create cli connection for (23,1123,terminal)
            self.fw_cli = self.uut.fw_cli('23')  # get cli from telnet port 23
            self.uboot = self.uut.fw_cli('terminal').u_boot
            self.consts = setup_consts.CONSTS[
                globals.setup.station_parameters.station_name]
        except KeyError as e:
            raise globals.Error(
                "uut index and interface input is missing or currpted, usage : uut_id=(0,1)"
            )

        # Get Signal tester VSG/MXG handle from setup
        log.info("Signal tester VSA/VSG/MXG configuration")
        if globals.setup.instruments.rf_vector_signal is None:
            raise globals.Error(
                "Signal tester is not initilized, please check your configuration"
            )

        self.vsg = globals.setup.instruments.rf_vector_signal['vsg']

        # Get RF switch handle from setup
        log.info("RF switch configuration")
        if globals.setup.instruments.rf_switch_box is None:
            raise globals.Error(
                "RF switch is not initilized, please check your configuration")

        # Get pointer to object
        self.rf_switch_box = globals.setup.instruments.rf_switch_box

        # MXG/VSG select switch
        self.rf_switch_box.set_switch(
            'A', self.param['rf_if'] + 1
        )  # setup RF Switch A to com 1/2   (com1 selection for chA,com2 selection for chB)
        self.rf_switch_box.set_switch('B', 2)  # Switch B to com 2

        if globals.setup.instruments.power_control is None:
            raise globals.Error(
                "Power control is not initilized, please check your configuration"
            )

        self.power_control = globals.setup.instruments.power_control

        # Set frequency
        self.uut.managment.set_rf_frequency(self.param['ch_freq'], self.rf_if)

        # Compensator connected/disconnected
        self.uut.managment.set_rf_frontend_enable(
            self.param['rf_front_end_compensator'], self.rf_if)

        print >> self.result._original_stdout, "\nWaiting for loading file to vsg.. "
        self.vsg.load_file(self.param['test_data_dir'],
                           self.param['data_waveform'],
                           self.param['bandwidth'])
        self.vsg.rf_enable(True)
Exemplo n.º 9
0
        def test_initilization(self):

            # Get sniffer handle from setup
            log.info("Getting Sniffer info")
            if globals.setup.instruments.sniffer is None:
                raise globals.Error(
                    "Sniffer is not initilize or define in setup, please check your configuration"
                )
            else:
                # Get pointer to object
                sniffer = globals.setup.instruments.sniffer

            # initlize sniffer
            sniffer.initialize()

            log.info("Getting GPS simulator in config")
            if globals.setup.instruments.gps_simulator is None:
                #raise globals.Error("gps simulator is not initilize, please check your configuration")
                gps_sim = None
            else:
                # Get pointer to object
                gps_sim = globals.setup.instruments.gps_simulator

            if globals.setup.instruments.can_bus is None:
                raise globals.Error(
                    "Can bus server is not initilize, please check your configuration"
                )
            else:
                # Get pointer to object
                self._can_bus_sim = globals.setup.instruments.can_bus

            #self._komodo = Komodo.Komodo()
            self._can_bus_sim.configure_port(self._can_inferface)
            self._can_bus_sim.power_up(self._can_inferface)
            #self._can_bus_sim.power_down(self._can_inferface)
            #self._komodo.power_down(self._komodo_interface)

            self.gm_can_msgs = gm_can_definitions.GmCanMessages(
                self._can_bus_sim, self._can_inferface)

            # set general tx power
            if not gps_sim is None:
                gps_sim.tx_power(self._gps_tx_power)
            #load scenario
            if not gps_sim is None:
                gps_sim.load(self._gps_scenario)

            dir_name = tempfile.gettempdir()
            timestr = time.strftime("%Y%m%d-%H%M%S")
            self.test_file_name = 'tc_can_2_bsm_rec'
            self.gps_file = os.path.join(
                tempfile.gettempdir(), self.test_file_name + "_" +
                time.strftime("%Y%m%d-%H%M%S") + "." + 'txt')
            self.sniffer_file = os.path.join(
                common.SNIFFER_DRIVE, self.test_file_name + "_" +
                time.strftime("%Y%m%d-%H%M%S") + "." + 'pcap')
Exemplo n.º 10
0
    def verify_ack(self, timout_sec=2):

        data = self.clean_ansi_escape(
            self._if.read_until(self._prompt, timout_sec))
        if 'OK' in data:
            return True
        elif 'ERR' in data:
            raise globals.Error("Error in Command")
        else:
            raise globals.Error("No ack")
Exemplo n.º 11
0
def get_value(json_data, key_name):
    """ Get value from json ctype configuration file """
    try:
        return json_data[key_name]
    except KeyError:
        raise globals.Error(
            'File corrupt, file should contain `%s\' attribute' % (key_name))
    else:
        raise globals.Error(
            "Unknow error getting value from configuration file. key : `%s\'" %
            (key_name))
Exemplo n.º 12
0
    def _check_connection(self):
        self._if.write("\n", False)
        str = self.clean_ansi_escape(self._if.read_until(self._prompt, 2))

        if self._prompt in str:
            return True
        if 'Connection is already in use by' in str:
            raise globals.Error(
                "Unable to connect to LABSAT, connection is busy")

        raise globals.Error("Unable to connect to LABSAT, unknown reason")
Exemplo n.º 13
0
    def _read_until(self, data, timeout):
        """ Read data until prompt """
        try:
            data = self._host.read_until(data, timeout)
        except EOFError as e:
            raise globals.Error(
                'ERROR : EOF rasied, no data to read from server')
        except Exception as e:
            raise globals.Error(
                'ERROR : Error reading from unit, {}'.format(e))

        return data
Exemplo n.º 14
0
    def test_vca_1(self):
        # Parse test parameters
        # params = [ tParam( tx = (0,1), rx = (1,1), proto_id = 0, frames = 1000, frame_rate_hz = 50, tx_data_len = 100, tx_data_val = 'ab', tx_power = -5 ) ]
        self._test_params = self.param.get('params', None)
        if self._test_params is None:
            raise globals.Error(
                "uut index and interface input is missing or currpted, usage : params = tParam( tx = (0,1), rx = (1,1), proto_id = 0, frames = 1000, frame_rate_hz = 50, tx_data_len = 100, tx_data_val = 'ab', tx_power = -5 )"
            )

        # Get & parse test parameters
        self.get_test_parameters()

        # Verify uut input exists and active
        self.rf_if_tx_params_list = []
        self.rf_if_rx_params_list = []
        for t_params in self._test_params:
            self.rf_if_rx_params_list.append(
                self.Rf_if_basic_params(t_params.rx[0], t_params.rx[1]))
            if t_params.tx_power == None or t_params.frame_rate_hz == None:
                raise globals.Error(
                    "Missing tx_power or frame_rate_hz from input params")
            self.rf_if_tx_params_list.append(
                self.Rf_if_tx_params(t_params.tx[0], t_params.tx[1],
                                     t_params.tx_power,
                                     t_params.frame_rate_hz))

        self.uuts = []
        for rf_if in self.rf_if_tx_params_list + self.rf_if_rx_params_list:
            self.uuts.append(globals.setup.units.unit(rf_if.uut_idx))
        self.uuts = set(self.uuts)

        #self._clean_logs()

        self.log = logging.getLogger(__name__)
        self.stats = self.Statistics()

        self.initilization()

        # Set Rf Frequenct & tx_power
        for rf_if_params in self.rf_if_tx_params_list:
            rf_if_params.uut.managment.set_rf_frequency(
                rf_if_params.freq, rf_if_params.rf_if)
            rf_if_params.uut.managment.set_tx_power(rf_if_params.tx_power,
                                                    rf_if_params.rf_if)

        for rf_if_params in self.rf_if_rx_params_list:
            rf_if_params.uut.managment.set_rf_frequency(
                rf_if_params.freq, rf_if_params.rf_if)

        (tx_vca_cnt, rx_vca_cnt, tx_hw_cnt, rx_hw_cnt) = self.main_test()

        self.print_report(tx_vca_cnt, rx_vca_cnt, tx_hw_cnt, rx_hw_cnt)
Exemplo n.º 15
0
    def setUp(self):
        # Verify uut input exists and active
        self._uut_id = self.param.get('uut_id', None )
        if self._uut_id is None:
            raise globals.Error("uut index and interface input is missing or currpted, usage : uut_id=(0,1)")

        # Verify uut idx exits
        try:
            self.uut = globals.setup.units.unit(self._uut_id[0])
            self.uut.create_fw_cli()                                # create cli connection for (23,1123,terminal)
            self.fw_cli = self.uut.fw_cli('23')                     # get cli from telnet port 23
            self.consts = setup_consts.CONSTS[globals.setup.station_parameters.station_name]
        except KeyError as e:
            raise globals.Error("uut index and interface input is missing or currpted, usage : uut_id=(0,1)")
Exemplo n.º 16
0
    def get_num_packets(self, pcap_file):
        """
        TBD : consider use of pypcapfile lbrary for this actions
        """
        try:
            data =  subprocess.check_output([self.capinfos_file,self.pcap_file])
        except WindowsError as e:
            raise globals.Error("FAILED : Please make sure the path are correct")
        except subprocess.CalledProcessError as e:
            raise globals.Error("FAILD : Process failed with return value diffrent from 0")

        data = data.split('\r\n')
        # Get numner of packet in file
        self.num_packets = int(data[4].split(':')[1].strip())
        return self.num_packets
Exemplo n.º 17
0
    def instruments_initilization(self):

        # Initilize GPS
        self.gps_init(self._gps_scenario, self._gps_tx_power)

        # Get sniffer handle from setup
        self.sniffer = globals.setup.instruments.sniffer
        if self.sniffer is None:
            raise globals.Error(
                "Sniffer is not initilize or define in setup, please check your configuration"
            )

        # initlize sniffer
        self.sniffer.initialize()
        self.sniffer.set_interface([0, 1])
        # tshark app used for capturing frames must verify license of sirit and it take time ~ 15 seconds
        time.sleep(20)

        if self.sniffer.type == 'sirit':
            self.sniffer.configure_dsrc_tool()

        self.can_bus = globals.setup.instruments.can_bus
        if self.can_bus == None:
            raise Exception(
                "CAN BUS simulator is missing in current configuration")

        # create capture files for gps and sniffer
        self.gps_file = os.path.join(
            tempfile.gettempdir(), self._testMethodName + "_" +
            time.strftime("%Y%m%d-%H%M%S") + "." + 'txt')
        self.sniffer_file = os.path.join(
            common.SNIFFER_DRIVE, self._testMethodName + "_" +
            time.strftime("%Y%m%d-%H%M%S") + "." + 'pcap')
Exemplo n.º 18
0
 def disconnect(self):
     if self._host is None:
         raise globals.Error('ERROR : system is not connected to any host')
     try:
         self.send_command("exit", False)
     except Exception:
         pass
Exemplo n.º 19
0
    def instruments_initilization(self):

        # Initilize GPS
        self.gps_init(self._gps_scenario, self._gps_tx_power)

        # Get sniffer handle from setup
        self.log.info("Getting Sniffer info")
        if globals.setup.instruments.sniffer is None:
            raise globals.Error(
                "Sniffer is not initilize or define in setup, please check your configuration"
            )
        else:
            # Get pointer to object
            self.sniffer = globals.setup.instruments.sniffer

        # initlize sniffer
        self.sniffer.initialize()
        self.sniffer.set_interface([0, 1])
        # tshark app used for capturing frames must verify license of sirit and it take time ~ 15 seconds
        time.sleep(20)

        # create capture files for gps and sniffer
        self.gps_file = os.path.join(
            tempfile.gettempdir(), self._testMethodName + "_" +
            time.strftime("%Y%m%d-%H%M%S") + "." + 'txt')
        self.sniffer_file = os.path.join(
            common.SNIFFER_DRIVE, self._testMethodName + "_" +
            time.strftime("%Y%m%d-%H%M%S") + "." + 'pcap')
Exemplo n.º 20
0
 def setUp(self):
     # Verify uut input exists and active
     self._uut_id = self.param.get('uut_id', None)
     if self._uut_id is None:
         raise globals.Error(
             "uut index and interface input is missing or currpted, usage : uut_id=(0,1)"
         )
Exemplo n.º 21
0
    def initilization(self):

        # Get sniffer handle from setup
        log.info("Getting Sniffer info")
        if globals.setup.instruments.sniffer is None:
            raise globals.Error(
                "Sniffer is not initilize or define in setup, please check your configuration"
            )
        else:
            # Get pointer to object
            self.sniffer = globals.setup.instruments.sniffer

        # initlize sniffer
        self.sniffer.initialize()

        self.sniffer.set_interface([0, 1])

        # Initilize GPS
        self.gps_sim = self.gps_init(self._gps_scenario, self._gps_tx_power)
        self.gps_file = os.path.join(
            tempfile.gettempdir(), self._testMethodName + "_" +
            time.strftime("%Y%m%d-%H%M%S") + "." + 'txt')
        self.sniffer_file = os.path.join(
            common.SNIFFER_DRIVE, self._testMethodName + "_" +
            time.strftime("%Y%m%d-%H%M%S") + "." + 'pcap')
Exemplo n.º 22
0
    def get_test_parameters(self):
        # Set Some test defaults
        self._gps_scenario = self.param.get('gps_scenario', "")
        self._gps_tx_power = self.param.get('gps_tx_power', -68.0)
        self._gps_lock_timeout_sec = self.param.get('gps_lock_timeout_sec',
                                                    600)
        self._capture_frames = self.param.get('capture_frames', 0)
        self._sniffer_test = self.param.get('sniffer_test', 0)

        self._testParams = self.param.get('params', None)
        if self._testParams is None:
            raise globals.Error(
                "uut index and interface input is missing or currpted, usage : params = tParam( tx = (0,1), rx = (1,1), proto_id = 0, frames = 1000, frame_rate_hz = 50, tx_data_len = 100, tx_data_val = 'ab', tx_power = -5 )"
            )

        g = list()
        i = 0
        for t_param in self._testParams:
            print "Tparam {} : {}".format(i, t_param.__dict__)

            if 'tx' in vars(t_param):
                g.append(t_param.tx[0])
            if 'rx' in vars(t_param):
                g.append(t_param.rx[0])

            i += 1

        self._uut_list = set(g)
        self._uut = {}
Exemplo n.º 23
0
    def start_dut_sniffer(self, cli_interface, idx, type):
            
        self.dut_host_sniffer = traffic_generator.TGHostSniffer(idx)
        if self.dut_embd_sniffer is None :
            self.dut_embd_sniffer = traffic_generator.Panagea4SnifferLinkEmbedded(cli_interface)            
        #add to sniffer list
                            
        sniffer_port = BASE_HOST_PORT + ( (idx - 1) * 10 ) 

        #save for sniffer close...
        self.sniffers_ports.append(sniffer_port)
        self.sniffer_file.append(os.path.join( common.SNIFFER_DRIVE ,  self._testMethodName + "_" + "dut" + str(idx) + "_" + type + "_" + time.strftime("%Y%m%d-%H%M%S") + "." + 'pcap'))  
        try:
            time.sleep(2)
            #use the last appended sniffer  file...
            self.dut_host_sniffer.start( if_idx = idx , port = sniffer_port, capture_file = self.sniffer_file[len(self.sniffer_file) - 1] )
            time.sleep(1)
            if bool(self.v2x_cli_sniffer_if0):
                self.dut_embd_sniffer.start( if_idx = idx -1 , server_ip = self.sniffer_agent_ip_addr , server_port = sniffer_port, sniffer_type = type)
            time.sleep(1)
            if bool(self.v2x_cli_sniffer_if1):
                self.dut_embd_sniffer.start( if_idx = idx , server_ip = self.sniffer_agent_ip_addr  , server_port = sniffer_port, sniffer_type = type)                   
        except  Exception as e:
            raise globals.Error("sniffer start error")
            pass        
Exemplo n.º 24
0
    def test_start(self):
        self.log = logging.getLogger(__name__)
        # unit configuration 
        print >> self.result._original_stdout, "Starting : {}".format( self._testMethodName )
        # Get position data that described in table below via NAV API.
        self.get_test_parameters()
        # Verify uut input exists and active
        self._uut_id = self.param.get('uut_id', None )
        if self._uut_id is None:
            raise globals.Error("uut index and interface input is missing or currpted, usage : uut_id=(0,1)")

        # Verify uut idx exits
        try:
            self.uut = globals.setup.units.unit(self._uut_id[0])
        except KeyError as e:
            raise globals.Error("uut index and interface input is missing or currpted, usage : uut_id=(0,1)")

        self.uut_channel = self._uut_id[1]


        self._tg_id = self.param.get('tg_id', None)
        if self._tg_id is None:
            raise globals.Error("uut index and interface input is missing or currpted, usage : tg_id=(0,1)")

        # Verify uut idx exits
        try:
            self.tg = globals.setup.units.unit(self._tg_id[0])
        except KeyError as e:
            raise globals.Error("uut index and interface input is missing or currpted, usage : tg_id=(0,1)")

        
        

        self.instruments_initilization()
        self.unit_configuration()
        self.main()

        #self.debug_override()

        if len(self._cpu_load_info):
            for uut_id in self._cpu_load_info:
                self.uut.set_cpu_load( 0 )

        self.analyze_results()

        self.print_results()
        print >> self.result._original_stdout, "test, {} completed".format( self._testMethodName )
Exemplo n.º 25
0
 def frequency_set(self, rf_if=None, freq=None):
     cmd = "%s freq set" % self._name
     cmd += (" -rf_if %s" % rf_if) if not rf_if is None else ""
     cmd += (" -freq %s" % freq) if not freq is None else ""
     self._if.send_command(cmd)
     data = self._if.read_until_prompt(timeout=3)
     if 'ERROR' in data:
         raise globals.Error("ERROR in frequency set")
Exemplo n.º 26
0
 def set_output(self, type, destination):
     """ Sets output direction """
     self.type = type
     if type == 'file':
         self.output = open(destination, 'w')
     elif type == "handler":
         self.output = destination
     elif type == 'stdout':
         self.output = sys.stdout
     else:
         raise globals.Error("Type is not known")
Exemplo n.º 27
0
def cpu_load(self, uut_idx, cpu_load_level=50, timeout=-1):
    try:
        cpu_uut = globals.setup.units.unit(uut_idx)
    except KeyError as e:
        raise globals.Error(
            "uut index and interface input is missing or currpted, usage : _uut_id_tx=(0,1)"
        )

    cli_name = 'cpu_load'
    cpu_uut.create_qa_cli(cli_name)
    # Open general session
    cpu_uut.qa_cli(cli_name).cpu_load(cpu_load_level, timeout)
Exemplo n.º 28
0
    def unit_configuration(self):
        super(TC_CAN_LOAD, self).unit_configuration()

        self.can_cli_rx = self.uut.create_qa_cli("can_cli_rx",
                                                 target_cpu=self.target_cpu)
        ret = self.can_cli_rx.can.socket_create(self.uut_can_if[0].device_id,
                                                {})
        if "ERROR :" in ret:
            raise globals.Error(
                "Can socket create received error {}".format(ret))

        self.can_cli_rx.can.reset_counters()
Exemplo n.º 29
0
    def initilization(self):
        # Initilize GPS
        self.gps_sim = None
        if self._gps_scenario == None:
            globals.Error(
                "Gps scenario not exists, please make sure to pass parameters")

        self.log.info("Getting GPS simulator in config")
        if globals.setup.instruments.gps_simulator is None:
            raise globals.Error(
                "GPS simulator is not initilize, please check your configuration"
            )
            #pass
        else:
            # Get pointer to object
            self.gps_sim = globals.setup.instruments.gps_simulator

            # set general tx power
            self.gps_sim.tx_power(self._gps_tx_power)
            #load scenario
            self.gps_sim.load(self._gps_scenario)
Exemplo n.º 30
0
    def parse_file( self, pdml_file_name, pckt_handler ):
         
        # pdml_filename = self.pcap_file.split('.')[0] + '.' + FILE_DEFAULT_FORMAT
        if  not(os.path.exists(pdml_file_name)):
            raise globals.Error("File not exists")

        file_hwd = open(pdml_file_name, "r")

        i = 0;
        
        #while file_hwd.readline() != '<?xml version="1.0"?>\n':
        while ('xml version' not in file_hwd.readline()) and (i < 20):
            i += 1
            
            
        if ( i >= 20 ):
            raise globals.Error("Start of PDML file not found")

        if ( i == 0 ): file_hwd.seek(0)

        self.pckt_handler = pckt_handler
        wiresharkXML.parse_fh(file_hwd, self._packet_analyzer)