Example #1
0
    def generate_wifi_traffic(self, serial):
        if serial == self.go_serial:
            server_serial = self.cli_serial
            server_on_go = False
        else:
            server_serial = self.go_serial
            server_on_go = True

        # generate URL
        (URL, IP) = wifi_generic_steps.create_download_url(file_name = attrs["wifi_file_name"],
                                        file_size = attrs["file_size"],
                                        local_path = ".",
                                        protocol = "ftp",
                                        port = attrs["port_number_wifi"],
                                        serial = serial)()

        # start download
        wifi_generic_steps.download_file(URL, file_name = attrs["wifi_file_name"],
                                         file_size = attrs["file_size"],
                                         protocol = "ftp",
                                         serial = serial)()

        #check download integrity
        wifi_generic_steps.check_file_integrity(mode = attrs["compare_method"],
                            local_file = attrs["wifi_file_name"],
                            remote_file = dut_platform.download_path + attrs["wifi_file_name"],
                            serial = serial)()
Example #2
0
    def generate_p2p_traffic(self, serial):
        if serial == self.go_serial:
            server_serial = self.cli_serial
            download_serial = self.go_serial
            server_on_go = False
        else:
            server_serial = self.go_serial
            download_serial = self.cli_serial
            server_on_go = True

        # make sure no other ftpd processes are running
        wifi_generic_steps.p2p_kill_ftpd(serial = server_serial)()

        # start the server
        wifi_generic_steps.p2p_start_ftpd(port_number = attrs["p2p_port_number"],
                                          serial = server_serial)()


        # generate the URL and push download file on the DUT acting as ftp server
        (URL, device_IP) = wifi_generic_steps.p2p_create_download_url(file_name = attrs["p2p_file_name"],
                                        file_size = attrs["file_size"],
                                        device_path = attrs["root_dir"],
                                        protocol = "ftp",
                                        port_number = attrs["p2p_port_number"],
                                        server_on_go = server_on_go,
                                        serial = server_serial,
                                        serial2 = download_serial)()

        # downloading the file
        wifi_generic_steps.download_file(URL, file_name = attrs["p2p_file_name"],
                                         file_size = attrs["file_size"],
                                         protocol = "ftp",
                                         serial = serial,
                                         serial2 = serial2)()

        #check download integrity
        wifi_generic_steps.check_file_integrity(mode = attrs["compare_method"],
                            local_file = attrs["p2p_file_name"],
                            remote_file = dut_platform.download_path + attrs["p2p_file_name"],
                            serial = serial)()
Example #3
0
                                         state='CONNECTED/CONNECTED',
                                         Security=conf_security,
                                         pairwise_cipher=pairwise_cipher)()

(URL, IP) = wifi_generic_steps.create_download_url(file_name,
                                                   file_size,
                                                   local_path=".",
                                                   protocol=protocol,
                                                   port=port_number,
                                                   serial=serial)()

# start download
wifi_steps.download_file(URL,
                         file_name,
                         file_size,
                         protocol,
                         serial=serial,
                         option=option,
                         interface5ghz=interface5ghz,
                         ap_name=ddwrt_ap_name,
                         negativetest=negativetest)()

#check download integrity
wifi_generic_steps.check_file_integrity(mode=compare_method,
                                        local_file=file_name,
                                        remote_file=platform.download_path +
                                        file_name,
                                        serial=serial)()

##### test end #####
Example #4
0
        serial=serial,
        view_to_find={
            "textContains": "OK",
            "enabled": True
        },
        view_to_check={"textContains": file_name + device + '.bin'})()

    wifi_generic_steps.download_file(url=URL,
                                     file_name=file_name + device + '.bin',
                                     protocol='ftp',
                                     file_size=file_size,
                                     serial=device)()

    wifi_generic_steps.check_file_integrity(
        mode='md5',
        local_file=pwd + '/' + file_name + device + '.bin',
        remote_file='/sdcard/Download/' + file_name + device + '.bin',
        serial=serial)()
except Exception as e:
    print e.message
