コード例 #1
0
    def _test_proxy(self):
        """ Test pac piroxy and manual proxy settings

        Steps:
            1. Start tcpdump
            2. Run http requests
            3. Stop tcpdump
            4. Verify the packets from tcpdump have valid queries
        """

        # start tcpdump on the device
        self.tcpdump_pid = start_tcpdump(self.dut, self.test_name)

        # verify http requests
        self._verify_http_request(self.dut)

        # stop tcpdump on the device
        pcap_file = stop_tcpdump(self.dut, self.tcpdump_pid, self.test_name)

        # verify proxy server
        result = self._verify_proxy_server(pcap_file, True, self.bypass_host)
        asserts.assert_true(result, "Proxy failed for %s" % self.bypass_host)
        result = self._verify_proxy_server(pcap_file, False,
                                           self.non_bypass_host)
        asserts.assert_true(result,
                            "Proxy failed for %s" % self.non_bypass_host)
 def setup_test(self):
     self.dut.droid.wifiStartTrackingStateChange()
     self.dut.droid.wakeLockAcquireBright()
     self.dut.droid.wakeUpNow()
     wutils.reset_wifi(self.dut)
     self.dut.ed.clear_all_events()
     self.tcpdump_pid = start_tcpdump(self.dut, self.test_name)
コード例 #3
0
    def _start_tcp_dump(self, ad):
        """ Start tcpdump on the give dut

        Args:
            1. ad: dut to run tcpdump on
        """
        self.tcpdump_pid = start_tcpdump(ad, self.test_name)
コード例 #4
0
    def catch_log(self):
        """Capture logs include bugreport, ANR, mount,ps,vendor,tcpdump"""

        self.log.info("Get log for regular capture.")
        file_name = time.strftime("%Y-%m-%d_%H:%M:%S", time.localtime())
        current_path = os.path.join(self.dut.log_path, file_name)
        os.makedirs(current_path, exist_ok=True)
        serial_number = self.dut.serial

        try:
            out = self.dut.adb.shell("bugreportz", timeout=240)
            if not out.startswith("OK"):
                raise AndroidDeviceError('Failed to take bugreport on %s: %s' %
                                         (serial_number, out),
                                         serial=serial_number)
            br_out_path = out.split(':')[1].strip().split()[0]
            self.dut.adb.pull("%s %s" % (br_out_path, self.dut.log_path))
            self.dut.adb.pull("/data/anr {}".format(current_path), timeout=600)
            self.dut.adb._exec_adb_cmd(
                "shell",
                "mount > {}".format(os.path.join(current_path, "mount.txt")))
            self.dut.adb._exec_adb_cmd(
                "shell", "ps > {}".format(os.path.join(current_path,
                                                       "ps.txt")))
            self.dut.adb.pull("/data/misc/logd {}".format(current_path))
            self.dut.adb.pull("/data/vendor {}".format(current_path),
                              timeout=800)
            stop_tcpdump(self.dut,
                         self.tcpdump_pid,
                         file_name,
                         adb_pull_timeout=600)
            self.tcpdump_pid = start_tcpdump(self.dut, file_name)
        except TimeoutError as e:
            self.log.error(e)
コード例 #5
0
    def setup_test(self):
        asserts.skip_if(
            self.test_name.startswith("test_tcp") and \
                self.kernel_version < SUPPORTED_KERNEL_VERSION,
            "TCP Keepalive is not supported on kernel %s. Need at least %s" %
            (self.kernel_version, SUPPORTED_KERNEL_VERSION))

        if self.test_name.endswith("_lte"):
            wutils.wifi_toggle_state(self.dut, False)
        time.sleep(3)
        link_prop = self.dut.droid.connectivityGetActiveLinkProperties()
        iface = link_prop["InterfaceName"]
        self.log.info("Iface: %s" % iface)
        self.dut_ip = self.dut.droid.connectivityGetIPv4Addresses(iface)[0]
        self.tcpdump_pid = start_tcpdump(self.dut, self.test_name)
