blob: 915b25f239af2ddfc7cd5350a9b5cc99e8117e62 [file] [log] [blame]
Girish Moturuf72690e2017-02-14 15:19:53 -08001#
2# Copyright 2017 - The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import logging
Girish Moturu2c21eb32017-05-25 14:37:55 +053017import random
Girish Moturuf72690e2017-02-14 15:19:53 -080018import socket
Girish Moturu2c21eb32017-05-25 14:37:55 +053019import time
Girish Moturuf72690e2017-02-14 15:19:53 -080020
21from acts import asserts
22from acts import base_test
23from acts import test_runner
24from acts.controllers import adb
Girish Moturu2c21eb32017-05-25 14:37:55 +053025from acts.test_decorators import test_tracker_info
Girish Moturuf72690e2017-02-14 15:19:53 -080026from acts.test_utils.tel import tel_defines
Girish Moturu2c21eb32017-05-25 14:37:55 +053027from acts.test_utils.tel.tel_data_utils import wait_for_cell_data_connection
28from acts.test_utils.tel.tel_test_utils import get_operator_name
Girish Moturu2c21eb32017-05-25 14:37:55 +053029from acts.test_utils.tel.tel_test_utils import verify_http_connection
30from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_2G
31from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_5G
Girish Moturuf5d2b2a2018-05-30 10:07:32 -070032from acts.test_utils.net import socket_test_utils as sutils
Girish Moturu47366062018-05-23 12:48:11 -070033from acts.test_utils.net import arduino_test_utils as dutils
Girish Moturu95f2f452018-07-23 15:57:15 -070034from acts.test_utils.net import net_test_utils as nutils
Girish Moturu2c21eb32017-05-25 14:37:55 +053035from acts.test_utils.wifi import wifi_test_utils as wutils
Girish Moturuf72690e2017-02-14 15:19:53 -080036
Girish Moturu8d9741f2019-04-01 08:43:16 -070037WAIT_TIME = 5
Girish Moturuf72690e2017-02-14 15:19:53 -080038
39class WifiTetheringTest(base_test.BaseTestClass):
40 """ Tests for Wifi Tethering """
41
42 def setup_class(self):
43 """ Setup devices for tethering and unpack params """
Girish Moturu2c21eb32017-05-25 14:37:55 +053044
Girish Moturu2c21eb32017-05-25 14:37:55 +053045 self.hotspot_device = self.android_devices[0]
46 self.tethered_devices = self.android_devices[1:]
Girish Moturub0768fa2018-02-13 15:24:27 -080047 req_params = ("network", "url", "open_network")
Girish Moturuf72690e2017-02-14 15:19:53 -080048 self.unpack_userparams(req_params)
Girish Moturu666e0972018-01-02 11:20:31 -080049 self.new_ssid = "wifi_tethering_test2"
Girish Moturu2c21eb32017-05-25 14:37:55 +053050
Girish Moturu95f2f452018-07-23 15:57:15 -070051 nutils.verify_lte_data_and_tethering_supported(self.hotspot_device)
Girish Moturu2c21eb32017-05-25 14:37:55 +053052 for ad in self.tethered_devices:
53 wutils.wifi_test_device_init(ad)
Girish Moturuf72690e2017-02-14 15:19:53 -080054
55 def teardown_class(self):
56 """ Reset devices """
Girish Moturu9bd1e9a2017-12-14 10:10:25 -080057 for ad in self.tethered_devices:
Girish Moturu95f2f452018-07-23 15:57:15 -070058 wutils.reset_wifi(ad)
Girish Moturu2c21eb32017-05-25 14:37:55 +053059
60 def on_fail(self, test_name, begin_time):
61 """ Collect bug report on failure """
Girish Moturu95f2f452018-07-23 15:57:15 -070062 for ad in self.android_devices:
Girish Moturu7df90e32017-10-16 12:49:56 -070063 ad.take_bug_report(test_name, begin_time)
Girish Moturuf72690e2017-02-14 15:19:53 -080064
65 """ Helper functions """
66
Girish Moturu2c21eb32017-05-25 14:37:55 +053067 def _is_ipaddress_ipv6(self, ip_address):
Girish Moturuf72690e2017-02-14 15:19:53 -080068 """ Verify if the given string is a valid IPv6 address
69
70 Args:
71 1. string which contains the IP address
72
73 Returns:
74 True: if valid ipv6 address
75 False: if not
76 """
77 try:
78 socket.inet_pton(socket.AF_INET6, ip_address)
79 return True
80 except socket.error:
81 return False
82
83 def _supports_ipv6_tethering(self, dut):
84 """ Check if provider supports IPv6 tethering.
85 Currently, only Verizon supports IPv6 tethering
86
87 Returns:
88 True: if provider supports IPv6 tethering
89 False: if not
90 """
91 # Currently only Verizon support IPv6 tethering
92 carrier_supports_tethering = ["vzw"]
Girish Moturu2c21eb32017-05-25 14:37:55 +053093 operator = get_operator_name(self.log, dut)
Girish Moturuf72690e2017-02-14 15:19:53 -080094 return operator in carrier_supports_tethering
95
Girish Moturu2c21eb32017-05-25 14:37:55 +053096 def _carrier_supports_ipv6(self,dut):
97 """ Verify if carrier supports ipv6
98 Currently, only verizon and t-mobile supports IPv6
99
100 Returns:
101 True: if carrier supports ipv6
102 False: if not
103 """
104 carrier_supports_ipv6 = ["vzw", "tmo"]
105 operator = get_operator_name(self.log, dut)
Girish Moturu7f287522017-09-25 13:33:06 -0700106 self.log.info("Carrier is %s" % operator)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530107 return operator in carrier_supports_ipv6
108
Girish Moturu2c21eb32017-05-25 14:37:55 +0530109 def _verify_ipv6_tethering(self, dut):
Girish Moturuf72690e2017-02-14 15:19:53 -0800110 """ Verify IPv6 tethering """
111 http_response = dut.droid.httpRequestString(self.url)
Girish Moturuf72690e2017-02-14 15:19:53 -0800112 self.log.info("IP address %s " % http_response)
Girish Moturu0fd0b942017-12-12 12:04:56 -0800113 active_link_addrs = dut.droid.connectivityGetAllAddressesOfActiveLink()
Girish Moturu2c21eb32017-05-25 14:37:55 +0530114 if dut==self.hotspot_device and self._carrier_supports_ipv6(dut)\
115 or self._supports_ipv6_tethering(self.hotspot_device):
Girish Moturuf72690e2017-02-14 15:19:53 -0800116 asserts.assert_true(self._is_ipaddress_ipv6(http_response),
117 "The http response did not return IPv6 address")
Girish Moturu0fd0b942017-12-12 12:04:56 -0800118 asserts.assert_true(
119 active_link_addrs and http_response in str(active_link_addrs),
120 "Could not find IPv6 address in link properties")
121 asserts.assert_true(
122 dut.droid.connectivityHasIPv6DefaultRoute(),
123 "Could not find IPv6 default route in link properties")
Girish Moturuf72690e2017-02-14 15:19:53 -0800124 else:
Girish Moturu0fd0b942017-12-12 12:04:56 -0800125 asserts.assert_true(
126 not dut.droid.connectivityHasIPv6DefaultRoute(),
127 "Found IPv6 default route in link properties")
Girish Moturuf72690e2017-02-14 15:19:53 -0800128
Girish Moturu2c21eb32017-05-25 14:37:55 +0530129 def _start_wifi_tethering(self, wifi_band=WIFI_CONFIG_APBAND_2G):
130 """ Start wifi tethering on hotspot device
131
132 Args:
133 1. wifi_band: specifies the wifi band to start the hotspot
134 on. The current options are 2G and 5G
135 """
136 wutils.start_wifi_tethering(self.hotspot_device,
137 self.network[wutils.WifiEnums.SSID_KEY],
138 self.network[wutils.WifiEnums.PWD_KEY],
139 wifi_band)
140
141 def _connect_disconnect_devices(self):
142 """ Randomly connect and disconnect devices from the
143 self.tethered_devices list to hotspot device
144 """
145 device_connected = [ False ] * len(self.tethered_devices)
146 for _ in range(50):
147 dut_id = random.randint(0, len(self.tethered_devices)-1)
148 dut = self.tethered_devices[dut_id]
Girish Moturu7df90e32017-10-16 12:49:56 -0700149 # wait for 1 sec between connect & disconnect stress test
150 time.sleep(1)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530151 if device_connected[dut_id]:
152 wutils.wifi_forget_network(dut, self.network["SSID"])
153 else:
154 wutils.wifi_connect(dut, self.network)
155 device_connected[dut_id] = not device_connected[dut_id]
156
Girish Moturu47366062018-05-23 12:48:11 -0700157 def _connect_disconnect_android_device(self, dut_id, wifi_state):
158 """ Connect or disconnect wifi on android device depending on the
159 current wifi state
160
161 Args:
162 1. dut_id: tethered device to change the wifi state
163 2. wifi_state: current wifi state
164 """
165 ad = self.tethered_devices[dut_id]
166 if wifi_state:
167 self.log.info("Disconnecting wifi on android device")
168 wutils.wifi_forget_network(ad, self.network["SSID"])
169 else:
170 self.log.info("Connecting to wifi on android device")
171 wutils.wifi_connect(ad, self.network)
172
173 def _connect_disconnect_wifi_dongle(self, dut_id, wifi_state):
174 """ Connect or disconnect wifi on wifi dongle depending on the
175 current wifi state
176
177 Args:
178 1. dut_id: wifi dongle to change the wifi state
179 2. wifi_state: current wifi state
180 """
181 wd = self.arduino_wifi_dongles[dut_id]
182 if wifi_state:
183 self.log.info("Disconnecting wifi on dongle")
184 dutils.disconnect_wifi(wd)
185 else:
186 self.log.info("Connecting to wifi on dongle")
187 dutils.connect_wifi(wd, self.network)
188
189 def _connect_disconnect_tethered_devices(self):
190 """ Connect disconnect tethered devices to wifi hotspot """
191 num_android_devices = len(self.tethered_devices)
192 num_wifi_dongles = 0
Girish Moturu95f2f452018-07-23 15:57:15 -0700193 if hasattr(self, 'arduino_wifi_dongles'):
Girish Moturu47366062018-05-23 12:48:11 -0700194 num_wifi_dongles = len(self.arduino_wifi_dongles)
195 total_devices = num_android_devices + num_wifi_dongles
196 device_connected = [False] * total_devices
197 for _ in range(50):
198 dut_id = random.randint(0, total_devices-1)
199 wifi_state = device_connected[dut_id]
200 if dut_id < num_android_devices:
201 self._connect_disconnect_android_device(dut_id, wifi_state)
202 else:
203 self._connect_disconnect_wifi_dongle(dut_id-num_android_devices,
204 wifi_state)
205 device_connected[dut_id] = not device_connected[dut_id]
206
Girish Moturu7f287522017-09-25 13:33:06 -0700207 def _verify_ping(self, dut, ip, isIPv6=False):
Girish Moturu2c21eb32017-05-25 14:37:55 +0530208 """ Verify ping works from the dut to IP/hostname
209
210 Args:
211 1. dut - ad object to check ping from
212 2. ip - ip/hostname to ping (IPv4 and IPv6)
213
214 Returns:
215 True - if ping is successful
216 False - if not
217 """
218 self.log.info("Pinging %s from dut %s" % (ip, dut.serial))
Girish Moturu7f287522017-09-25 13:33:06 -0700219 if isIPv6 or self._is_ipaddress_ipv6(ip):
Girish Moturu2c21eb32017-05-25 14:37:55 +0530220 return dut.droid.pingHost(ip, 5, "ping6")
221 return dut.droid.pingHost(ip)
222
223 def _return_ip_for_interface(self, dut, iface_name):
224 """ Return list of IP addresses for an interface
225
226 Args:
227 1. dut - ad object
228 2. iface_name - interface name
229
230 Returns:
231 List of IPv4 and IPv6 addresses
232 """
233 return dut.droid.connectivityGetIPv4Addresses(iface_name) + \
234 dut.droid.connectivityGetIPv6Addresses(iface_name)
235
Girish Moturu47366062018-05-23 12:48:11 -0700236 def _test_traffic_between_two_tethered_devices(self, ad, wd):
Girish Moturu2c21eb32017-05-25 14:37:55 +0530237 """ Verify pinging interfaces of one DUT from another
238
239 Args:
Girish Moturu47366062018-05-23 12:48:11 -0700240 1. ad - android device
241 2. wd - wifi dongle
Girish Moturu2c21eb32017-05-25 14:37:55 +0530242 """
Girish Moturu47366062018-05-23 12:48:11 -0700243 wutils.wifi_connect(ad, self.network)
244 dutils.connect_wifi(wd, self.network)
245 local_ip = ad.droid.connectivityGetIPv4Addresses('wlan0')[0]
246 remote_ip = wd.ip_address()
247 port = 8888
Girish Moturu2c21eb32017-05-25 14:37:55 +0530248
Girish Moturu47366062018-05-23 12:48:11 -0700249 time.sleep(6) # wait until UDP packets method is invoked
Girish Moturuf5d2b2a2018-05-30 10:07:32 -0700250 socket = sutils.open_datagram_socket(ad, local_ip, port)
251 sutils.send_recv_data_datagram_sockets(
Girish Moturu47366062018-05-23 12:48:11 -0700252 ad, ad, socket, socket, remote_ip, port)
Girish Moturuf5d2b2a2018-05-30 10:07:32 -0700253 sutils.close_datagram_socket(ad, socket)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530254
255 def _ping_hotspot_interfaces_from_tethered_device(self, dut):
256 """ Ping hotspot interfaces from tethered device
257
258 Args:
259 1. dut - tethered device
260
261 Returns:
262 True - if all IP addresses are pingable
263 False - if not
264 """
265 ifaces = self.hotspot_device.droid.connectivityGetNetworkInterfaces()
266 return_result = True
267 for interface in ifaces:
268 iface_name = interface.split()[0].split(':')[1]
269 if iface_name == "lo":
270 continue
271 ip_list = self._return_ip_for_interface(
272 self.hotspot_device, iface_name)
273 for ip in ip_list:
274 ping_result = self._verify_ping(dut, ip)
275 self.log.info("Ping result: %s %s %s" %
276 (iface_name, ip, ping_result))
277 return_result = return_result and ping_result
278
279 return return_result
Girish Moturuf72690e2017-02-14 15:19:53 -0800280
Girish Moturub0768fa2018-02-13 15:24:27 -0800281 def _save_wifi_softap_configuration(self, ad, config):
282 """ Save soft AP configuration
283
284 Args:
285 1. dut - device to save configuration on
286 2. config - soft ap configuration
287 """
288 asserts.assert_true(ad.droid.wifiSetWifiApConfiguration(config),
289 "Failed to set WifiAp Configuration")
290 wifi_ap = ad.droid.wifiGetApConfiguration()
291 asserts.assert_true(wifi_ap[wutils.WifiEnums.SSID_KEY] == config[wutils.WifiEnums.SSID_KEY],
292 "Configured wifi hotspot SSID does not match with the expected SSID")
293
294 def _turn_on_wifi_hotspot(self, ad):
295 """ Turn on wifi hotspot with a config that is already saved
296
297 Args:
298 1. dut - device to turn wifi hotspot on
299 """
300 ad.droid.wifiStartTrackingTetherStateChange()
301 ad.droid.connectivityStartTethering(tel_defines.TETHERING_WIFI, False)
302 try:
303 ad.ed.pop_event("ConnectivityManagerOnTetheringStarted")
304 ad.ed.wait_for_event("TetherStateChanged",
305 lambda x: x["data"]["ACTIVE_TETHER"], 30)
306 except:
307 asserts.fail("Didn't receive wifi tethering starting confirmation")
308 ad.droid.wifiStopTrackingTetherStateChange()
309
Girish Moturuf72690e2017-02-14 15:19:53 -0800310 """ Test Cases """
311
Girish Moturu2c21eb32017-05-25 14:37:55 +0530312 @test_tracker_info(uuid="36d03295-bea3-446e-8342-b9f8f1962a32")
Girish Moturuf72690e2017-02-14 15:19:53 -0800313 def test_ipv6_tethering(self):
314 """ IPv6 tethering test
315
316 Steps:
Girish Moturu2c21eb32017-05-25 14:37:55 +0530317 1. Start wifi tethering on hotspot device
Girish Moturu7df90e32017-10-16 12:49:56 -0700318 2. Verify IPv6 address on hotspot device (VZW & TMO only)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530319 3. Connect tethered device to hotspot device
Girish Moturu7df90e32017-10-16 12:49:56 -0700320 4. Verify IPv6 address on the client's link properties (VZW only)
321 5. Verify ping on client using ping6 which should pass (VZW only)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530322 6. Disable mobile data on provider and verify that link properties
Girish Moturu7df90e32017-10-16 12:49:56 -0700323 does not have IPv6 address and default route (VZW only)
Girish Moturuf72690e2017-02-14 15:19:53 -0800324 """
325 # Start wifi tethering on the hotspot device
Girish Moturu2c21eb32017-05-25 14:37:55 +0530326 wutils.toggle_wifi_off_and_on(self.hotspot_device)
327 self._start_wifi_tethering()
Girish Moturuf72690e2017-02-14 15:19:53 -0800328
329 # Verify link properties on hotspot device
Girish Moturu7f287522017-09-25 13:33:06 -0700330 self.log.info("Check IPv6 properties on the hotspot device. "
331 "Verizon & T-mobile should have IPv6 in link properties")
Girish Moturuf72690e2017-02-14 15:19:53 -0800332 self._verify_ipv6_tethering(self.hotspot_device)
333
334 # Connect the client to the SSID
Girish Moturu2c21eb32017-05-25 14:37:55 +0530335 wutils.wifi_connect(self.tethered_devices[0], self.network)
Girish Moturuf72690e2017-02-14 15:19:53 -0800336
337 # Need to wait atleast 2 seconds for IPv6 address to
338 # show up in the link properties
Girish Moturu7f287522017-09-25 13:33:06 -0700339 time.sleep(WAIT_TIME)
Girish Moturuf72690e2017-02-14 15:19:53 -0800340
341 # Verify link properties on tethered device
Girish Moturu7f287522017-09-25 13:33:06 -0700342 self.log.info("Check IPv6 properties on the tethered device. "
343 "Device should have IPv6 if carrier is Verizon")
Girish Moturu2c21eb32017-05-25 14:37:55 +0530344 self._verify_ipv6_tethering(self.tethered_devices[0])
Girish Moturuf72690e2017-02-14 15:19:53 -0800345
346 # Verify ping6 on tethered device
Girish Moturu2c21eb32017-05-25 14:37:55 +0530347 ping_result = self._verify_ping(self.tethered_devices[0],
Girish Moturu7f287522017-09-25 13:33:06 -0700348 wutils.DEFAULT_PING_ADDR, True)
Girish Moturuf72690e2017-02-14 15:19:53 -0800349 if self._supports_ipv6_tethering(self.hotspot_device):
350 asserts.assert_true(ping_result, "Ping6 failed on the client")
351 else:
352 asserts.assert_true(not ping_result, "Ping6 failed as expected")
353
354 # Disable mobile data on hotspot device
355 # and verify the link properties on tethered device
Girish Moturu2c21eb32017-05-25 14:37:55 +0530356 self.log.info("Disabling mobile data to verify ipv6 default route")
Girish Moturuf72690e2017-02-14 15:19:53 -0800357 self.hotspot_device.droid.telephonyToggleDataConnection(False)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530358 asserts.assert_equal(
359 self.hotspot_device.droid.telephonyGetDataConnectionState(),
360 tel_defines.DATA_STATE_CONNECTED,
361 "Could not disable cell data")
362
Girish Moturu7f287522017-09-25 13:33:06 -0700363 time.sleep(WAIT_TIME) # wait until the IPv6 is removed from link properties
Girish Moturu2c21eb32017-05-25 14:37:55 +0530364
Girish Moturu0fd0b942017-12-12 12:04:56 -0800365 result = self.tethered_devices[0].droid.connectivityHasIPv6DefaultRoute()
Girish Moturu2c21eb32017-05-25 14:37:55 +0530366 self.hotspot_device.droid.telephonyToggleDataConnection(True)
Girish Moturu7df90e32017-10-16 12:49:56 -0700367 if result:
Girish Moturu2c21eb32017-05-25 14:37:55 +0530368 asserts.fail("Found IPv6 default route in link properties:Data off")
Girish Moturu7df90e32017-10-16 12:49:56 -0700369 self.log.info("Did not find IPv6 address in link properties")
Girish Moturu2c21eb32017-05-25 14:37:55 +0530370
371 # Disable wifi tethering
372 wutils.stop_wifi_tethering(self.hotspot_device)
373
374 @test_tracker_info(uuid="110b61d1-8af2-4589-8413-11beac7a3025")
Girish Moturu47366062018-05-23 12:48:11 -0700375 def test_wifi_tethering_2ghz_traffic_between_2tethered_devices(self):
Girish Moturu2c21eb32017-05-25 14:37:55 +0530376 """ Steps:
377
378 1. Start wifi hotspot with 2G band
379 2. Connect 2 tethered devices to the hotspot device
380 3. Ping interfaces between the tethered devices
381 """
Girish Moturu95f2f452018-07-23 15:57:15 -0700382 asserts.skip_if(not hasattr(self, 'arduino_wifi_dongles'),
383 "No wifi dongles connected. Skipping test")
Girish Moturu2c21eb32017-05-25 14:37:55 +0530384 wutils.toggle_wifi_off_and_on(self.hotspot_device)
385 self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G)
386 self._test_traffic_between_two_tethered_devices(self.tethered_devices[0],
Girish Moturu47366062018-05-23 12:48:11 -0700387 self.arduino_wifi_dongles[0])
Girish Moturu2c21eb32017-05-25 14:37:55 +0530388 wutils.stop_wifi_tethering(self.hotspot_device)
389
390 @test_tracker_info(uuid="953f6e2e-27bd-4b73-85a6-d2eaa4e755d5")
Girish Moturu7df90e32017-10-16 12:49:56 -0700391 def wifi_tethering_5ghz_traffic_between_2tethered_devices(self):
Girish Moturu2c21eb32017-05-25 14:37:55 +0530392 """ Steps:
393
394 1. Start wifi hotspot with 5ghz band
395 2. Connect 2 tethered devices to the hotspot device
396 3. Send traffic between the tethered devices
397 """
398 wutils.toggle_wifi_off_and_on(self.hotspot_device)
399 self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
400 self._test_traffic_between_two_tethered_devices(self.tethered_devices[0],
Girish Moturu47366062018-05-23 12:48:11 -0700401 self.arduino_wifi_dongles[0])
Girish Moturu2c21eb32017-05-25 14:37:55 +0530402 wutils.stop_wifi_tethering(self.hotspot_device)
403
404 @test_tracker_info(uuid="d7d5aa51-682d-4882-a334-61966d93b68c")
405 def test_wifi_tethering_2ghz_connect_disconnect_devices(self):
406 """ Steps:
407
408 1. Start wifi hotspot with 2ghz band
409 2. Connect and disconnect multiple devices randomly
410 3. Verify the correct functionality
411 """
412 wutils.toggle_wifi_off_and_on(self.hotspot_device)
413 self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G)
Girish Moturu47366062018-05-23 12:48:11 -0700414 self._connect_disconnect_tethered_devices()
Girish Moturu2c21eb32017-05-25 14:37:55 +0530415 wutils.stop_wifi_tethering(self.hotspot_device)
416
417 @test_tracker_info(uuid="34abd6c9-c7f1-4d89-aa2b-a66aeabed9aa")
418 def test_wifi_tethering_5ghz_connect_disconnect_devices(self):
419 """ Steps:
420
421 1. Start wifi hotspot with 5ghz band
422 2. Connect and disconnect multiple devices randomly
423 3. Verify the correct functionality
424 """
425 wutils.toggle_wifi_off_and_on(self.hotspot_device)
426 self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
427 self._connect_disconnect_devices()
428 wutils.stop_wifi_tethering(self.hotspot_device)
429
430 @test_tracker_info(uuid="7edfb220-37f8-42ea-8d7c-39712fbe9be5")
431 def test_wifi_tethering_2ghz_ping_hotspot_interfaces(self):
432 """ Steps:
433
434 1. Start wifi hotspot with 2ghz band
435 2. Connect tethered device to hotspot device
436 3. Ping 'wlan0' and 'rmnet_data' interface's IPv4
437 and IPv6 interfaces on hotspot device from tethered device
438 """
439 wutils.toggle_wifi_off_and_on(self.hotspot_device)
440 self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G)
441 wutils.wifi_connect(self.tethered_devices[0], self.network)
442 result = self._ping_hotspot_interfaces_from_tethered_device(
443 self.tethered_devices[0])
444 wutils.stop_wifi_tethering(self.hotspot_device)
445 return result
446
447 @test_tracker_info(uuid="17e450f4-795f-4e67-adab-984940dffedc")
448 def test_wifi_tethering_5ghz_ping_hotspot_interfaces(self):
449 """ Steps:
450
451 1. Start wifi hotspot with 5ghz band
452 2. Connect tethered device to hotspot device
453 3. Ping 'wlan0' and 'rmnet_data' interface's IPv4
454 and IPv6 interfaces on hotspot device from tethered device
455 """
456 wutils.toggle_wifi_off_and_on(self.hotspot_device)
457 self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G)
458 wutils.wifi_connect(self.tethered_devices[0], self.network)
459 result = self._ping_hotspot_interfaces_from_tethered_device(
460 self.tethered_devices[0])
461 wutils.stop_wifi_tethering(self.hotspot_device)
462 return result
463
Girish Moturu2c21eb32017-05-25 14:37:55 +0530464 @test_tracker_info(uuid="2bc344cb-0277-4f06-b6cc-65b3972086ed")
465 def test_change_wifi_hotspot_ssid_when_hotspot_enabled(self):
466 """ Steps:
467
468 1. Start wifi tethering
469 2. Verify wifi Ap configuration
470 3. Change the SSID of the wifi hotspot while hotspot is on
471 4. Verify the new SSID in wifi ap configuration
472 5. Restart tethering and verify that the tethered device is able
473 to connect to the new SSID
474 """
475 wutils.toggle_wifi_off_and_on(self.hotspot_device)
476 dut = self.hotspot_device
477
478 # start tethering and verify the wifi ap configuration settings
479 self._start_wifi_tethering()
480 wifi_ap = dut.droid.wifiGetApConfiguration()
481 asserts.assert_true(
482 wifi_ap[wutils.WifiEnums.SSID_KEY] == \
483 self.network[wutils.WifiEnums.SSID_KEY],
484 "Configured wifi hotspot SSID did not match with the expected SSID")
485 wutils.wifi_connect(self.tethered_devices[0], self.network)
486
487 # update the wifi ap configuration with new ssid
488 config = {wutils.WifiEnums.SSID_KEY: self.new_ssid}
489 config[wutils.WifiEnums.PWD_KEY] = self.network[wutils.WifiEnums.PWD_KEY]
490 config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_2G
Girish Moturub0768fa2018-02-13 15:24:27 -0800491 self._save_wifi_softap_configuration(dut, config)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530492
493 # start wifi tethering with new wifi ap configuration
494 wutils.stop_wifi_tethering(dut)
Girish Moturub0768fa2018-02-13 15:24:27 -0800495 self._turn_on_wifi_hotspot(dut)
Girish Moturu2c21eb32017-05-25 14:37:55 +0530496
497 # verify dut can connect to new wifi ap configuration
498 new_network = {wutils.WifiEnums.SSID_KEY: self.new_ssid,
499 wutils.WifiEnums.PWD_KEY: \
500 self.network[wutils.WifiEnums.PWD_KEY]}
501 wutils.wifi_connect(self.tethered_devices[0], new_network)
502 wutils.stop_wifi_tethering(self.hotspot_device)
Girish Moturub0768fa2018-02-13 15:24:27 -0800503
504 @test_tracker_info(uuid="4cf7ab26-ca2d-46f6-9d3f-a935c7e04c97")
505 def test_wifi_tethering_open_network_2g(self):
506 """ Steps:
507
508 1. Start wifi tethering with open network 2G band
509 (Not allowed manually. b/72412729)
510 2. Connect tethered device to the SSID
511 3. Verify internet connectivity
512 """
513 wutils.start_wifi_tethering(
514 self.hotspot_device, self.open_network[wutils.WifiEnums.SSID_KEY],
515 None, WIFI_CONFIG_APBAND_2G)
516 wutils.wifi_connect(self.tethered_devices[0], self.open_network)
517 wutils.stop_wifi_tethering(self.hotspot_device)
518
519 @test_tracker_info(uuid="f407049b-1324-40ea-a8d1-f90587933310")
520 def test_wifi_tethering_open_network_5g(self):
521 """ Steps:
522
523 1. Start wifi tethering with open network 5G band
524 (Not allowed manually. b/72412729)
525 2. Connect tethered device to the SSID
526 3. Verify internet connectivity
527 """
528 wutils.start_wifi_tethering(
529 self.hotspot_device, self.open_network[wutils.WifiEnums.SSID_KEY],
530 None, WIFI_CONFIG_APBAND_5G)
531 wutils.wifi_connect(self.tethered_devices[0], self.open_network)
532 wutils.stop_wifi_tethering(self.hotspot_device)
533
534 @test_tracker_info(uuid="d964f2e6-0acb-417c-ada9-eb9fc5a470e4")
535 def test_wifi_tethering_open_network_2g_stress(self):
536 """ Steps:
537
538 1. Save wifi hotspot configuration with open network 2G band
539 (Not allowed manually. b/72412729)
540 2. Turn on wifi hotspot
541 3. Connect tethered device and verify internet connectivity
542 4. Turn off wifi hotspot
543 5. Repeat steps 2 to 4
544 """
545 # save open network wifi ap configuration with 2G band
546 config = {wutils.WifiEnums.SSID_KEY:
547 self.open_network[wutils.WifiEnums.SSID_KEY]}
548 config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_2G
549 self._save_wifi_softap_configuration(self.hotspot_device, config)
550
551 # turn on/off wifi hotspot, connect device
552 for _ in range(9):
553 self._turn_on_wifi_hotspot(self.hotspot_device)
554 wutils.wifi_connect(self.tethered_devices[0], self.open_network)
555 wutils.stop_wifi_tethering(self.hotspot_device)
556 time.sleep(1) # wait for some time before turning on hotspot
557
558 @test_tracker_info(uuid="c7ef840c-4003-41fc-80e3-755f9057b542")
559 def test_wifi_tethering_open_network_5g_stress(self):
560 """ Steps:
561
562 1. Save wifi hotspot configuration with open network 5G band
563 (Not allowed manually. b/72412729)
564 2. Turn on wifi hotspot
565 3. Connect tethered device and verify internet connectivity
566 4. Turn off wifi hotspot
567 5. Repeat steps 2 to 4
568 """
569 # save open network wifi ap configuration with 5G band
570 config = {wutils.WifiEnums.SSID_KEY:
571 self.open_network[wutils.WifiEnums.SSID_KEY]}
572 config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_5G
573 self._save_wifi_softap_configuration(self.hotspot_device, config)
574
575 # turn on/off wifi hotspot, connect device
576 for _ in range(9):
577 self._turn_on_wifi_hotspot(self.hotspot_device)
578 wutils.wifi_connect(self.tethered_devices[0], self.open_network)
579 wutils.stop_wifi_tethering(self.hotspot_device)
580 time.sleep(1) # wait for some time before turning on hotspot