finally:
    #teardown

    # adb_steps.uninstall_apk(serial = device, apk_path = ftp_server_apk)()
    # adb_steps.uninstall_apk(serial= serial, apk_path = ftp_client_apk)()

    #Open FTP server app
    ui_steps.open_app_from_allapps(serial=device,
                                   view_to_find={"text": "Ftp server"})()

    ui_steps.click_button_common(serial=device,
Example #5
0
def ftp_download_file(serial, condition, event, mode='bg', security='none',
                      ddwrt_ap_name='ddwrt', ddwrt_ap_pass='******',
                      encryption=None, file_name='generated.bin',
                      file_size=102400, protocol='ftp', port_number='20211',
                      dut_security=None, conf_security='NONE',
                      compare_method='md5', adb_server_port='5037',
                      iteration=1,
                      q=None):
    result = []
    try:
        platform = statics.Device(serial=serial)

        adb_steps.connect_device(serial=serial, port=adb_server_port)()
        for _ in range(0, iteration):
            if iteration > 1:
                log.info("Ftp download: Iteration #{}".format(_ + 1))
            if priority == 'wifi' and _ == 0:
                # print 'wifi 1st event wait'
                # print e.is_set()
                event.wait(CONDITION_EVENT_TIMEOUT)
                event.clear()
            elif not priority == 'toggle':
                # print 'wifi 1st event set'
                event.set()

            if _ == 0:
                with condition:
                    if priority == 'bt' and _ == 0:
                        condition.wait(CONDITION_EVENT_TIMEOUT)
                    if not connect_to_ap(serial, condition):
                        raise Exception("Not able to connect to AP")

                    # generate URL
                    (URL, IP) = wifi_generic_steps.create_download_url(
                        file_name, file_size, local_path=".", protocol=protocol,
                        port=port_number, serial=serial)()
                    if priority == 'wifi' and _ == 0:
                        # print 'Notify wifi process'
                        condition.notify()

            # print 'Notified after creating url'
            if priority == 'wifi' and _ == 0:
                # print e.is_set()
                # print 'wifi 2nd event wait'
                event.wait(CONDITION_EVENT_TIMEOUT)
            elif not priority == 'toggle':
                # print 'wifi 2nd event set'
                event.set()

            wifi_instance = None
            with condition:
                if priority == 'bt' and _ == 0:
                    condition.wait(CONDITION_EVENT_TIMEOUT)
                # start download
                wifi_instance = wifi_generic_steps.download_file(URL, file_name,
                                                                 file_size,
                                                                 protocol,
                                                                 serial=serial,
                                                                 check_file_downloaded=False)
                wifi_instance()

                if priority == 'wifi' and _ == 0:
                    condition.notify()

                # this condition will notify the 'toggle_bt' to proceed to
                # toggle state
                if priority == 'toggle':
                    event.set()

            # This notify bt operation to start validating receiving file as
            #  this should not happen parallel to wifi download as both
            # rely on UI
            if initiator == "dev" and priority == "bt" and _ == 0:
                event.set()

            wifi_instance.check_file_downloaded = True
            if wifi_instance.check_condition():
                # check download integrity
                if wifi_generic_steps.check_file_integrity(mode=compare_method,
                                                           local_file=file_name,
                                                           serial=serial,
                                                           remote_file=platform.download_path + file_name)():
                    result.append('Pass')
                    log.info("Download file is completed")
                else:
                    raise Exception('File integrity check failed')
            else:
                raise Exception("Error during FTP Download")
            #q.put(['WifiDownloadFile', True])
    except Exception:
        log.error(Exception.message)
        log.error(traceback.format_exc())
        result.append('Fail')
    except:
        log.error('FtpDownloadFile: Unexpected Error')
        log.error(traceback.format_exc())
        result.append('Fail')

    if False in result:
        q.put(['FtpDownloadFile', 'Fail', result])
    else:
        q.put(['FtpDownloadFile', 'Pass'])

    log.info("Wifi Ftp download completed")