コード例 #1
0
    def run_test(self):
        """
        Execute the test
        """

        # Call LabHspaBase Run function
        LabHspaBase.run_test(self)

        result = Global.SUCCESS
        measure_throughput_msg = "Measured throughput:"
        failure_throughput_msg = "Failure throughput:"

        # Start to search the trigger_msg in the logcat log
        self._device_logger = self._device.get_device_logger()
        self._start_ftp_trigger_msg = "status::SUCCESS - output::RECEIVED - function::startFtpXfer"
        self._device_logger.add_trigger_message(self._start_ftp_trigger_msg)

        self._logger.info("FTP transfer " + str(self._ftp_direction) +
                          " for " + str(self._ftp_filename) + "...")

        self._ftp_task_id = self._networking_api.start_ftp_xfer(
            self._ftp_direction, self._server_ip_address, self._username,
            self._password, self._ftp_filename, self._device.get_ftpdir_path())

        # Get the ftp start log msg and retrieve the OP code from the message
        self._op_code_message = self._device_logger.get_message_triggered_status(
            self._start_ftp_trigger_msg)
        self._device_logger.remove_trigger_message(self._start_ftp_trigger_msg)
        self._op_code = re.findall(r'ACS\_\d*', str(self._op_code_message))[0]

        self._logger.info(
            "Wait %d seconds for ensure that transfer is established" %
            self._wait_time_before_measure)
        time.sleep(self._wait_time_before_measure)

        self._voicecall_api.dial(self._phone_number)

        # Check call state "CONNECTED" before callSetupTimeout seconds
        self._ns_voice_call_3g.check_call_connected(self._call_setup_timeout)

        self._logger.info(
            "Wait %d seconds for ensure that transfer is stable" %
            self._wait_time_before_measure)
        time.sleep(self._wait_time_before_measure)

        data_throughput_dict = self._ns.get_data_throughput(
            self._measurement_duration, self._failure_throughput_dict.keys())

        # Check call is connected for CALL_DURATION seconds
        self._ns_voice_call_3g.is_voice_call_connected(self._call_duration)

        # Release the voice call
        self._ns_voice_call_3g.voice_call_network_release()

        self._timeout = self._xfer_timeout - self._wait_time_before_measure - self._call_duration

        self._device_logger.add_trigger_message(self._op_code)

        # Create success_msg to check ftp transfers finish success
        ftp_filename = os.path.split(self._ftp_filename)[1]
        success_msg = "Ftp %s of file %s finish success" % (
            self._ftp_direction, ftp_filename)

        # Wait to ftp imeout to verify ftp transfers finish success
        while self._timeout > 0:
            triggered_status = self._device_logger.get_message_triggered_status(
                self._op_code)
            # When the  success message  is in the message of ACS op code
            if success_msg in str(triggered_status):
                self._logger.info(str(triggered_status))
                break
            else:
                time.sleep(1)
                self._timeout -= 1
        else:
            self._device_logger.remove_trigger_message(self._op_code)
            self._networking_api.stop_ftp_xfer(self._ftp_task_id)
            self._error.Msg = "The FTP transfer doesn't finish in the timeout"
            raise DeviceException(DeviceException.TIMEOUT_REACHED,
                                  self._error.Msg)

        for data_type in data_throughput_dict.keys():

            if "Mbps" in data_throughput_dict[data_type][0]:
                # Convert to Mbps for result compare
                if float(data_throughput_dict[data_type][0]
                         [0:-4]) < self._failure_throughput_dict[data_type]:
                    result = Global.FAILURE
            elif "Kbps" in data_throughput_dict[data_type][0]:
                if float(data_throughput_dict[data_type][0][0:-4]
                         ) < self._failure_throughput_dict[data_type] * 1000:
                    result = Global.FAILURE
            elif "bps" in data_throughput_dict[data_type][0]:
                if float(
                        data_throughput_dict[data_type][0][0:-4]
                ) < self._failure_throughput_dict[data_type] * 1000 * 1000:
                    result = Global.FAILURE
            else:
                self._error.Msg = "unknown measure result unit: %s " % str(
                    data_throughput_dict[data_type][0])
                raise TestEquipmentException(
                    TestEquipmentException.PROHIBITIVE_MEASURE,
                    self._error.Msg)

            measure_throughput_msg = measure_throughput_msg + str(data_type)\
                + ":" + str(data_throughput_dict[data_type][0]) + " "
            failure_throughput_msg = failure_throughput_msg + str(data_type)\
                + ":" + str(self._failure_throughput_dict[data_type]) + "Mbps" + " "

        self._error.Msg = measure_throughput_msg + "- " + failure_throughput_msg

        return result, self._error.Msg
コード例 #2
0
 def run_test(self):
     (code, message) = LabHspaBase.run_test(self)
     if code == Global.SUCCESS:
         (code, message) = AnyUsbTether.run_test(self)
     return code, message