blob: 57ecbb05321d5162468753eece35ec68bc83ca00 [file] [log] [blame]
Hayden Nix3f2eebf2020-01-14 10:39:21 -08001#!/usr/bin/env python3
2#
3# Copyright 2020 - 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
Hayden Nixc8a02bf2020-04-14 19:12:34 +000017import json
18import os
19import time
Hayden Nix3f2eebf2020-01-14 10:39:21 -080020
Hayden Nixc8a02bf2020-04-14 19:12:34 +000021from statistics import pstdev
22
23from bokeh.models import FixedTicker
24from bokeh.plotting import ColumnDataSource
25from bokeh.plotting import figure
26from bokeh.plotting import output_file
27from bokeh.plotting import save
28
29from acts import asserts
30from acts import context
Hayden Nix3f2eebf2020-01-14 10:39:21 -080031from acts import utils
Hayden Nix3f2eebf2020-01-14 10:39:21 -080032from acts.controllers.ap_lib import hostapd_config
Hayden Nixc8a02bf2020-04-14 19:12:34 +000033from acts.controllers.ap_lib import hostapd_constants
34from acts.controllers.ap_lib.hostapd_security import Security
35from acts.controllers.iperf_server import IPerfResult
Xianyuan Jia24299b72020-10-21 13:52:47 -070036from acts_contrib.test_utils.abstract_devices.utils_lib import wlan_utils
37from acts_contrib.test_utils.abstract_devices.wlan_device import create_wlan_device
38from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest
Hayden Nix3f2eebf2020-01-14 10:39:21 -080039
40N_CAPABILITIES_DEFAULT = [
41 hostapd_constants.N_CAPABILITY_LDPC, hostapd_constants.N_CAPABILITY_SGI20,
42 hostapd_constants.N_CAPABILITY_SGI40,
43 hostapd_constants.N_CAPABILITY_TX_STBC,
44 hostapd_constants.N_CAPABILITY_RX_STBC1
45]
46
47AC_CAPABILITIES_DEFAULT = [
48 hostapd_constants.AC_CAPABILITY_MAX_MPDU_11454,
49 hostapd_constants.AC_CAPABILITY_RXLDPC,
50 hostapd_constants.AC_CAPABILITY_SHORT_GI_80,
51 hostapd_constants.AC_CAPABILITY_TX_STBC_2BY1,
52 hostapd_constants.AC_CAPABILITY_RX_STBC_1,
53 hostapd_constants.AC_CAPABILITY_MAX_A_MPDU_LEN_EXP7,
54 hostapd_constants.AC_CAPABILITY_RX_ANTENNA_PATTERN,
55 hostapd_constants.AC_CAPABILITY_TX_ANTENNA_PATTERN
56]
57
Hayden Nixc8a02bf2020-04-14 19:12:34 +000058DEFAULT_MIN_THROUGHPUT = 0
59DEFAULT_MAX_STD_DEV = 1
Hayden Nix3f2eebf2020-01-14 10:39:21 -080060
Hayden Nixc8a02bf2020-04-14 19:12:34 +000061DEFAULT_TIME_TO_WAIT_FOR_IP_ADDR = 30
62GRAPH_CIRCLE_SIZE = 10
63IPERF_NO_THROUGHPUT_VALUE = 0
64MAX_2_4_CHANNEL = 14
65TIME_TO_SLEEP_BETWEEN_RETRIES = 1
Hayden Nix484f48c2020-04-14 20:54:17 +000066TIME_TO_WAIT_FOR_COUNTRY_CODE = 10
Hayden Nixc8a02bf2020-04-14 19:12:34 +000067WEP_HEX_STRING_LENGTH = 10
Hayden Nix3f2eebf2020-01-14 10:39:21 -080068
Hayden Nix7a69a4d2020-08-05 18:42:27 +000069MEGABITS_PER_SECOND = 'Mbps'
70
Hayden Nix3f2eebf2020-01-14 10:39:21 -080071
Hayden Nixc8a02bf2020-04-14 19:12:34 +000072def get_test_name(settings):
73 """Retrieves the test_name value from test_settings"""
74 return settings.get('test_name')
Hayden Nix3f2eebf2020-01-14 10:39:21 -080075
76
77class ChannelSweepTest(WifiBaseTest):
Hayden Nix484f48c2020-04-14 20:54:17 +000078 """Tests channel performance and regulatory compliance..
Hayden Nix3f2eebf2020-01-14 10:39:21 -080079
80 Testbed Requirement:
81 * One ACTS compatible device (dut)
82 * One Access Point
Hayden Nixc8a02bf2020-04-14 19:12:34 +000083 * One Linux Machine used as IPerfServer if running performance tests
84 Note: Performance tests should be done in isolated testbed.
Hayden Nix3f2eebf2020-01-14 10:39:21 -080085 """
86 def __init__(self, controllers):
87 WifiBaseTest.__init__(self, controllers)
Hayden Nixc8a02bf2020-04-14 19:12:34 +000088 if 'channel_sweep_test_params' in self.user_params:
89 self.time_to_wait_for_ip_addr = self.user_params[
90 'channel_sweep_test_params'].get(
91 'time_to_wait_for_ip_addr',
92 DEFAULT_TIME_TO_WAIT_FOR_IP_ADDR)
93 else:
94 self.time_to_wait_for_ip_addr = DEFAULT_TIME_TO_WAIT_FOR_IP_ADDR
Hayden Nix3f2eebf2020-01-14 10:39:21 -080095
96 def setup_class(self):
97 super().setup_class()
98 if 'dut' in self.user_params:
99 if self.user_params['dut'] == 'fuchsia_devices':
100 self.dut = create_wlan_device(self.fuchsia_devices[0])
101 elif self.user_params['dut'] == 'android_devices':
102 self.dut = create_wlan_device(self.android_devices[0])
103 else:
104 raise ValueError('Invalid DUT specified in config. (%s)' %
105 self.user_params['dut'])
106 else:
107 # Default is an android device, just like the other tests
108 self.dut = create_wlan_device(self.android_devices[0])
109
110 self.android_devices = getattr(self, 'android_devices', [])
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000111
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800112 self.access_point = self.access_points[0]
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000113 self.iperf_server = self.iperf_servers[0]
114 self.iperf_server.start()
115 self.iperf_client = self.iperf_clients[0]
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800116 self.access_point.stop_all_aps()
117
118 def setup_test(self):
Hayden Nix484f48c2020-04-14 20:54:17 +0000119 # TODO(fxb/46417): Uncomment when wlanClearCountry is implemented up any
120 # country code changes.
121 # for fd in self.fuchsia_devices:
122 # phy_ids_response = fd.wlan_lib.wlanPhyIdList()
123 # if phy_ids_response.get('error'):
124 # raise ConnectionError(
125 # 'Failed to retrieve phy ids from FuchsiaDevice (%s). '
126 # 'Error: %s' % (fd.ip, phy_ids_response['error']))
127 # for id in phy_ids_response['result']:
128 # clear_country_response = fd.wlan_lib.wlanClearCountry(id)
129 # if clear_country_response.get('error'):
130 # raise EnvironmentError(
131 # 'Failed to reset country code on FuchsiaDevice (%s). '
132 # 'Error: %s' % (fd.ip, clear_country_response['error'])
133 # )
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000134 self.access_point.stop_all_aps()
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800135 for ad in self.android_devices:
136 ad.droid.wakeLockAcquireBright()
137 ad.droid.wakeUpNow()
138 self.dut.wifi_toggle_state(True)
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000139 self.dut.disconnect()
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800140
141 def teardown_test(self):
142 for ad in self.android_devices:
143 ad.droid.wakeLockRelease()
144 ad.droid.goToSleepNow()
145 self.dut.turn_location_off_and_scan_toggle_off()
146 self.dut.disconnect()
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800147 self.access_point.stop_all_aps()
148
149 def on_fail(self, test_name, begin_time):
150 self.dut.take_bug_report(test_name, begin_time)
151 self.dut.get_log(test_name, begin_time)
152
Hayden Nix484f48c2020-04-14 20:54:17 +0000153 def set_dut_country_code(self, country_code):
154 """Set the country code on the DUT. Then verify that the country
155 code was set successfully
156
157 Args:
158 country_code: string, the 2 character country code to set
159 """
160 self.log.info('Setting DUT country code to %s' % country_code)
161 country_code_response = self.dut.device.regulatory_region_lib.setRegion(
162 country_code)
163 if country_code_response.get('error'):
164 raise EnvironmentError(
165 'Failed to set country code (%s) on DUT. Error: %s' %
166 (country_code, country_code_response['error']))
167
168 self.log.info('Verifying DUT country code was correctly set to %s.' %
169 country_code)
170 phy_ids_response = self.dut.device.wlan_lib.wlanPhyIdList()
171 if phy_ids_response.get('error'):
172 raise ConnectionError('Failed to get phy ids from DUT. Error: %s' %
173 (country_code, phy_ids_response['error']))
174
175 end_time = time.time() + TIME_TO_WAIT_FOR_COUNTRY_CODE
176 while time.time() < end_time:
177 for id in phy_ids_response['result']:
178 get_country_response = self.dut.device.wlan_lib.wlanGetCountry(
179 id)
180 if get_country_response.get('error'):
181 raise ConnectionError(
182 'Failed to query PHY ID (%s) for country. Error: %s' %
183 (id, get_country_response['error']))
184
185 set_code = ''.join([
186 chr(ascii_char)
187 for ascii_char in get_country_response['result']
188 ])
189 if set_code != country_code:
190 self.log.debug(
191 'PHY (id: %s) has incorrect country code set. '
192 'Expected: %s, Got: %s' % (id, country_code, set_code))
193 break
194 else:
195 self.log.info('All PHYs have expected country code (%s)' %
196 country_code)
197 break
198 time.sleep(TIME_TO_SLEEP_BETWEEN_RETRIES)
199 else:
200 raise EnvironmentError('Failed to set DUT country code to %s.' %
201 country_code)
202
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000203 def setup_ap(self, channel, channel_bandwidth, security_profile=None):
204 """Start network on AP with basic configuration.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800205
206 Args:
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000207 channel: int, channel to use for network
208 channel_bandwidth: int, channel bandwidth in mhz to use for network,
209 security_profile: Security object, or None if open
210
211 Returns:
212 string, ssid of network running
213
214 Raises:
215 ConnectionError if network is not started successfully.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800216 """
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000217 if channel > MAX_2_4_CHANNEL:
218 vht_bandwidth = channel_bandwidth
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800219 else:
220 vht_bandwidth = None
221
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000222 if channel_bandwidth == hostapd_constants.CHANNEL_BANDWIDTH_20MHZ:
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800223 n_capabilities = N_CAPABILITIES_DEFAULT + [
224 hostapd_constants.N_CAPABILITY_HT20
225 ]
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000226 elif (channel_bandwidth == hostapd_constants.CHANNEL_BANDWIDTH_40MHZ or
227 channel_bandwidth == hostapd_constants.CHANNEL_BANDWIDTH_80MHZ):
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800228 if hostapd_config.ht40_plus_allowed(channel):
229 extended_channel = [hostapd_constants.N_CAPABILITY_HT40_PLUS]
230 elif hostapd_config.ht40_minus_allowed(channel):
231 extended_channel = [hostapd_constants.N_CAPABILITY_HT40_MINUS]
232 else:
233 raise ValueError('Invalid Channel: %s' % channel)
234 n_capabilities = N_CAPABILITIES_DEFAULT + extended_channel
235 else:
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000236 raise ValueError('Invalid Bandwidth: %s' % channel_bandwidth)
237 ssid = utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G)
238 try:
239 wlan_utils.setup_ap(access_point=self.access_point,
240 profile_name='whirlwind',
241 channel=channel,
242 security=security_profile,
243 n_capabilities=n_capabilities,
244 ac_capabilities=None,
245 force_wmm=True,
246 ssid=ssid,
247 vht_bandwidth=vht_bandwidth,
248 setup_bridge=True)
249 except Exception as err:
250 raise ConnectionError(
251 'Failed to setup ap on channel: %s, channel bandwidth: %smhz. '
252 'Error: %s' % (channel, channel_bandwidth, err))
253 else:
254 self.log.info(
255 'Network (ssid: %s) up on channel %s w/ channel bandwidth %smhz'
256 % (ssid, channel, channel_bandwidth))
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800257
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000258 return ssid
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800259
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000260 def get_and_verify_iperf_address(self, channel, device, interface=None):
261 """Get ip address from a devices interface and verify it belongs to
262 expected subnet based on APs DHCP config.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800263
264 Args:
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000265 channel: int, channel network is running on, to determine subnet
266 device: device to get ip address for
267 interface (default: None): interface on device to get ip address.
268 If None, uses device.test_interface.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800269
270 Returns:
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000271 String, ip address of device on given interface (or test_interface)
272
273 Raises:
274 ConnectionError, if device does not have a valid ip address after
275 all retries.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800276 """
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000277 if channel <= MAX_2_4_CHANNEL:
278 subnet = self.access_point._AP_2G_SUBNET_STR
279 else:
280 subnet = self.access_point._AP_5G_SUBNET_STR
281 end_time = time.time() + self.time_to_wait_for_ip_addr
282 while time.time() < end_time:
283 if interface:
284 device_addresses = device.get_interface_ip_addresses(interface)
285 else:
286 device_addresses = device.get_interface_ip_addresses(
287 device.test_interface)
288
289 if device_addresses['ipv4_private']:
290 for ip_addr in device_addresses['ipv4_private']:
291 if utils.ip_in_subnet(ip_addr, subnet):
292 return ip_addr
293 else:
294 self.log.debug(
295 'Device has an ip address (%s), but it is not in '
296 'subnet %s' % (ip_addr, subnet))
297 else:
298 self.log.debug(
299 'Device does not have a valid ip address. Retrying.')
300 time.sleep(TIME_TO_SLEEP_BETWEEN_RETRIES)
301 raise ConnectionError('Device failed to get an ip address.')
302
303 def get_iperf_throughput(self,
304 iperf_server_address,
305 iperf_client_address,
306 reverse=False):
307 """Run iperf between client and server and get the throughput.
308
309 Args:
310 iperf_server_address: string, ip address of running iperf server
311 iperf_client_address: string, ip address of iperf client (dut)
312 reverse (default: False): If True, run traffic in reverse direction,
313 from server to client.
314
315 Returns:
316 int, iperf throughput OR IPERF_NO_THROUGHPUT_VALUE, if iperf fails
317 """
318 if reverse:
319 self.log.info(
320 'Running IPerf traffic from server (%s) to dut (%s).' %
321 (iperf_server_address, iperf_client_address))
322 iperf_results_file = self.iperf_client.start(
323 iperf_server_address, '-i 1 -t 10 -R -J', 'channel_sweep_rx')
324 else:
325 self.log.info(
326 'Running IPerf traffic from dut (%s) to server (%s).' %
327 (iperf_client_address, iperf_server_address))
328 iperf_results_file = self.iperf_client.start(
329 iperf_server_address, '-i 1 -t 10 -J', 'channel_sweep_tx')
330 if iperf_results_file:
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000331 iperf_results = IPerfResult(
332 iperf_results_file, reporting_speed_units=MEGABITS_PER_SECOND)
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000333 return iperf_results.avg_send_rate
334 else:
335 return IPERF_NO_THROUGHPUT_VALUE
336
337 def log_to_file_and_throughput_data(self, channel, channel_bandwidth,
338 tx_throughput, rx_throughput):
339 """Write performance info to csv file and to throughput data.
340
341 Args:
342 channel: int, channel that test was run on
343 channel_bandwidth: int, channel bandwidth the test used
344 tx_throughput: float, throughput value from dut to iperf server
345 rx_throughput: float, throughput value from iperf server to dut
346 """
347 test_name = self.throughput_data['test']
348 output_path = context.get_current_context().get_base_output_path()
349 log_path = '%s/ChannelSweepTest/%s' % (output_path, test_name)
350 if not os.path.exists(log_path):
351 os.makedirs(log_path)
352 log_file = '%s/%s_%smhz.csv' % (log_path, test_name, channel_bandwidth)
353 self.log.info('Writing IPerf results for %s to %s' %
354 (test_name, log_file))
355 with open(log_file, 'a') as csv_file:
356 csv_file.write('%s,%s,%s\n' %
357 (channel, tx_throughput, rx_throughput))
358 self.throughput_data['results'][str(channel)] = {
359 'tx_throughput': tx_throughput,
360 'rx_throughput': rx_throughput
361 }
362
363 def write_graph(self):
364 """Create graph html files from throughput data, plotting channel vs
365 tx_throughput and channel vs rx_throughput.
366 """
367 output_path = context.get_current_context().get_base_output_path()
368 test_name = self.throughput_data['test']
369 channel_bandwidth = self.throughput_data['channel_bandwidth']
370 output_file_name = '%s/ChannelSweepTest/%s/%s_%smhz.html' % (
371 output_path, test_name, test_name, channel_bandwidth)
372 output_file(output_file_name)
373 channels = []
374 tx_throughputs = []
375 rx_throughputs = []
376 for channel in self.throughput_data['results']:
377 channels.append(str(channel))
378 tx_throughputs.append(
379 self.throughput_data['results'][channel]['tx_throughput'])
380 rx_throughputs.append(
381 self.throughput_data['results'][channel]['rx_throughput'])
382 channel_vs_throughput_data = ColumnDataSource(
383 data=dict(channels=channels,
384 tx_throughput=tx_throughputs,
385 rx_throughput=rx_throughputs))
386 TOOLTIPS = [('Channel', '@channels'),
387 ('TX_Throughput', '@tx_throughput'),
388 ('RX_Throughput', '@rx_throughput')]
389 channel_vs_throughput_graph = figure(title='Channels vs. Throughput',
390 x_axis_label='Channels',
391 x_range=channels,
392 y_axis_label='Throughput',
393 tooltips=TOOLTIPS)
394 channel_vs_throughput_graph.sizing_mode = 'stretch_both'
395 channel_vs_throughput_graph.title.align = 'center'
396 channel_vs_throughput_graph.line('channels',
397 'tx_throughput',
398 source=channel_vs_throughput_data,
399 line_width=2,
400 line_color='blue',
401 legend_label='TX_Throughput')
402 channel_vs_throughput_graph.circle('channels',
403 'tx_throughput',
404 source=channel_vs_throughput_data,
405 size=GRAPH_CIRCLE_SIZE,
406 color='blue')
407 channel_vs_throughput_graph.line('channels',
408 'rx_throughput',
409 source=channel_vs_throughput_data,
410 line_width=2,
411 line_color='red',
412 legend_label='RX_Throughput')
413 channel_vs_throughput_graph.circle('channels',
414 'rx_throughput',
415 source=channel_vs_throughput_data,
416 size=GRAPH_CIRCLE_SIZE,
417 color='red')
418
419 channel_vs_throughput_graph.legend.location = "top_left"
420 graph_file = save([channel_vs_throughput_graph])
421 self.log.info('Saved graph to %s' % graph_file)
422
423 def verify_standard_deviation(self, max_std_dev):
424 """Verifies the standard deviation of the throughput across the channels
425 does not exceed the max_std_dev value.
426
427 Args:
428 max_std_dev: float, max standard deviation of throughput for a test
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000429 to pass (in Mb/s)
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000430
431 Raises:
432 TestFailure, if standard deviation of throughput exceeds max_std_dev
433 """
434 self.log.info('Verifying standard deviation across channels does not '
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000435 'exceed max standard deviation of %s Mb/s' % max_std_dev)
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000436 tx_values = []
437 rx_values = []
438 for channel in self.throughput_data['results']:
439 if self.throughput_data['results'][channel][
440 'tx_throughput'] is not None:
441 tx_values.append(
442 self.throughput_data['results'][channel]['tx_throughput'])
443 if self.throughput_data['results'][channel][
444 'rx_throughput'] is not None:
445 rx_values.append(
446 self.throughput_data['results'][channel]['rx_throughput'])
447 tx_std_dev = pstdev(tx_values)
448 rx_std_dev = pstdev(rx_values)
449 if tx_std_dev > max_std_dev or rx_std_dev > max_std_dev:
450 asserts.fail(
451 'With %smhz channel bandwidth, throughput standard '
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000452 'deviation (tx: %s Mb/s, rx: %s Mb/s) exceeds max standard '
453 'deviation (%s Mb/s).' %
Hayden Nix484f48c2020-04-14 20:54:17 +0000454 (self.throughput_data['channel_bandwidth'], tx_std_dev,
455 rx_std_dev, max_std_dev))
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000456 else:
457 asserts.explicit_pass(
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000458 'Throughput standard deviation (tx: %s Mb/s, rx: %s Mb/s) '
459 'with %smhz channel bandwidth does not exceed maximum (%s Mb/s).'
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000460 % (tx_std_dev, rx_std_dev,
461 self.throughput_data['channel_bandwidth'], max_std_dev))
462
463 def run_channel_performance_tests(self, settings):
464 """Test function for running channel performance tests. Used by both
465 explicit test cases and debug test cases from config. Runs a performance
466 test for each channel in test_channels with test_channel_bandwidth, then
467 writes a graph and csv file of the channel vs throughput.
468
469 Args:
470 settings: dict, containing the following test settings
471 test_channels: list of channels to test.
472 test_channel_bandwidth: int, channel bandwidth to use for test.
473 test_security (optional): string, security type to use for test.
474 min_tx_throughput (optional, default: 0): float, minimum tx
475 throughput threshold to pass individual channel tests
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000476 (in Mb/s).
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000477 min_rx_throughput (optional, default: 0): float, minimum rx
478 throughput threshold to pass individual channel tests
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000479 (in Mb/s).
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000480 max_std_dev (optional, default: 1): float, maximum standard
481 deviation of throughput across all test channels to pass
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000482 test (in Mb/s).
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000483 base_test_name (optional): string, test name prefix to use with
484 generated subtests.
Hayden Nix484f48c2020-04-14 20:54:17 +0000485 country_name (optional): string, country name from
486 hostapd_constants to set on device.
487 country_code (optional): string, two-char country code to set on
488 the DUT. Takes priority over country_name.
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000489 test_name (debug tests only): string, the test name for this
490 parent test case from the config file. In explicit tests,
491 this is not necessary.
492
493 Writes:
494 CSV file: channel, tx_throughput, rx_throughput
495 for every test channel.
496 Graph: channel vs tx_throughput & channel vs rx_throughput
497
498 Raises:
499 TestFailure, if throughput standard deviation across channels
500 exceeds max_std_dev
501
502 Example Explicit Test (see EOF for debug JSON example):
503 def test_us_2g_20mhz_wpa2(self):
504 self.run_channel_performance_tests(
505 dict(
506 test_channels=hostapd_constants.US_CHANNELS_2G,
507 test_channel_bandwidth=20,
508 test_security=hostapd_constants.WPA2_STRING,
509 min_tx_throughput=2,
510 min_rx_throughput=4,
511 max_std_dev=0.75,
Hayden Nix484f48c2020-04-14 20:54:17 +0000512 country_code='US',
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000513 base_test_name='test_us'))
514 """
515 test_channels = settings['test_channels']
516 test_channel_bandwidth = settings['test_channel_bandwidth']
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000517 test_security = settings.get('test_security', None)
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000518 test_name = settings.get('test_name', self.test_name)
519 base_test_name = settings.get('base_test_name', 'test')
520 min_tx_throughput = settings.get('min_tx_throughput',
521 DEFAULT_MIN_THROUGHPUT)
522 min_rx_throughput = settings.get('min_rx_throughput',
523 DEFAULT_MIN_THROUGHPUT)
524 max_std_dev = settings.get('max_std_dev', DEFAULT_MAX_STD_DEV)
Hayden Nix484f48c2020-04-14 20:54:17 +0000525 country_code = settings.get('country_code')
526 country_name = settings.get('country_name')
527 country_label = None
528
529 if country_code:
530 country_label = country_code
531 self.set_dut_country_code(country_code)
532 elif country_name:
533 country_label = country_name
534 code = hostapd_constants.COUNTRY_CODE[country_name]['country_code']
535 self.set_dut_country_code(code)
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000536
537 self.throughput_data = {
538 'test': test_name,
539 'channel_bandwidth': test_channel_bandwidth,
540 'results': {}
541 }
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800542 test_list = []
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000543 for channel in test_channels:
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000544 sub_test_name = 'test_%schannel_%s_%smhz_%s_performance' % (
Hayden Nix484f48c2020-04-14 20:54:17 +0000545 '%s_' % country_label if country_label else '', channel,
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000546 test_channel_bandwidth,
547 test_security if test_security else 'open')
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000548 test_list.append({
549 'test_name': sub_test_name,
550 'channel': int(channel),
551 'channel_bandwidth': int(test_channel_bandwidth),
552 'security': test_security,
553 'min_tx_throughput': min_tx_throughput,
554 'min_rx_throughput': min_rx_throughput
555 })
556 self.run_generated_testcases(self.get_channel_performance,
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800557 settings=test_list,
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000558 name_func=get_test_name)
559 self.log.info('Channel tests completed.')
560 self.write_graph()
561 self.verify_standard_deviation(max_std_dev)
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800562
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000563 def get_channel_performance(self, settings):
564 """Run a single channel performance test and logs results to csv file
565 and throughput data. Run with generated sub test cases in
566 run_channel_performance_tests.
567
568 1. Sets up network with test settings
569 2. Associates DUT
570 3. Runs traffic between DUT and iperf server (both directions)
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000571 4. Logs channel, tx_throughput (Mb/s), and rx_throughput (Mb/s) to
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000572 log file and throughput data.
573 5. Checks throughput values against minimum throughput thresholds.
574
575 Args:
576 settings: see run_channel_performance_tests
577
578 Raises:
579 TestFailure, if throughput (either direction) is less than
580 the directions given minimum throughput threshold.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800581 """
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000582 channel = settings['channel']
583 channel_bandwidth = settings['channel_bandwidth']
584 security = settings['security']
585 test_name = settings['test_name']
586 min_tx_throughput = settings['min_tx_throughput']
587 min_rx_throughput = settings['min_rx_throughput']
588 if security:
589 if security == hostapd_constants.WEP_STRING:
590 password = utils.rand_hex_str(WEP_HEX_STRING_LENGTH)
591 else:
592 password = utils.rand_ascii_str(
593 hostapd_constants.MIN_WPA_PSK_LENGTH)
594 security_profile = Security(security_mode=security,
595 password=password)
596 else:
597 password = None
598 security_profile = None
599 ssid = self.setup_ap(channel, channel_bandwidth, security_profile)
600 associated = wlan_utils.associate(client=self.dut,
601 ssid=ssid,
602 password=password)
603 if not associated:
604 self.log_to_file_and_throughput_data(channel, channel_bandwidth,
605 None, None)
606 asserts.fail('Device failed to associate with network %s' % ssid)
607 self.log.info('DUT (%s) connected to network %s.' %
608 (self.dut.device.ip, ssid))
609 self.iperf_server.renew_test_interface_ip_address()
610 self.log.info(
611 'Getting ip address for iperf server. Will retry for %s seconds.' %
612 self.time_to_wait_for_ip_addr)
613 iperf_server_address = self.get_and_verify_iperf_address(
614 channel, self.iperf_server)
615 self.log.info(
616 'Getting ip address for DUT. Will retry for %s seconds.' %
617 self.time_to_wait_for_ip_addr)
618 iperf_client_address = self.get_and_verify_iperf_address(
619 channel, self.dut, self.iperf_client.test_interface)
620 tx_throughput = self.get_iperf_throughput(iperf_server_address,
621 iperf_client_address)
622 rx_throughput = self.get_iperf_throughput(iperf_server_address,
623 iperf_client_address,
624 reverse=True)
625 self.log_to_file_and_throughput_data(channel, channel_bandwidth,
626 tx_throughput, rx_throughput)
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000627 self.log.info('Throughput (tx, rx): (%s Mb/s, %s Mb/s), '
628 'Minimum threshold (tx, rx): (%s Mb/s, %s Mb/s)' %
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000629 (tx_throughput, rx_throughput, min_tx_throughput,
630 min_rx_throughput))
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000631 base_message = (
632 'Actual throughput (on channel: %s, channel bandwidth: '
633 '%s, security: %s)' % (channel, channel_bandwidth, security))
Hayden Nix484f48c2020-04-14 20:54:17 +0000634 if (tx_throughput < min_tx_throughput
635 or rx_throughput < min_rx_throughput):
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000636 asserts.fail('%s below the minimum threshold.' % base_message)
637 asserts.explicit_pass('%s above the minimum threshold.' % base_message)
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800638
Hayden Nix484f48c2020-04-14 20:54:17 +0000639 def verify_regulatory_compliance(self, settings):
640 """Test function for regulatory compliance tests. Verify device complies
641 with provided regulatory requirements.
642
643 Args:
644 settings: dict, containing the following test settings
645 test_channels: dict, mapping channels to a set of the channel
646 bandwidths to test (see example for using JSON). Defaults
647 to hostapd_constants.ALL_CHANNELS.
648 country_code: string, two-char country code to set on device
649 (prioritized over country_name)
650 country_name: string, country name from hostapd_constants to set
651 on device.
652 base_test_name (optional): string, test name prefix to use with
653 generatedsubtests.
654 test_name: string, the test name for this
655 parent test case from the config file. In explicit tests,
656 this is not necessary.
657 """
658 country_name = settings.get('country_name')
659 country_code = settings.get('country_code')
660 if not (country_code or country_name):
661 raise ValueError('No country code or name provided.')
662
663 test_channels = settings.get('test_channels',
664 hostapd_constants.ALL_CHANNELS)
665 allowed_channels = settings['allowed_channels']
666
667 base_test_name = settings.get('base_test_name', 'test_compliance')
668
669 if country_code:
670 code = country_code
671 else:
672 code = hostapd_constants.COUNTRY_CODE[country_name]['country_code']
673
674 self.set_dut_country_code(code)
675
676 test_list = []
677 for channel in test_channels:
678 for channel_bandwidth in test_channels[channel]:
679 sub_test_name = '%s_channel_%s_%smhz' % (
680 base_test_name, channel, channel_bandwidth)
Hayden Nix7a69a4d2020-08-05 18:42:27 +0000681 should_associate = (channel in allowed_channels
682 and channel_bandwidth
683 in allowed_channels[channel])
Hayden Nix484f48c2020-04-14 20:54:17 +0000684 # Note: these int conversions because when these tests are
685 # imported via JSON, they may be strings since the channels
686 # will be keys. This makes the json/list test_channels param
687 # behave exactly like the in code dict/set test_channels.
688 test_list.append({
689 'country_code': code,
690 'channel': int(channel),
691 'channel_bandwidth': int(channel_bandwidth),
692 'should_associate': should_associate,
693 'test_name': sub_test_name
694 })
695 self.run_generated_testcases(test_func=self.verify_channel_compliance,
696 settings=test_list,
697 name_func=get_test_name)
698
699 def verify_channel_compliance(self, settings):
700 """Verify device complies with provided regulatory requirements for a
701 specific channel and channel bandwidth. Run with generated test cases
702 in the verify_regulatory_compliance parent test.
703_
704 Args:
705 settings: see verify_regulatory_compliance`
706 """
707 channel = settings['channel']
708 channel_bandwidth = settings['channel_bandwidth']
709 code = settings['country_code']
710 should_associate = settings['should_associate']
711
712 ssid = self.setup_ap(channel, channel_bandwidth)
713
714 self.log.info(
715 'Attempting to associate with network (%s) on channel %s @ %smhz. '
716 'Expected behavior: %s' %
717 (ssid, channel, channel_bandwidth, 'Device should associate'
718 if should_associate else 'Device should NOT associate.'))
719
720 associated = wlan_utils.associate(client=self.dut, ssid=ssid)
721 if associated == should_associate:
722 asserts.explicit_pass(
723 'Device complied with %s regulatory requirement for channel %s '
724 ' with channel bandwidth %smhz. %s' %
725 (code, channel, channel_bandwidth,
726 'Associated.' if associated else 'Refused to associate.'))
727 else:
728 asserts.fail(
729 'Device failed compliance with regulatory domain %s for '
730 'channel %s with channel bandwidth %smhz. Expected: %s, Got: %s'
731 % (code, channel, channel_bandwidth, 'Should associate'
732 if should_associate else 'Should not associate',
733 'Associated' if associated else 'Did not associate'))
734
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000735 # Helper functions to allow explicit tests throughput and standard deviation
736 # thresholds to be passed in via config.
737 def _get_min_tx_throughput(self, test_name):
738 return self.user_params.get('channel_sweep_test_params',
739 {}).get(test_name,
740 {}).get('min_tx_throughput',
741 DEFAULT_MIN_THROUGHPUT)
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800742
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000743 def _get_min_rx_throughput(self, test_name):
744 return self.user_params.get('channel_sweep_test_params',
745 {}).get(test_name,
746 {}).get('min_rx_throughput',
747 DEFAULT_MIN_THROUGHPUT)
748
749 def _get_max_std_dev(self, test_name):
750 return self.user_params.get('channel_sweep_test_params',
751 {}).get(test_name,
752 {}).get('min_std_dev',
753 DEFAULT_MAX_STD_DEV)
754
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000755 # Channel Performance of US Channels: 570 Test Cases
756 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000757 def test_us_20mhz_open_channel_performance(self):
758 self.run_channel_performance_tests(
759 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
760 hostapd_constants.US_CHANNELS_5G,
761 test_channel_bandwidth=hostapd_constants.
762 CHANNEL_BANDWIDTH_20MHZ,
763 base_test_name=self.test_name,
764 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
765 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
766 max_std_dev=self._get_max_std_dev(self.test_name)))
767
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000768 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000769 def test_us_40mhz_open_channel_performance(self):
770 self.run_channel_performance_tests(
771 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
772 hostapd_constants.US_CHANNELS_5G[:-1],
773 test_channel_bandwidth=hostapd_constants.
774 CHANNEL_BANDWIDTH_40MHZ,
775 base_test_name=self.test_name,
776 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
777 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
778 max_std_dev=self._get_max_std_dev(self.test_name)))
779
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000780 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000781 def test_us_80mhz_open_channel_performance(self):
782 self.run_channel_performance_tests(
783 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
784 test_channel_bandwidth=hostapd_constants.
785 CHANNEL_BANDWIDTH_80MHZ,
786 base_test_name=self.test_name,
787 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
788 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
789 max_std_dev=self._get_max_std_dev(self.test_name)))
790
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000791 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000792 def test_us_20mhz_wep_channel_performance(self):
793 self.run_channel_performance_tests(
794 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
795 hostapd_constants.US_CHANNELS_5G,
796 test_channel_bandwidth=hostapd_constants.
797 CHANNEL_BANDWIDTH_20MHZ,
798 test_security=hostapd_constants.WEP_STRING,
799 base_test_name=self.test_name,
800 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
801 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
802 max_std_dev=self._get_max_std_dev(self.test_name)))
803
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000804 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000805 def test_us_40mhz_wep_channel_performance(self):
806 self.run_channel_performance_tests(
807 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
808 hostapd_constants.US_CHANNELS_5G[:-1],
809 test_channel_bandwidth=hostapd_constants.
810 CHANNEL_BANDWIDTH_40MHZ,
811 test_security=hostapd_constants.WEP_STRING,
812 base_test_name=self.test_name,
813 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
814 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
815 max_std_dev=self._get_max_std_dev(self.test_name)))
816
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000817 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000818 def test_us_80mhz_wep_channel_performance(self):
819 self.run_channel_performance_tests(
820 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
821 test_channel_bandwidth=hostapd_constants.
822 CHANNEL_BANDWIDTH_80MHZ,
823 test_security=hostapd_constants.WEP_STRING,
824 base_test_name=self.test_name,
825 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
826 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
827 max_std_dev=self._get_max_std_dev(self.test_name)))
828
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000829 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000830 def test_us_20mhz_wpa_channel_performance(self):
831 self.run_channel_performance_tests(
832 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
833 hostapd_constants.US_CHANNELS_5G,
834 test_channel_bandwidth=hostapd_constants.
835 CHANNEL_BANDWIDTH_20MHZ,
836 test_security=hostapd_constants.WPA_STRING,
837 base_test_name=self.test_name,
838 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
839 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
840 max_std_dev=self._get_max_std_dev(self.test_name)))
841
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000842 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000843 def test_us_40mhz_wpa_channel_performance(self):
844 self.run_channel_performance_tests(
845 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
846 hostapd_constants.US_CHANNELS_5G[:-1],
847 test_channel_bandwidth=hostapd_constants.
848 CHANNEL_BANDWIDTH_40MHZ,
849 test_security=hostapd_constants.WPA_STRING,
850 base_test_name=self.test_name,
851 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
852 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
853 max_std_dev=self._get_max_std_dev(self.test_name)))
854
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000855 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000856 def test_us_80mhz_wpa_channel_performance(self):
857 self.run_channel_performance_tests(
858 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
859 test_channel_bandwidth=hostapd_constants.
860 CHANNEL_BANDWIDTH_80MHZ,
861 test_security=hostapd_constants.WPA_STRING,
862 base_test_name=self.test_name,
863 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
864 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
865 max_std_dev=self._get_max_std_dev(self.test_name)))
866
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000867 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000868 def test_us_20mhz_wpa2_channel_performance(self):
869 self.run_channel_performance_tests(
870 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
871 hostapd_constants.US_CHANNELS_5G,
872 test_channel_bandwidth=hostapd_constants.
873 CHANNEL_BANDWIDTH_20MHZ,
874 test_security=hostapd_constants.WPA2_STRING,
875 base_test_name=self.test_name,
876 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
877 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
878 max_std_dev=self._get_max_std_dev(self.test_name)))
879
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000880 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000881 def test_us_40mhz_wpa2_channel_performance(self):
882 self.run_channel_performance_tests(
883 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
884 hostapd_constants.US_CHANNELS_5G[:-1],
885 test_channel_bandwidth=hostapd_constants.
886 CHANNEL_BANDWIDTH_40MHZ,
887 test_security=hostapd_constants.WPA2_STRING,
888 base_test_name=self.test_name,
889 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
890 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
891 max_std_dev=self._get_max_std_dev(self.test_name)))
892
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000893 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000894 def test_us_80mhz_wpa2_channel_performance(self):
895 self.run_channel_performance_tests(
896 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
897 test_channel_bandwidth=hostapd_constants.
898 CHANNEL_BANDWIDTH_80MHZ,
899 test_security=hostapd_constants.WPA2_STRING,
900 base_test_name=self.test_name,
901 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
902 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
903 max_std_dev=self._get_max_std_dev(self.test_name)))
904
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000905 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000906 def test_us_20mhz_wpa_wpa2_channel_performance(self):
907 self.run_channel_performance_tests(
908 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
909 hostapd_constants.US_CHANNELS_5G,
910 test_channel_bandwidth=hostapd_constants.
911 CHANNEL_BANDWIDTH_20MHZ,
912 test_security=hostapd_constants.WPA_MIXED_STRING,
913 base_test_name=self.test_name,
914 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
915 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
916 max_std_dev=self._get_max_std_dev(self.test_name)))
917
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000918 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000919 def test_us_40mhz_wpa_wpa2_channel_performance(self):
920 self.run_channel_performance_tests(
921 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
922 hostapd_constants.US_CHANNELS_5G[:-1],
923 test_channel_bandwidth=hostapd_constants.
924 CHANNEL_BANDWIDTH_40MHZ,
925 test_security=hostapd_constants.WPA_MIXED_STRING,
926 base_test_name=self.test_name,
927 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
928 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
929 max_std_dev=self._get_max_std_dev(self.test_name)))
930
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000931 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000932 def test_us_80mhz_wpa_wpa2_channel_performance(self):
933 self.run_channel_performance_tests(
934 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
935 test_channel_bandwidth=hostapd_constants.
936 CHANNEL_BANDWIDTH_80MHZ,
937 test_security=hostapd_constants.WPA_MIXED_STRING,
938 base_test_name=self.test_name,
939 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
940 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
941 max_std_dev=self._get_max_std_dev(self.test_name)))
942
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000943 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000944 def test_us_20mhz_wpa3_channel_performance(self):
945 self.run_channel_performance_tests(
946 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
947 hostapd_constants.US_CHANNELS_5G,
948 test_channel_bandwidth=hostapd_constants.
949 CHANNEL_BANDWIDTH_20MHZ,
950 test_security=hostapd_constants.WPA3_STRING,
951 base_test_name=self.test_name,
952 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
953 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
954 max_std_dev=self._get_max_std_dev(self.test_name)))
955
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000956 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000957 def test_us_40mhz_wpa3_channel_performance(self):
958 self.run_channel_performance_tests(
959 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
960 hostapd_constants.US_CHANNELS_5G[:-1],
961 test_channel_bandwidth=hostapd_constants.
962 CHANNEL_BANDWIDTH_40MHZ,
963 test_security=hostapd_constants.WPA3_STRING,
964 base_test_name=self.test_name,
965 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
966 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
967 max_std_dev=self._get_max_std_dev(self.test_name)))
968
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000969 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000970 def test_us_80mhz_wpa3_channel_performance(self):
971 self.run_channel_performance_tests(
972 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
973 test_channel_bandwidth=hostapd_constants.
974 CHANNEL_BANDWIDTH_80MHZ,
975 test_security=hostapd_constants.WPA3_STRING,
976 base_test_name=self.test_name,
977 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
978 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
979 max_std_dev=self._get_max_std_dev(self.test_name)))
980
981 def test_channel_performance_debug(self):
982 """Run channel performance test cases from the ACTS config file.
983
984 Example:
985 "channel_sweep_test_params": {
986 "debug_channel_performance_tests": [
987 {
988 "test_name": "test_123_20mhz_wpa2_performance"
989 "test_channels": [1, 2, 3],
990 "test_channel_bandwidth": 20,
991 "test_security": "wpa2",
992 "base_test_name": "test_123_perf",
993 "min_tx_throughput": 1.1,
994 "min_rx_throughput": 3,
995 "max_std_dev": 0.5
996 },
997 ...
998 ]
999 }
1000
Hayden Nix3f2eebf2020-01-14 10:39:21 -08001001 """
Hayden Nixc8a02bf2020-04-14 19:12:34 +00001002 asserts.skip_if(
Hayden Nix7a69a4d2020-08-05 18:42:27 +00001003 'debug_channel_performance_tests'
1004 not in self.user_params.get('channel_sweep_test_params', {}),
Hayden Nixc8a02bf2020-04-14 19:12:34 +00001005 'No custom channel performance tests provided in config.')
1006 base_tests = self.user_params['channel_sweep_test_params'][
1007 'debug_channel_performance_tests']
1008 self.run_generated_testcases(self.run_channel_performance_tests,
1009 settings=base_tests,
1010 name_func=get_test_name)
Hayden Nix484f48c2020-04-14 20:54:17 +00001011
1012 def test_regulatory_compliance(self):
1013 """Run regulatory compliance test case from the ACTS config file.
1014 Note: only one country_name OR country_code is required.
1015
1016 Example:
1017 "channel_sweep_test_params": {
1018 "regulatory_compliance_tests": [
1019 {
1020 "test_name": "test_japan_compliance_1_13_36"
1021 "country_name": "JAPAN",
1022 "country_code": "JP",
1023 "test_channels": {
1024 "1": [20, 40], "13": [40], "36": [20, 40, 80]
1025 },
1026 "allowed_channels": {
1027 "1": [20, 40], "36": [20, 40, 80]
1028 },
1029 "base_test_name": "test_japan"
1030 },
1031 ...
1032 ]
1033 }
1034 """
1035 asserts.skip_if(
Hayden Nix7a69a4d2020-08-05 18:42:27 +00001036 'regulatory_compliance_tests'
1037 not in self.user_params.get('channel_sweep_test_params', {}),
Hayden Nix484f48c2020-04-14 20:54:17 +00001038 'No custom regulatory compliance tests provided in config.')
1039 base_tests = self.user_params['channel_sweep_test_params'][
1040 'regulatory_compliance_tests']
1041 self.run_generated_testcases(self.verify_regulatory_compliance,
1042 settings=base_tests,
1043 name_func=get_test_name)