def test_passpoint_connect_config_store_with_config_passpoint_ttls_gtc( self): asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), "Passpoint is not supported on %s" % self.dut.model) config = dict(self.config_passpoint_ttls) config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value self.eap_connect_toggle_wifi(config, self.dut)
def test_dpp_as_initiator_configurator_with_psk_5G_broadcast(self): asserts.skip_if(not self.dut.droid.wifiIs5GHzBandSupported() or not self.helper_dev.droid.wifiIs5GHzBandSupported(), "5G not supported on at least on test device") self.start_dpp_as_initiator_configurator( security=self.DPP_TEST_SECURITY_PSK, responder_chan="126/149", responder_freq=5745, use_mac=False)
def passpoint_connect_negative_with_config_passpoint_ttls_gtc(self): asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), "Passpoint is not supported on %s" % self.dut.model) config = dict(self.config_passpoint_ttls) config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value config = self.gen_negative_passpoint_configs(config) self.eap_negative_connect_logic(config, self.dut)
def setup_test(self): required_params = ("lci_reference", "lcr_reference", "rtt_reference_distance_mm", "stress_test_min_iteration_count", "stress_test_target_run_time_sec") self.unpack_userparams(required_params) # can be moved to JSON config file self.rtt_reference_distance_margin_mm = 2000 self.rtt_max_failure_rate_two_sided_rtt_percentage = 20 self.rtt_max_failure_rate_one_sided_rtt_percentage = 50 self.rtt_max_margin_exceeded_rate_two_sided_rtt_percentage = 10 self.rtt_max_margin_exceeded_rate_one_sided_rtt_percentage = 50 self.rtt_min_expected_rssi_dbm = -100 for ad in self.android_devices: utils.set_location_service(ad, True) asserts.skip_if( not ad.droid.doesDeviceSupportWifiRttFeature(), "Device under test does not support Wi-Fi RTT - skipping test") wutils.wifi_toggle_state(ad, True) rtt_avail = ad.droid.wifiIsRttAvailable() if not rtt_avail: self.log.info('RTT not available. Waiting ...') rutils.wait_for_event(ad, rconsts.BROADCAST_WIFI_RTT_AVAILABLE) ad.ed.clear_all_events() rutils.config_privilege_override(ad, False) wutils.set_wifi_country_code(ad, wutils.WifiEnums.CountryCode.US) ad.rtt_capabilities = rutils.get_rtt_capabilities(ad)
def test_passpoint_connect_negative(self): """Test connecting to enterprise networks. Procedures: For each enterprise wifi network 1. Connect to the network with invalid credentials. Expect: Fail to establish connection. """ asserts.skip_if( not self.dut.droid.wifiIsPasspointSupported(), "Passpoint is not supported on device %s" % self.dut.model) neg_passpoint_configs = self.gen_negative_passpoint_configs() self.log.info("Testing %d different configs.", len(neg_passpoint_configs)) random.shuffle(neg_passpoint_configs) def name_gen(config, ad): name = self.gen_passpoint_test_name(config, ad) name += "-with_wrong-{}".format(config["invalid_field"]) return name failed = self.run_generated_testcases(self.eap_negative_connect_logic, neg_passpoint_configs, args=(self.dut, ), name_func=name_gen) asserts.assert_equal( len(failed), 0, "The following configs failed negative passpoint connect test: %s" % pprint.pformat(failed))
def test_passpoint_connect_config_store(self): """Test connecting to enterprise networks of different authentication types with passpoint support after wifi toggle. The authentication types tested are: EAP-TLS EAP-TTLS with MSCHAPV2 as phase2. Procedures: For each enterprise wifi network 1. Connect to the network. 2. Send a GET request to a website and check response. 3. Toggle wifi. 4. Ensure that the device reconnects to the same network. Expect: Successful connection and Internet access through the enterprise networks with passpoint support. """ asserts.skip_if( not self.dut.droid.wifiIsPasspointSupported(), "Passpoint is not supported on device %s" % self.dut.model) passpoint_configs = self.gen_passpoint_configs() self.log.info("Testing %d different configs.", len(passpoint_configs)) random.shuffle(passpoint_configs) failed = self.run_generated_testcases( self.eap_connect_toggle_wifi, passpoint_configs, args=(self.dut, ), name_func=self.gen_passpoint_test_name_for_config_store) asserts.assert_equal( len(failed), 0, "The following configs failed passpoint connect test: %s" % pprint.pformat(failed))
def setup_test(self): required_params = ("aware_default_power_mode", ) self.unpack_userparams(required_params) for ad in self.android_devices: asserts.skip_if( not ad.droid.doesDeviceSupportWifiAwareFeature(), "Device under test does not support Wi-Fi Aware - skipping test" ) wutils.wifi_toggle_state(ad, True) ad.droid.wifiP2pClose() utils.set_location_service(ad, True) aware_avail = ad.droid.wifiIsAwareAvailable() if not aware_avail: self.log.info('Aware not available. Waiting ...') autils.wait_for_event(ad, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) ad.ed.clear_all_events() ad.aware_capabilities = autils.get_aware_capabilities(ad) self.reset_device_parameters(ad) self.reset_device_statistics(ad) self.set_power_mode_parameters(ad) wutils.set_wifi_country_code(ad, wutils.WifiEnums.CountryCode.US) autils.configure_ndp_allow_any_override(ad, True) # set randomization interval to 0 (disable) to reduce likelihood of # interference in tests autils.configure_mac_random_interval(ad, 0)
def passpoint_connect_with_config_passpoint_ttls_mschapv2(self): asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), "Passpoint is not supported on %s" % self.dut.model) config = dict(self.config_passpoint_ttls) config[ WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value wutils.wifi_connect(self.dut, config)
def run_test_rtt_non_80211mc_supporting_aps(self, dut, accuracy_evaluation=False): """Scan for APs and perform RTT on non-IEEE 802.11mc supporting APs Args: dut: test device accuracy_evaluation: False - only evaluate success rate. True - evaluate both success rate and accuracy default is False. """ asserts.skip_if( not dut.rtt_capabilities[rconsts.CAP_RTT_ONE_SIDED_SUPPORTED], "Device does not support one-sided RTT") non_rtt_aps = rutils.select_best_scan_results( rutils.scan_with_rtt_support_constraint(dut, False), select_count=1) dut.log.debug("Visible non-IEEE 802.11mc APs=%s", non_rtt_aps) asserts.assert_true(len(non_rtt_aps) > 0, "Need at least one AP!") events = rutils.run_ranging(dut, non_rtt_aps, self.NUM_ITER, self.TIME_BETWEEN_ITERATIONS) stats = rutils.analyze_results(events, self.rtt_reference_distance_mm, self.rtt_reference_distance_margin_mm, self.rtt_min_expected_rssi_dbm, [], []) dut.log.debug("Stats=%s", stats) for bssid, stat in stats.items(): asserts.assert_true(stat['num_no_results'] == 0, "Missing (timed-out) results", extras=stats) asserts.assert_false(stat['any_lci_mismatch'], "LCI mismatch", extras=stats) asserts.assert_false(stat['any_lcr_mismatch'], "LCR mismatch", extras=stats) asserts.assert_equal(stat['num_invalid_rssi'], 0, "Invalid RSSI", extras=stats) asserts.assert_true( stat['num_failures'] <= self.rtt_max_failure_rate_one_sided_rtt_percentage * stat['num_results'] / 100, "Failure rate is too high", extras=stats) if accuracy_evaluation: asserts.assert_true( stat['num_range_out_of_margin'] <= self.rtt_max_margin_exceeded_rate_one_sided_rtt_percentage * stat['num_success_results'] / 100, "Results exceeding error margin rate is too high", extras=stats) asserts.explicit_pass("RTT test done", extras=stats)
def test_softap_5G_two_clients_ping_each_other(self): """Test for 5G hotspot with 2 clients 1. Turn on 5G hotspot 2. Two clients connect to the hotspot 3. Two clients ping each other """ asserts.skip_if( len(self.android_devices) < 3, "No extra android devices. Skip test") self.validate_full_tether_startup(WIFI_CONFIG_APBAND_5G, test_clients=True)
def test_wifi_tethering_wifi_data_usage_downlink_ipv4(self): """Verify wifi data usage with tethered device over IPv4.""" asserts.skip_if( self.android_devices[0].model not in self.dbs_supported_models, "Device %s does not support dual interfaces." % self.android_devices[0].model) self._test_data_usage_downlink(self.android_devices[0], self.android_devices[1], self.download_file_ipv4, cconst.TYPE_WIFI, True, True, False)
def test_soft_ap_stress_from_config(self): """ Runs tests from ACTS config file. Example Config "soft_ap_test_params" : { "soft_ap_tests": [ { "ssid": "test_network", "security_type": "wpa2", "password": "******", "connectivity_mode": "local_only", "operating_band": "only_2_4_ghz", "reconnect_loops": 10 } ] } """ tests = self.user_params.get('soft_ap_test_params', {}).get('soft_ap_tests') asserts.skip_if(not tests, 'No soft ap tests in the ACTS config.') test_settings_list = [] for config_settings in self.user_params['soft_ap_test_params'][ 'soft_ap_tests']: ssid = config_settings.get( 'ssid', utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G)) security_type = config_settings.get('security_type', SECURITY_OPEN) password = config_settings.get('password', '') connectivity_mode = config_settings.get('connectivity_mode', CONNECTIVITY_MODE_LOCAL) operating_band = config_settings.get('operating_band', OPERATING_BAND_ANY) test_type = config_settings.get('test_type', 'associate_and_pass_traffic') reconnect_loops = config_settings.get('reconnect_loops', 1) test_settings = { 'client': self.primary_client, 'ssid': ssid, 'security_type': security_type, 'password': password, 'connectivity_mode': connectivity_mode, 'operating_band': operating_band, 'test_type': test_type, 'reconnect_loops': reconnect_loops } test_settings_list.append(test_settings) self.run_generated_testcases(self.run_config_stress_test, test_settings_list, name_func=generate_test_name)
def test_wifi_tethering_2ghz_traffic_between_2tethered_devices(self): """ Steps: 1. Start wifi hotspot with 2G band 2. Connect 2 tethered devices to the hotspot device 3. Ping interfaces between the tethered devices """ asserts.skip_if(not hasattr(self, 'arduino_wifi_dongles'), "No wifi dongles connected. Skipping test") wutils.toggle_wifi_off_and_on(self.hotspot_device) self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) self._test_traffic_between_two_tethered_devices( self.tethered_devices[0], self.arduino_wifi_dongles[0]) wutils.stop_wifi_tethering(self.hotspot_device)
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)
def test_private_dns_mode_off_tmo_carrier(self): """ Verify private dns mode off on TMO network Steps: 1. Set private dns to off mode 2. Connect to wifi network. TMO supports DNS/TLS 3. Run HTTP ping to amazon.com, facebook.com, netflix.com 4. Verify ping works to differnt hostnames 5. Verify that all queries go to port 53 """ carrier = get_operator_name(self.log, self.dut) asserts.skip_if(carrier != "tmo", "Carrier is not T-mobile") self._test_private_dns_mode(self.dut, None, cconst.PRIVATE_DNS_MODE_OFF, False)
def test_full_tether_startup_2G_multiple_clients(self): """Test full startup of wifi tethering in 2G band, connect clients to softAp and send traffic between them. 1. Report current state. 2. Switch to AP mode. 3. verify SoftAP active. 4. Connect clients to softAp. 5. Send and recv UDP traffic between them. 6. Shutdown wifi tethering. 7. verify back to previous mode. """ asserts.skip_if(not hasattr(self, 'arduino_wifi_dongles'), "No wifi dongles connected. Skipping test") self.validate_full_tether_startup(WIFI_CONFIG_APBAND_2G, test_clients=True)
def test_private_dns_mode_opportunistic_vzw_carrier(self): """ Verify private dns mode opportunistic on VZW network Steps: 1. Set private dns mode opportunistic 2. Connect to wifi network. VZW doesn't support DNS/TLS 3. Run HTTP ping to amazon.com, facebook.com, netflix.com 4. Verify ping works to differnt hostnames 5. Verify that all queries go to port 53 """ carrier = get_operator_name(self.log, self.dut_b) asserts.skip_if(carrier != "vzw", "Carrier is not Verizon") self._test_private_dns_mode(self.dut_b, None, cconst.PRIVATE_DNS_MODE_OPPORTUNISTIC, False)
def test_private_dns_mode_opportunistic_tmo_carrier(self): """ Verify private dns mode opportunistic on TMO network Steps: 1. Set private dns mode opportunistic 2. Connect to wifi network. TMP supports DNS/TLS 3. Run HTTP ping to amazon.com, facebook.com, netflix.com 4. Verify ping works to differnt hostnames 5. Verify that all queries go to port 853 and encrypted """ carrier = get_operator_name(self.log, self.dut) asserts.skip_if(carrier != "tmo", "Carrier is not T-mobile") self._test_private_dns_mode(self.dut, None, cconst.PRIVATE_DNS_MODE_OPPORTUNISTIC, True)
def test_brightness_scale(self): """Test SetNormalizedBrightnessScale and SetNormalizedBrightnessScale FIDL calls. The display brightness should decrease then increase. This test will only run if the device config has a 'backlight_tests' entry. """ asserts.skip_if('backlight_tests' not in self.user_params, 'backlight_tests not specified in the config') time.sleep(BRIGHTNESS_CHANGE_SLEEP_TIME_SECONDS) # Brightness should decrease result = self.fd.backlight_lib.setNormalizedBrightnessScale( self.initial_scale * ONE_QUARTER_BRIGHTNESS) asserts.assert_true(result['error'] is None, 'SetNormalizedBrightnessScale failed') result = self.fd.backlight_lib.getNormalizedBrightnessScale() asserts.assert_true(result['error'] is None, 'GetNormalizedBrightnessScale failed') asserts.assert_true( float_near(result['result'], self.initial_scale * ONE_QUARTER_BRIGHTNESS), 'Got unexpected brightness scale value') # Toggle the brightness to force an update. This works around a hardware limitation. self.fd.backlight_lib.setStateNormalized(True, ONE_QUARTER_BRIGHTNESS) self.fd.backlight_lib.setStateNormalized(True, HALF_BRIGHTNESS) time.sleep(BRIGHTNESS_CHANGE_SLEEP_TIME_SECONDS) # Brightness should increase result = self.fd.backlight_lib.setNormalizedBrightnessScale( self.initial_scale) asserts.assert_true(result['error'] is None, 'SetNormalizedBrightnessScale failed') result = self.fd.backlight_lib.getNormalizedBrightnessScale() asserts.assert_true(result['error'] is None, 'GetNormalizedBrightnessScale failed') asserts.assert_true(float_near(result['result'], self.initial_scale), 'Got unexpected brightness scale value') self.fd.backlight_lib.setStateNormalized(True, ONE_QUARTER_BRIGHTNESS) self.fd.backlight_lib.setStateNormalized(True, HALF_BRIGHTNESS)
def test_private_dns_mode_strict_tmo_carrier(self): """ Verify private dns mode strict on TMO network Steps: 1. Set private dns mode strict 2. Connect to wifi network. TMO supports DNS/TLS 3. Run HTTP ping to amazon.com, facebook.com, netflix.com 4. Verify ping works to differnt hostnames 5. Verify that all queries go to port 853 and encrypted """ carrier = get_operator_name(self.log, self.dut) asserts.skip_if(carrier != "tmo", "Carrier is not T-mobile") for dns in self.private_dns_servers: self._test_private_dns_mode(self.dut, None, cconst.PRIVATE_DNS_MODE_STRICT, True, dns)
def test_hard_reboot_dut_ipv4_ipv6_2g_5g(self): # Note: This may need to be removed if non-battery android devices # are added. asserts.skip_if(self.user_params['dut'] == 'android_devices', 'No hard reboots for android battery devices.') test_list = [] for combination in itertools.product(IP_VERSIONS, BANDS): test_settings = { 'reboot_device': DUT, 'reboot_type': HARD, 'ipv4': combination[0][IPV4], 'ipv6': combination[0][IPV6], 'band': combination[1] } test_list.append(test_settings) self.run_generated_testcases(self.run_reboot_test, settings=test_list, name_func=get_test_name)
def test_connect_to_hidden_network(self): """ Adds a network suggestion with hidden SSID config, ensure device can scan and connect to this network. Steps: 1. Send a hidden network suggestion to the device. 2. Wait for the device to connect to it. 3. Ensure that we did not receive the post connection broadcast (isAppInteractionRequired = False). 4. Remove the suggestions and ensure the device does not connect back. """ asserts.skip_if(not hasattr(self, "hidden_networks"), "No hidden networks, skip this test") network_suggestion = self.hidden_network self.add_suggestions_and_ensure_connection( [network_suggestion], network_suggestion[WifiEnums.SSID_KEY], False) self.remove_suggestions_disconnect_and_ensure_no_connection_back( [network_suggestion], network_suggestion[WifiEnums.SSID_KEY])
def setup_test(self): required_params = ("aware_default_power_mode", ) self.unpack_userparams(required_params) for ad in self.android_devices: asserts.skip_if( not ad.droid.doesDeviceSupportWifiAwareFeature(), "Device under test does not support Wi-Fi Aware - skipping test" ) wutils.wifi_toggle_state(ad, True) ad.droid.wifiP2pClose() aware_avail = ad.droid.wifiIsAwareAvailable() if not aware_avail: self.log.info('Aware not available. Waiting ...') autils.wait_for_event(ad, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) ad.ed.clear_all_events() ad.aware_capabilities = autils.get_aware_capabilities(ad) self.reset_device_parameters(ad) self.reset_device_statistics(ad) self.set_power_mode_parameters(ad)
def setup_test(self): required_params = ( "aware_default_power_mode", "dbs_supported_models", ) self.unpack_userparams(required_params) if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"): wutils.start_cnss_diags(self.android_devices, self.cnss_diag_file, self.pixel_models) self.tcpdump_proc = [] if hasattr(self, "android_devices"): for ad in self.android_devices: proc = nutils.start_tcpdump(ad, self.test_name) self.tcpdump_proc.append((ad, proc)) for ad in self.android_devices: ad.droid.wifiEnableVerboseLogging(1) asserts.skip_if( not ad.droid.doesDeviceSupportWifiAwareFeature(), "Device under test does not support Wi-Fi Aware - skipping test" ) aware_avail = ad.droid.wifiIsAwareAvailable() ad.droid.wifiP2pClose() wutils.wifi_toggle_state(ad, True) utils.set_location_service(ad, True) if not aware_avail: self.log.info('Aware not available. Waiting ...') autils.wait_for_event(ad, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) ad.aware_capabilities = autils.get_aware_capabilities(ad) self.reset_device_parameters(ad) self.reset_device_statistics(ad) self.set_power_mode_parameters(ad) wutils.set_wifi_country_code(ad, wutils.WifiEnums.CountryCode.US) autils.configure_ndp_allow_any_override(ad, True) # set randomization interval to 0 (disable) to reduce likelihood of # interference in tests autils.configure_mac_random_interval(ad, 0) ad.ed.clear_all_events()
def test_att_passpoint_network(self): """Add a AT&T Passpoint network and verify device connects to it. Steps: 1. Install a AT&T Passpoint Profile. 2. Verify the device connects to the required Passpoint SSID. 3. Get the Passpoint configuration added above. 4. Delete Passpoint configuration using its FQDN. 5. Verify that we are disconnected from the Passpoint network. """ carriers = ["att"] operator = get_operator_name(self.log, self.dut) asserts.skip_if(operator not in carriers, "Device %s does not have a ATT sim" % self.dut.model) passpoint_config = self.passpoint_networks[ATT] self.install_passpoint_profile(passpoint_config) ssid = passpoint_config[WifiEnums.SSID_KEY] self.check_passpoint_connection(ssid) self.get_configured_passpoint_and_delete() wutils.wait_for_disconnect(self.dut)
def test_touch_reports(self): """Prints touch events for the next 5 seconds. This test requires a 'touch_test_params' object to be specified in the device config. touch_test_params will be used by the facade to find the touch device, and may include 'vendor_id' and 'product_id' values. """ asserts.skip_if('touch_tests_params' not in self.user_params, 'touch_tests_params not specified in the config') # Make a call to the facade to get it to establish a connection to the # touch device. This ensures that the first second of touch events don't # get missed. result = self.fd.input_report_lib.getDescriptor( **self.user_params['touch_tests_params']) self.log.info('Printing touch events for the next %d seconds...' % TEST_TIME_SECONDS) end_time = time.time() + TEST_TIME_SECONDS while time.time() < end_time: time.sleep(TEST_POLL_TIME_SECONDS) result = self.fd.input_report_lib.getReports( **self.user_params['touch_tests_params']) asserts.assert_true(result['error'] is None, 'GetReports failed: %s' % result['error']) for event in result['result']: contacts = event['touch']['contacts'] touch = ', '.join([ '(%d, %d)' % (t['position_x'], t['position_y']) for t in event['touch']['contacts'] ]) or '(none)' self.log.info('touch event @ %d: %s' % (event['event_time'], touch))
def test_multi_client_open(self): """Tests multi-client association with a single soft AP network. This tests associates a variable length list of clients, verfying it can can ping the SoftAP and pass traffic, and then verfies all previously associated clients can still ping and pass traffic. The same occurs in reverse for disassocations. """ asserts.skip_if( len(self.clients) < 2, 'Test requires at least 2 SoftAPClients') settings = { 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), 'security_type': SECURITY_OPEN, 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, 'operating_band': OPERATING_BAND_ANY } self.start_soft_ap(settings) dut_ap_interface = self.get_dut_interface_by_role(INTERFACE_ROLE_AP) associated = [] for client in self.clients: # Associate new client self.associate_with_soft_ap(client.w_device, settings) client_ipv4 = self.wait_for_ipv4_address( client.w_device, ANDROID_DEFAULT_WLAN_PORT) self.run_iperf_traffic(client.ip_client, dut_ap_interface.ipv4) # Verify previously associated clients still behave as expected for client_map in associated: associated_client = client_map['client'] associated_client_ipv4 = client_map['ipv4'] self.log.info( 'Verifying previously associated client %s still functions correctly.' % associated_client.w_device.device.serial) try: self.verify_ping(self.dut, associated_client_ipv4) self.verify_ping(associated_client.w_device, dut_ap_interface.ipv4) self.run_iperf_traffic(associated_client.ip_client, dut_ap_interface.ipv4) except signals.TestFailure as err: asserts.fail( 'Previously associated client %s failed checks after ' 'client %s associated. Error: %s' % (associated_client.w_device.device.serial, client.w_device.device.serial, err)) associated.append({'client': client, 'ipv4': client_ipv4}) self.log.info( 'All devices successfully associated. Beginning disassociations.') while len(associated) > 0: # Disassociate client client = associated.pop()['client'] self.disconnect_from_soft_ap(client.w_device) # Verify still connected clients still behave as expected for client_map in associated: associated_client = client_map['client'] associated_client_ipv4 = client_map['ipv4'] try: self.log.info( 'Verifying still associated client %s still functions ' 'correctly.' % associated_client.w_device.device.serial) self.verify_ping(self.dut, associated_client_ipv4) self.verify_ping(associated_client.w_device, dut_ap_interface.ipv4) self.run_iperf_traffic(associated_client.ip_client, dut_ap_interface.ipv4) except signals.TestFailure as err: asserts.fail( 'Previously associated client %s failed checks after' ' client %s disassociated. Error: %s' % (associated_client.w_device.device.serial, client.w_device.device.serial, err)) self.log.info('All disassociations occurred smoothly.')
def passpoint_connect_config_store_with_config_passpoint_tls(self): asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), "Passpoint is not supported on %s" % self.dut.model) self.eap_connect_toggle_wifi(self.config_passpoint_tls, self.dut)
def run_multiple_concurrent_services(self, type_x, type_y): """Validate multiple identical discovery services running on both devices: - DUT1 & DUT2 running Publish for X - DUT1 & DUT2 running Publish for Y - DUT1 Subscribes for X - DUT2 Subscribes for Y Message exchanges. Note: test requires that devices support 2 publish sessions concurrently. The test will be skipped if the devices are not capable. Args: type_x, type_y: A list of [ptype, stype] of the publish and subscribe types for services X and Y respectively. """ dut1 = self.android_devices[0] dut2 = self.android_devices[1] X_SERVICE_NAME = "ServiceXXX" Y_SERVICE_NAME = "ServiceYYY" asserts.skip_if( dut1.aware_capabilities[aconsts.CAP_MAX_PUBLISHES] < 2 or dut2.aware_capabilities[aconsts.CAP_MAX_PUBLISHES] < 2, "Devices do not support 2 publish sessions") # attach and wait for confirmation id1 = dut1.droid.wifiAwareAttach(False) autils.wait_for_event(dut1, aconsts.EVENT_CB_ON_ATTACHED) time.sleep(self.device_startup_offset) id2 = dut2.droid.wifiAwareAttach(False) autils.wait_for_event(dut2, aconsts.EVENT_CB_ON_ATTACHED) # DUT1 & DUT2: start publishing both X & Y services and wait for # confirmations dut1_x_pid = dut1.droid.wifiAwarePublish( id1, autils.create_discovery_config(X_SERVICE_NAME, type_x[0])) event = autils.wait_for_event(dut1, aconsts.SESSION_CB_ON_PUBLISH_STARTED) asserts.assert_equal(event["data"][aconsts.SESSION_CB_KEY_SESSION_ID], dut1_x_pid, "Unexpected DUT1 X publish session discovery ID") dut1_y_pid = dut1.droid.wifiAwarePublish( id1, autils.create_discovery_config(Y_SERVICE_NAME, type_y[0])) event = autils.wait_for_event(dut1, aconsts.SESSION_CB_ON_PUBLISH_STARTED) asserts.assert_equal(event["data"][aconsts.SESSION_CB_KEY_SESSION_ID], dut1_y_pid, "Unexpected DUT1 Y publish session discovery ID") dut2_x_pid = dut2.droid.wifiAwarePublish( id2, autils.create_discovery_config(X_SERVICE_NAME, type_x[0])) event = autils.wait_for_event(dut2, aconsts.SESSION_CB_ON_PUBLISH_STARTED) asserts.assert_equal(event["data"][aconsts.SESSION_CB_KEY_SESSION_ID], dut2_x_pid, "Unexpected DUT2 X publish session discovery ID") dut2_y_pid = dut2.droid.wifiAwarePublish( id2, autils.create_discovery_config(Y_SERVICE_NAME, type_y[0])) event = autils.wait_for_event(dut2, aconsts.SESSION_CB_ON_PUBLISH_STARTED) asserts.assert_equal(event["data"][aconsts.SESSION_CB_KEY_SESSION_ID], dut2_y_pid, "Unexpected DUT2 Y publish session discovery ID") # DUT1: start subscribing for X dut1_x_sid = dut1.droid.wifiAwareSubscribe( id1, autils.create_discovery_config(X_SERVICE_NAME, type_x[1])) autils.wait_for_event(dut1, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED) # DUT2: start subscribing for Y dut2_y_sid = dut2.droid.wifiAwareSubscribe( id2, autils.create_discovery_config(Y_SERVICE_NAME, type_y[1])) autils.wait_for_event(dut2, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED) # DUT1 & DUT2: wait for service discovery event = autils.wait_for_event(dut1, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) asserts.assert_equal( event["data"][aconsts.SESSION_CB_KEY_SESSION_ID], dut1_x_sid, "Unexpected DUT1 X subscribe session discovery ID") dut1_peer_id_for_dut2_x = event["data"][aconsts.SESSION_CB_KEY_PEER_ID] event = autils.wait_for_event(dut2, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) asserts.assert_equal( event["data"][aconsts.SESSION_CB_KEY_SESSION_ID], dut2_y_sid, "Unexpected DUT2 Y subscribe session discovery ID") dut2_peer_id_for_dut1_y = event["data"][aconsts.SESSION_CB_KEY_PEER_ID] # DUT1.X send message to DUT2 x_msg = "Hello X on DUT2!" dut1.droid.wifiAwareSendMessage(dut1_x_sid, dut1_peer_id_for_dut2_x, self.get_next_msg_id(), x_msg, self.msg_retx_count) autils.wait_for_event(dut1, aconsts.SESSION_CB_ON_MESSAGE_SENT) event = autils.wait_for_event(dut2, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED) asserts.assert_equal( event["data"][aconsts.SESSION_CB_KEY_SESSION_ID], dut2_x_pid, "Unexpected publish session ID on DUT2 for meesage " "received on service X") asserts.assert_equal( event["data"][aconsts.SESSION_CB_KEY_MESSAGE_AS_STRING], x_msg, "Message on service X from DUT1 to DUT2 not received correctly") # DUT2.Y send message to DUT1 y_msg = "Hello Y on DUT1!" dut2.droid.wifiAwareSendMessage(dut2_y_sid, dut2_peer_id_for_dut1_y, self.get_next_msg_id(), y_msg, self.msg_retx_count) autils.wait_for_event(dut2, aconsts.SESSION_CB_ON_MESSAGE_SENT) event = autils.wait_for_event(dut1, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED) asserts.assert_equal( event["data"][aconsts.SESSION_CB_KEY_SESSION_ID], dut1_y_pid, "Unexpected publish session ID on DUT1 for meesage " "received on service Y") asserts.assert_equal( event["data"][aconsts.SESSION_CB_KEY_MESSAGE_AS_STRING], y_msg, "Message on service Y from DUT2 to DUT1 not received correctly")
def test_soft_ap_and_client(self): """ Tests FuchsiaDevice DUT can act as a client and a SoftAP simultaneously. Raises: ConnectionError: if DUT fails to connect as client RuntimeError: if parallel processes fail to join TestFailure: if DUT fails to pass traffic as either a client or an AP """ asserts.skip_if(not self.access_point, 'No access point provided.') self.log.info('Setting up AP using hostapd.') # Configure AP ap_params = self.user_params.get('soft_ap_test_params', {}).get('ap_params', {}) channel = ap_params.get('channel', 11) ssid = ap_params.get('ssid', 'apnet') security_mode = ap_params.get('security_mode', None) password = ap_params.get('password', None) if security_mode: security = hostapd_security.Security(security_mode, password) else: security = None # Setup AP and associate DUT if not setup_ap_and_associate(access_point=self.access_point, client=self.dut, profile_name='whirlwind', channel=channel, security=security, password=password, ssid=ssid): raise ConnectionError( 'FuchsiaDevice DUT failed to connect as client to AP.') self.log.info('DUT successfully associated to AP network.') # Verify FuchsiaDevice's client interface has an ip address from AP dut_client_interface = self.get_dut_interface_by_role( INTERFACE_ROLE_CLIENT) # Verify FuchsiaDevice can ping AP lowest_5ghz_channel = 36 if channel < lowest_5ghz_channel: ap_interface = self.access_point.wlan_2g else: ap_interface = self.access_point.wlan_5g ap_ipv4 = utils.get_interface_ip_addresses( self.access_point.ssh, ap_interface)['ipv4_private'][0] self.verify_ping(self.dut, ap_ipv4) # Setup SoftAP soft_ap_settings = { 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), 'security_type': SECURITY_OPEN, 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, 'operating_band': OPERATING_BAND_2G } self.start_soft_ap(soft_ap_settings) # Get FuchsiaDevice's AP interface info dut_ap_interface = self.get_dut_interface_by_role(INTERFACE_ROLE_AP) # Associate primary client with SoftAP self.associate_with_soft_ap(self.primary_client.w_device, soft_ap_settings) # Verify primary client has an ip address from SoftAP client_ipv4 = self.wait_for_ipv4_address(self.primary_client.w_device, ANDROID_DEFAULT_WLAN_PORT) # Verify primary client can ping SoftAP, and reverse self.verify_ping(self.primary_client.w_device, dut_ap_interface.ipv4) self.verify_ping(self.dut, client_ipv4) # Set up secondary iperf server of FuchsiaDevice self.log.info('Setting up second iperf server on FuchsiaDevice DUT.') secondary_iperf_server = iperf_server.IPerfServerOverSsh( self.iperf_server_config, DEFAULT_IPERF_PORT + 1, use_killall=True) secondary_iperf_server.start() # Set up iperf client on AP self.log.info('Setting up iperf client on AP.') ap_iperf_client = iperf_client.IPerfClientOverSsh( self.user_params['AccessPoint'][0]['ssh_config']) # Setup iperf processes: # Primary client <-> SoftAP interface on FuchsiaDevice # AP <-> Client interface on FuchsiaDevice process_errors = mp.Queue() iperf_soft_ap = mp.Process( target=self.run_iperf_traffic_parallel_process, args=[ self.primary_client.ip_client, dut_ap_interface.ipv4, process_errors ]) iperf_fuchsia_client = mp.Process( target=self.run_iperf_traffic_parallel_process, args=[ap_iperf_client, dut_client_interface.ipv4, process_errors], kwargs={'server_port': 5202}) # Run iperf processes simultaneously self.log.info('Running simultaneous iperf traffic: between AP and DUT ' 'client interface, and DUT AP interface and client.') iperf_soft_ap.start() iperf_fuchsia_client.start() # Block until processes can join or timeout for proc in [iperf_soft_ap, iperf_fuchsia_client]: proc.join(timeout=30) if proc.is_alive(): raise RuntimeError('Failed to join process %s' % proc) # Stop iperf server (also stopped in teardown class as failsafe) secondary_iperf_server.stop() # Check errors from parallel processes if process_errors.empty(): asserts.explicit_pass( 'FuchsiaDevice was successfully able to pass traffic as a ' 'client and an AP simultaneously.') else: while not process_errors.empty(): self.log.error('Error in iperf process: %s' % process_errors.get()) asserts.fail( 'FuchsiaDevice failed to pass traffic as a client and an AP ' 'simultaneously.')