• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3.4
2#
3#   Copyright 2017 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17import itertools
18import pprint
19import time
20
21import acts.signals
22import acts.test_utils.wifi.wifi_test_utils as wutils
23
24from acts import asserts
25from acts.test_decorators import test_tracker_info
26from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest
27
28WifiEnums = wutils.WifiEnums
29
30
31class WifiIOTTest(WifiBaseTest):
32    """ Tests for wifi IOT
33
34        Test Bed Requirement:
35          * One Android device
36          * Wi-Fi IOT networks visible to the device
37    """
38
39    def __init__(self, controllers):
40        WifiBaseTest.__init__(self, controllers)
41
42    def setup_class(self):
43        self.dut = self.android_devices[0]
44        wutils.wifi_test_device_init(self.dut)
45
46        req_params = [ "iot_networks", ]
47        opt_params = [ "open_network", "iperf_server_address" ]
48        self.unpack_userparams(req_param_names=req_params,
49                               opt_param_names=opt_params)
50
51        asserts.assert_true(
52            len(self.iot_networks) > 0,
53            "Need at least one iot network with psk.")
54
55        if getattr(self, 'open_network', False):
56            self.iot_networks.append(self.open_network)
57
58        wutils.wifi_toggle_state(self.dut, True)
59        if "iperf_server_address" in self.user_params:
60            self.iperf_server = self.iperf_servers[0]
61            self.iperf_server.start()
62
63        # create hashmap for testcase name and SSIDs
64        self.iot_test_prefix = "test_iot_connection_to_"
65        self.ssid_map = {}
66        for network in self.iot_networks:
67            SSID = network['SSID'].replace('-','_')
68            self.ssid_map[SSID] = network
69
70    def setup_test(self):
71        self.dut.droid.wakeLockAcquireBright()
72        self.dut.droid.wakeUpNow()
73
74    def teardown_test(self):
75        self.dut.droid.wakeLockRelease()
76        self.dut.droid.goToSleepNow()
77        wutils.reset_wifi(self.dut)
78
79    def teardown_class(self):
80        if "iperf_server_address" in self.user_params:
81            self.iperf_server.stop()
82
83    def on_fail(self, test_name, begin_time):
84        self.dut.take_bug_report(test_name, begin_time)
85        self.dut.cat_adb_log(test_name, begin_time)
86
87    """Helper Functions"""
88
89    def connect_to_wifi_network(self, network):
90        """Connection logic for open and psk wifi networks.
91
92        Args:
93            params: Dictionary with network info.
94        """
95        SSID = network[WifiEnums.SSID_KEY]
96        self.dut.ed.clear_all_events()
97        wutils.start_wifi_connection_scan(self.dut)
98        scan_results = self.dut.droid.wifiGetScanResults()
99        wutils.assert_network_in_list({WifiEnums.SSID_KEY: SSID}, scan_results)
100        wutils.wifi_connect(self.dut, network, num_of_tries=3)
101
102    def run_iperf_client(self, network):
103        """Run iperf traffic after connection.
104
105        Args:
106            params: Dictionary with network info.
107        """
108        if "iperf_server_address" in self.user_params:
109            wait_time = 5
110            SSID = network[WifiEnums.SSID_KEY]
111            self.log.info("Starting iperf traffic through {}".format(SSID))
112            time.sleep(wait_time)
113            port_arg = "-p {}".format(self.iperf_server.port)
114            success, data = self.dut.run_iperf_client(self.iperf_server_address,
115                                                      port_arg)
116            self.log.debug(pprint.pformat(data))
117            asserts.assert_true(success, "Error occurred in iPerf traffic.")
118
119    def connect_to_wifi_network_and_run_iperf(self, network):
120        """Connection logic for open and psk wifi networks.
121
122        Logic steps are
123        1. Connect to the network.
124        2. Run iperf traffic.
125
126        Args:
127            params: A dictionary with network info.
128        """
129        self.connect_to_wifi_network(network)
130        self.run_iperf_client(network)
131
132    """Tests"""
133
134    @test_tracker_info(uuid="a57cc861-b6c2-47e4-9db6-7a3ab32c6e20")
135    def test_iot_connection_to_ubiquity_ap1_2g(self):
136        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
137        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
138
139    @test_tracker_info(uuid="2065c2f7-2b89-4da7-a15d-e5dc17b88d52")
140    def test_iot_connection_to_ubiquity_ap1_5g(self):
141        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
142        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
143
144    @test_tracker_info(uuid="6870e35b-f7a7-45bf-b021-fea049ae53de")
145    def test_iot_connection_to_AirportExpress_2G(self):
146        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
147        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
148
149    @test_tracker_info(uuid="95f4b405-79d7-4873-a152-4384acc88f41")
150    def test_iot_connection_to_AirportExpress_5G(self):
151        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
152        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
153
154    @test_tracker_info(uuid="02a8cc75-6781-4153-8d90-bed7568a1e78")
155    def test_iot_connection_to_AirportExtreme_2G(self):
156        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
157        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
158
159    @test_tracker_info(uuid="83a42c97-1358-4ba7-bdb2-238fdb1c945e")
160    def test_iot_connection_to_AirportExtreme_5G(self):
161        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
162        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
163
164    @test_tracker_info(uuid="d56cc46a-f772-4c96-b84e-4e05c82f5f9d")
165    def test_iot_connection_to_AirportExtremeOld_2G(self):
166        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
167        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
168
169    @test_tracker_info(uuid="4b57277d-ea96-4379-bd71-8b4f03253ec8")
170    def test_iot_connection_to_AirportExtremeOld_5G(self):
171        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
172        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
173
174    @test_tracker_info(uuid="2503d9ed-35df-4be0-b838-590324cecaee")
175    def iot_connection_to_Dlink_AC1200_2G(self):
176        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
177        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
178
179    @test_tracker_info(uuid="0a44e148-a4bf-43f4-88eb-e4c1ffa850ce")
180    def iot_connection_to_Dlink_AC1200_5G(self):
181        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
182        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
183
184    @test_tracker_info(uuid="6bd77417-089f-4fb1-b4c2-2cd673c64bcb")
185    def test_iot_connection_to_Dlink_AC3200_2G(self):
186        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
187        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
188
189    @test_tracker_info(uuid="9fbff6e7-36c8-4342-9c29-bce6a8ef04ec")
190    def test_iot_connection_to_Dlink_AC3200_5G_1(self):
191        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
192        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
193
194    @test_tracker_info(uuid="bfccdaa9-8e01-488c-9768-8c71ab5ec157")
195    def test_iot_connection_to_Dlink_AC3200_5G_2(self):
196        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
197        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
198
199    @test_tracker_info(uuid="0e4978de-0435-4856-ae5a-c39cc64e375b")
200    def test_iot_connection_to_Dlink_N750_2G(self):
201        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
202        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
203
204    @test_tracker_info(uuid="cdb82797-9981-4ba6-8958-025f59c60e83")
205    def test_iot_connection_to_Dlink_N750_5G(self):
206        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
207        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
208
209    @test_tracker_info(uuid="0bf8f129-eb96-4b1e-94bd-8dd93e8731e3")
210    def iot_connection_to_Linksys_E800_2G(self):
211        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
212        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
213
214    @test_tracker_info(uuid="f231216d-6ab6-46b7-a0a5-1ac15935e412")
215    def test_iot_connection_to_Linksys_AC1900_2G(self):
216        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
217        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
218
219    @test_tracker_info(uuid="5acd4bec-b210-4b4c-8b2c-60f3f67798a9")
220    def test_iot_connection_to_Linksys_AC1900_5G(self):
221        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
222        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
223
224    @test_tracker_info(uuid="f4fd9877-b13f-47b0-9523-1ce363200c2f")
225    def iot_connection_to_Linksys_AC2400_2g(self):
226        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
227        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
228
229    @test_tracker_info(uuid="438d679a-4f6c-476d-9eba-63b6f1f2bef4")
230    def iot_connection_to_Linksys_AC2400_5g(self):
231        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
232        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
233
234    @test_tracker_info(uuid="b9bc00d8-46c5-4c5e-bd58-93ab1ca8d53b")
235    def iot_connection_to_NETGEAR_AC1900_2G(self):
236        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
237        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
238
239    @test_tracker_info(uuid="fb4c7d80-4c12-4b08-a40a-2745e2bd167b")
240    def iot_connection_to_NETGEAR_AC1900_5G(self):
241        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
242        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
243
244    @test_tracker_info(uuid="054d2ffc-97fd-4613-bf47-acedd0fa4701")
245    def test_iot_connection_to_NETGEAR_AC3200_2G(self):
246        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
247        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
248
249    @test_tracker_info(uuid="d15a789a-def5-4c6a-b59e-1a75f73cc6a9")
250    def test_iot_connection_to_NETGEAR_AC3200_5G_1(self):
251        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
252        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
253
254    @test_tracker_info(uuid="1de6369e-97da-479f-b17c-9144bb814f51")
255    def test_iot_connection_to_NETGEAR_AC3200_5G_2(self):
256        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
257        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
258
259    @test_tracker_info(uuid="008ec18e-fd48-4359-8a0d-223c921a1faa")
260    def iot_connection_to_NETGEAR_N300_2G(self):
261        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
262        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
263
264    @test_tracker_info(uuid="c61eeaf0-af02-46bf-bcec-871e2f9dee71")
265    def iot_connection_to_WNDR4500v2_AES_2G(self):
266        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
267        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
268
269    @test_tracker_info(uuid="dcad3474-4022-48bc-8529-07321611b616")
270    def iot_connection_to_WNDR4500v2_WEP_SHARED128_5G(self):
271        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
272        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
273
274    @test_tracker_info(uuid="3573a880-4542-4dea-9909-aa2f9865a059")
275    def iot_connection_to_ARCHER_WEP_OPEN_64_2G(self):
276        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
277        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
278
279    @test_tracker_info(uuid="9c15c52e-945a-4b9b-bf0e-5bd6293dad1c")
280    def iot_connection_to_ARCHER_WEP_OPEN_128_5G(self):
281        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
282        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
283
284    @test_tracker_info(uuid="e5517b82-c225-449d-83ac-055a561a764f")
285    def test_iot_connection_to_TP_LINK_AC1700_2G(self):
286        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
287        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
288
289    @test_tracker_info(uuid="9531d3cc-129d-4501-a5e3-d7502120cd8b")
290    def test_iot_connection_to_TP_LINK_AC1700_5G(self):
291        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
292        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
293
294    @test_tracker_info(uuid="eab810d4-8e07-49c9-86c1-cb8d1a0285d0")
295    def iot_connection_to_TP_LINK_N300_2G(self):
296        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
297        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
298
299    @test_tracker_info(uuid="05d4cb25-a58d-46b4-a5ff-6e3fe28f2b16")
300    def iot_connection_to_fritz_7490_5g(self):
301        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
302        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
303
304    @test_tracker_info(uuid="8333e5e6-72fd-4957-bab0-fa45ce1d765a")
305    def iot_connection_to_NETGEAR_R8500_2G(self):
306        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
307        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
308
309    @test_tracker_info(uuid="c88053fb-730f-4447-a802-1fb9721f69df")
310    def iot_connection_to_NETGEAR_R8500_5G1(self):
311        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
312        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
313
314    @test_tracker_info(uuid="f5d1e44b-396b-4976-bb0c-160bdce89a59")
315    def iot_connection_to_NETGEAR_R8500_5G2(self):
316        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
317        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
318
319    @test_tracker_info(uuid="7c12f943-d9e2-45b1-aa84-fcb43efbbb04")
320    def test_iot_connection_to_TP_LINK_5504_2G(self):
321        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
322        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
323
324    @test_tracker_info(uuid="52be6b76-5e43-4289-83e1-4cd0d995d39b")
325    def test_iot_connection_to_TP_LINK_5504_5G_1(self):
326        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
327        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
328
329    @test_tracker_info(uuid="0b43d1da-e207-443d-b16c-c4ee3e924036")
330    def test_iot_connection_to_TP_LINK_5504_5G_2(self):
331        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
332        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
333
334    @test_tracker_info(uuid="4adcef5c-589a-4398-a28c-28a56d762f72")
335    def test_iot_connection_to_TP_LINK_C2600_2G(self):
336        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
337        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
338
339    @test_tracker_info(uuid="3955a443-505b-4015-9daa-f52abbad8377")
340    def test_iot_connection_to_TP_LINK_C2600_5G(self):
341        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
342        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
343
344    @test_tracker_info(uuid="3e9115dd-adb6-40a4-9831-dca8f1f32abe")
345    def test_iot_connection_to_Linksys06832_2G(self):
346        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
347        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
348
349    @test_tracker_info(uuid="5dca028a-7384-444f-b231-973054afe215")
350    def test_iot_connection_to_Linksys06832_5G(self):
351        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
352        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
353
354    @test_tracker_info(uuid="e639f6db-ad8e-4b4f-91f3-10acdf93142a")
355    def test_iot_connection_to_AmpedAthena_2G(self):
356        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
357        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
358
359    @test_tracker_info(uuid="3dd90d80-952f-4f17-a48a-fe42e7d6e1ff")
360    def test_iot_connection_to_AmpedAthena_5G(self):
361        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
362        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
363
364    @test_tracker_info(uuid="b9babe3a-ecba-4c5c-bc6b-0ba48c744e66")
365    def test_iot_connection_to_ASUS_AC3100_2G(self):
366        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
367        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
368
369    @test_tracker_info(uuid="f8f06f92-821d-4e80-8f1e-efb6c6adc12a")
370    def test_iot_connection_to_ASUS_AC3100_5G(self):
371        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
372        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
373
374    @test_tracker_info(uuid="f4d227df-1151-469a-b01c-f4b1c1f7a84b")
375    def iot_connection_to_NETGEAR_WGR614_2G(self):
376        ssid_key = self.current_test_name.replace(self.iot_test_prefix, "")
377        self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key])
378