コード例 #6
0
    def test_multipath_preference_data_download(self):
        """ Verify multipath preference when large file is downloaded

        Steps:
            1. DUT has WiFi and LTE data
            2. WiFi is active network
            3. Download large file over cell network
            4. Verify multipath preference on cell network is 0
        """
        # set vars
        ad = self.android_devices[1]
        self.dut = ad
        self._clear_netstats(ad)
        utils.sync_device_time(ad)
        self.tcpdump_pid = nutils.start_tcpdump(ad, self.test_name)

        cell_network = ad.droid.connectivityGetActiveNetwork()
        self.log.info("cell network %s" % cell_network)
        wutils.wifi_connect(ad, self.wifi_network)
        wifi_network = ad.droid.connectivityGetActiveNetwork()
        self.log.info("wifi network %s" % wifi_network)

        # verify multipath preference for wifi and cell networks
        self._verify_multipath_preferences(ad, RELIABLE, RELIABLE,
                                           wifi_network, cell_network)

        # download file with cell network
        ad.droid.connectivityNetworkOpenConnection(cell_network,
                                                   self.download_file)
        file_folder, file_name = _generate_file_directory_and_file_name(
            self.download_file, DOWNLOAD_PATH)
        file_path = os.path.join(file_folder, file_name)
        self.log.info("File path: %s" % file_path)
        if _check_file_existance(ad, file_path):
            self.log.info("File exists. Removing file %s" % file_name)
            ad.adb.shell("rm -rf %s%s" % (DOWNLOAD_PATH, file_name))

        #  verify multipath preference values
        curr_time = time.time()
        while time.time() < curr_time + TIMEOUT:
            try:
                self._verify_multipath_preferences(ad, RELIABLE, NONE,
                                                   wifi_network, cell_network)
                return True
            except signals.TestFailure as e:
                self.log.debug("%s" % e)
            time.sleep(1)
        return False
    def test_IPv6_RA_with_RTT(self):
        """Test if the device filters IPv6 RA packets with different re-trans time

        Steps:
          1. Get the current RA count
          2. Send 400 packets with different re-trans time
          3. Verify that RA count increased by 400
          4. Verify internet connectivity
        """
        pkt_num = 400
        rtt_list = random.sample(range(10, 10000), pkt_num)
        self.log.info("RTT List: %s" % rtt_list)

        # get mac address of the dut
        ap = self.access_points[0]
        wutils.connect_to_wifi_network(self.dut, self.wpapsk_5g)
        mac_addr = self.dut.droid.wifiGetConnectionInfo()['mac_address']
        self.log.info("mac_addr %s" % mac_addr)
        time.sleep(30)  # wait 30 sec before sending RAs

        # get the current ra count
        ra_count = self._get_icmp6intype134()

        # start tcpdump on the device
        tcpdump_pid = start_tcpdump(self.dut, self.test_name)

        # send RA with differnt re-trans time
        for rtt in rtt_list:
            ap.send_ra('wlan1', mac_addr, 0, 1, rtt=rtt)

        # stop tcpdump and pull file
        time.sleep(60)
        pcap_file = stop_tcpdump(self.dut, tcpdump_pid, self.test_name)

        # get the new RA count
        new_ra_count = self._get_icmp6intype134()
        asserts.assert_true(new_ra_count >= ra_count + pkt_num,
                            "Device did not accept all RAs")

        # verify the RA pkts RTT match
        tcpdump_rtt_list = self._get_rtt_list_from_tcpdump(pcap_file)
        asserts.assert_true(
            set(rtt_list).issubset(set(tcpdump_rtt_list)),
            "RA packets didn't match with tcpdump")

        # verify if internet connectivity works after sending RA packets
        wutils.validate_connection(self.dut)
コード例 #8
0
    def test_multipath_preference_low_data_limit(self):
        """ Verify multipath preference when mobile data limit is low

        Steps:
            1. DUT has WiFi and LTE data
            2. Set mobile data usage limit to low value
            3. Verify that multipath preference is 0 for cell network
        """
        # set vars
        ad = self.android_devices[0]
        self.dut = ad
        self._clear_netstats(ad)
        utils.sync_device_time(ad)
        self.tcpdump_pid = nutils.start_tcpdump(ad, self.test_name)

        sub_id = str(ad.droid.telephonyGetSubscriberId())
        cell_network = ad.droid.connectivityGetActiveNetwork()
        self.log.info("cell network %s" % cell_network)
        wutils.wifi_connect(ad, self.wifi_network)
        wifi_network = ad.droid.connectivityGetActiveNetwork()
        self.log.info("wifi network %s" % wifi_network)

        # verify mulipath preference values
        self._verify_multipath_preferences(ad, RELIABLE, RELIABLE,
                                           wifi_network, cell_network)

        # set low data limit on mobile data
        total_pre = self._get_total_data_usage_for_device(ad, 0, sub_id)
        self.log.info("Setting data usage limit to %sMB" % (total_pre + 5))
        ad.droid.connectivitySetDataUsageLimit(
            sub_id, int((total_pre + 5) * 1000.0 * 1000.0))
        self.log.info("Setting data warning limit to %sMB" % (total_pre + 5))
        ad.droid.connectivitySetDataWarningLimit(
            sub_id, int((total_pre + 5) * 1000.0 * 1000.0))

        # verify multipath preference values
        curr_time = time.time()
        while time.time() < curr_time + TIMEOUT:
            try:
                self._verify_multipath_preferences(ad, RELIABLE, NONE,
                                                   wifi_network, cell_network)
                return True
            except signals.TestFailure as e:
                self.log.debug("%s" % e)
            time.sleep(1)
        return False
コード例 #9
0
    def browsing_test(self, stress_hour_time):
        """Continue stress http_request and capture log if any fail

        Args:
            stress_hour_time: hour of time to stress http_request
        """
        t = threading.Thread(target=self.simulate_roaming)
        t.start()
        start_time = time.time()
        http_request_failed = False
        while time.time() < start_time + stress_hour_time * 3600:
            if not self.http_request():
                http_request_failed = True
        self.simulation_thread_running = False
        t.join()
        if http_request_failed:
            self.catch_log()
        else:
            stop_standing_subprocess(self.tcpdump_pid)
            file_name = time.strftime("%Y-%m-%d_%H:%M:%S", time.localtime())
            self.tcpdump_pid = start_tcpdump(self.dut, file_name)
コード例 #10
0
 def setup_test(self):
     self.tcpdump_pid_a = start_tcpdump(self.dut_a, self.test_name)
     self.tcpdump_pid_b = start_tcpdump(self.dut_b, self.test_name)
コード例 #11
0
 def setup_test(self):
     self.dut.droid.wakeLockAcquireBright()
     self.dut.droid.wakeUpNow()
     self.dut.unlock_screen()
     self.tcpdump_pid = start_tcpdump(self.dut, self.test_name)
コード例 #12
0
 def setup_test(self):
     for ad in self.android_devices:
         self.tcpdump_pid.append(nutils.start_tcpdump(ad, self.test_name))
 def setup_test(self):
     if 'RTT' not in self.test_name:
         self.tcpdump_pid = start_tcpdump(self.dut, self.test_name)
 def setup_test(self):
     for ad in self.android_devices:
         self.tcpdumps.append(start_tcpdump(ad, self.test_name))
         ad.droid.wakeLockAcquireBright()
         ad.droid.wakeUpNow()