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)
def _stop_tcp_dump(self, ad): """ Stop tcpdump and pull it to the test run logs Args: 1. ad: dut to pull tcpdump from """ return stop_tcpdump(ad, self.tcpdump_pid, self.test_name)
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 teardown_test(self): for ad in self.hs_enabled: try: wutils.stop_wifi_tethering(ad) except Exception as e: self.log.warn("Failed to stop wifi tethering: %s" % e) self.hs_enabled = [] for i in range(len(self.android_devices)): ad = self.android_devices[i] stop_tcpdump(ad, self.tcpdumps[i], self.test_name) wutils.reset_wifi(ad) sub_id = str(ad.droid.telephonyGetSubscriberId()) ad.droid.connectivityFactoryResetNetworkPolicies(sub_id) ad.droid.telephonyToggleDataConnection(True) ad.droid.wakeLockRelease() ad.droid.goToSleepNow() self.tcpdumps = []
def teardown_test(self): if self.tcpdump_pid: stop_tcpdump(self.dut, self.tcpdump_pid, self.test_name) self.tcpdump_pid = None if self.gce_tcpdump_pid: host = self.remote_server if "_on_data_" in self.test_name: host = self.remote_server_2 nutils.stop_tcpdump_gce_server( self.dut, self.gce_tcpdump_pid, None, host) self.gce_tcpdump_pid = None for ska in self.socket_keepalives: cutils.stop_socket_keepalive(self.dut, ska) self.socket_keepalives = [] for sock in self.tcp_sockets: sutils.shutdown_socket(self.dut, sock) self.tcp_sockets = [] if self.udp_encap: self.dut.droid.ipSecCloseUdpEncapsulationSocket(self.udp_encap) self.udp_encap = None wutils.wifi_toggle_state(self.dut, True)
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)
def teardown_test(self): stop_tcpdump(self.dut, self.tcpdump_pid, self.test_name) self.dut.droid.wakeLockRelease() self.dut.droid.goToSleepNow() self.dut.droid.wifiStopTrackingStateChange()
def teardown_test(self): if self.tcpdump_pid: nutils.stop_tcpdump(self.dut, self.tcpdump_pid, self.test_name) self.tcpdump_pid = None
def teardown_test(self): stop_tcpdump(self.dut_a, self.tcpdump_pid_a, self.test_name) stop_tcpdump(self.dut_b, self.tcpdump_pid_b, self.test_name)
def teardown_test(self): if self.hotspot_device.droid.wifiIsApEnabled(): wutils.stop_wifi_tethering(self.hotspot_device) for ad, pid in zip(self.android_devices, self.tcpdump_pid): nutils.stop_tcpdump(ad, pid, self.test_name) self.tcpdump_pid = []
def teardown_test(self): if 'RTT' not in self.test_name: stop_tcpdump(self.dut, self.tcpdump_pid, self.test_name)