blob: 6430da1c53e2905a432d1a1e1cf38b88e6f249eb [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
36from acts.test_utils.abstract_devices.utils_lib import wlan_utils
Hayden Nix3f2eebf2020-01-14 10:39:21 -080037from acts.test_utils.abstract_devices.wlan_device import create_wlan_device
Hayden Nix3f2eebf2020-01-14 10:39:21 -080038from acts.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 Nix3f2eebf2020-01-14 10:39:21 -080069
Hayden Nixc8a02bf2020-04-14 19:12:34 +000070def get_test_name(settings):
71 """Retrieves the test_name value from test_settings"""
72 return settings.get('test_name')
Hayden Nix3f2eebf2020-01-14 10:39:21 -080073
74
75class ChannelSweepTest(WifiBaseTest):
Hayden Nix484f48c2020-04-14 20:54:17 +000076 """Tests channel performance and regulatory compliance..
Hayden Nix3f2eebf2020-01-14 10:39:21 -080077
78 Testbed Requirement:
79 * One ACTS compatible device (dut)
80 * One Access Point
Hayden Nixc8a02bf2020-04-14 19:12:34 +000081 * One Linux Machine used as IPerfServer if running performance tests
82 Note: Performance tests should be done in isolated testbed.
Hayden Nix3f2eebf2020-01-14 10:39:21 -080083 """
84 def __init__(self, controllers):
85 WifiBaseTest.__init__(self, controllers)
Hayden Nixc8a02bf2020-04-14 19:12:34 +000086 if 'channel_sweep_test_params' in self.user_params:
87 self.time_to_wait_for_ip_addr = self.user_params[
88 'channel_sweep_test_params'].get(
89 'time_to_wait_for_ip_addr',
90 DEFAULT_TIME_TO_WAIT_FOR_IP_ADDR)
91 else:
92 self.time_to_wait_for_ip_addr = DEFAULT_TIME_TO_WAIT_FOR_IP_ADDR
Hayden Nix3f2eebf2020-01-14 10:39:21 -080093
94 def setup_class(self):
95 super().setup_class()
96 if 'dut' in self.user_params:
97 if self.user_params['dut'] == 'fuchsia_devices':
98 self.dut = create_wlan_device(self.fuchsia_devices[0])
99 elif self.user_params['dut'] == 'android_devices':
100 self.dut = create_wlan_device(self.android_devices[0])
101 else:
102 raise ValueError('Invalid DUT specified in config. (%s)' %
103 self.user_params['dut'])
104 else:
105 # Default is an android device, just like the other tests
106 self.dut = create_wlan_device(self.android_devices[0])
107
108 self.android_devices = getattr(self, 'android_devices', [])
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000109
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800110 self.access_point = self.access_points[0]
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000111 self.iperf_server = self.iperf_servers[0]
112 self.iperf_server.start()
113 self.iperf_client = self.iperf_clients[0]
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800114 self.access_point.stop_all_aps()
115
116 def setup_test(self):
Hayden Nix484f48c2020-04-14 20:54:17 +0000117 # TODO(fxb/46417): Uncomment when wlanClearCountry is implemented up any
118 # country code changes.
119 # for fd in self.fuchsia_devices:
120 # phy_ids_response = fd.wlan_lib.wlanPhyIdList()
121 # if phy_ids_response.get('error'):
122 # raise ConnectionError(
123 # 'Failed to retrieve phy ids from FuchsiaDevice (%s). '
124 # 'Error: %s' % (fd.ip, phy_ids_response['error']))
125 # for id in phy_ids_response['result']:
126 # clear_country_response = fd.wlan_lib.wlanClearCountry(id)
127 # if clear_country_response.get('error'):
128 # raise EnvironmentError(
129 # 'Failed to reset country code on FuchsiaDevice (%s). '
130 # 'Error: %s' % (fd.ip, clear_country_response['error'])
131 # )
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000132 self.access_point.stop_all_aps()
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800133 for ad in self.android_devices:
134 ad.droid.wakeLockAcquireBright()
135 ad.droid.wakeUpNow()
136 self.dut.wifi_toggle_state(True)
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000137 self.dut.disconnect()
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800138
139 def teardown_test(self):
140 for ad in self.android_devices:
141 ad.droid.wakeLockRelease()
142 ad.droid.goToSleepNow()
143 self.dut.turn_location_off_and_scan_toggle_off()
144 self.dut.disconnect()
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800145 self.access_point.stop_all_aps()
146
147 def on_fail(self, test_name, begin_time):
148 self.dut.take_bug_report(test_name, begin_time)
149 self.dut.get_log(test_name, begin_time)
150
Hayden Nix484f48c2020-04-14 20:54:17 +0000151 def set_dut_country_code(self, country_code):
152 """Set the country code on the DUT. Then verify that the country
153 code was set successfully
154
155 Args:
156 country_code: string, the 2 character country code to set
157 """
158 self.log.info('Setting DUT country code to %s' % country_code)
159 country_code_response = self.dut.device.regulatory_region_lib.setRegion(
160 country_code)
161 if country_code_response.get('error'):
162 raise EnvironmentError(
163 'Failed to set country code (%s) on DUT. Error: %s' %
164 (country_code, country_code_response['error']))
165
166 self.log.info('Verifying DUT country code was correctly set to %s.' %
167 country_code)
168 phy_ids_response = self.dut.device.wlan_lib.wlanPhyIdList()
169 if phy_ids_response.get('error'):
170 raise ConnectionError('Failed to get phy ids from DUT. Error: %s' %
171 (country_code, phy_ids_response['error']))
172
173 end_time = time.time() + TIME_TO_WAIT_FOR_COUNTRY_CODE
174 while time.time() < end_time:
175 for id in phy_ids_response['result']:
176 get_country_response = self.dut.device.wlan_lib.wlanGetCountry(
177 id)
178 if get_country_response.get('error'):
179 raise ConnectionError(
180 'Failed to query PHY ID (%s) for country. Error: %s' %
181 (id, get_country_response['error']))
182
183 set_code = ''.join([
184 chr(ascii_char)
185 for ascii_char in get_country_response['result']
186 ])
187 if set_code != country_code:
188 self.log.debug(
189 'PHY (id: %s) has incorrect country code set. '
190 'Expected: %s, Got: %s' % (id, country_code, set_code))
191 break
192 else:
193 self.log.info('All PHYs have expected country code (%s)' %
194 country_code)
195 break
196 time.sleep(TIME_TO_SLEEP_BETWEEN_RETRIES)
197 else:
198 raise EnvironmentError('Failed to set DUT country code to %s.' %
199 country_code)
200
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000201 def setup_ap(self, channel, channel_bandwidth, security_profile=None):
202 """Start network on AP with basic configuration.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800203
204 Args:
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000205 channel: int, channel to use for network
206 channel_bandwidth: int, channel bandwidth in mhz to use for network,
207 security_profile: Security object, or None if open
208
209 Returns:
210 string, ssid of network running
211
212 Raises:
213 ConnectionError if network is not started successfully.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800214 """
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000215 if channel > MAX_2_4_CHANNEL:
216 vht_bandwidth = channel_bandwidth
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800217 else:
218 vht_bandwidth = None
219
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000220 if channel_bandwidth == hostapd_constants.CHANNEL_BANDWIDTH_20MHZ:
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800221 n_capabilities = N_CAPABILITIES_DEFAULT + [
222 hostapd_constants.N_CAPABILITY_HT20
223 ]
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000224 elif (channel_bandwidth == hostapd_constants.CHANNEL_BANDWIDTH_40MHZ or
225 channel_bandwidth == hostapd_constants.CHANNEL_BANDWIDTH_80MHZ):
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800226 if hostapd_config.ht40_plus_allowed(channel):
227 extended_channel = [hostapd_constants.N_CAPABILITY_HT40_PLUS]
228 elif hostapd_config.ht40_minus_allowed(channel):
229 extended_channel = [hostapd_constants.N_CAPABILITY_HT40_MINUS]
230 else:
231 raise ValueError('Invalid Channel: %s' % channel)
232 n_capabilities = N_CAPABILITIES_DEFAULT + extended_channel
233 else:
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000234 raise ValueError('Invalid Bandwidth: %s' % channel_bandwidth)
235 ssid = utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G)
236 try:
237 wlan_utils.setup_ap(access_point=self.access_point,
238 profile_name='whirlwind',
239 channel=channel,
240 security=security_profile,
241 n_capabilities=n_capabilities,
242 ac_capabilities=None,
243 force_wmm=True,
244 ssid=ssid,
245 vht_bandwidth=vht_bandwidth,
246 setup_bridge=True)
247 except Exception as err:
248 raise ConnectionError(
249 'Failed to setup ap on channel: %s, channel bandwidth: %smhz. '
250 'Error: %s' % (channel, channel_bandwidth, err))
251 else:
252 self.log.info(
253 'Network (ssid: %s) up on channel %s w/ channel bandwidth %smhz'
254 % (ssid, channel, channel_bandwidth))
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800255
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000256 return ssid
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800257
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000258 def get_and_verify_iperf_address(self, channel, device, interface=None):
259 """Get ip address from a devices interface and verify it belongs to
260 expected subnet based on APs DHCP config.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800261
262 Args:
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000263 channel: int, channel network is running on, to determine subnet
264 device: device to get ip address for
265 interface (default: None): interface on device to get ip address.
266 If None, uses device.test_interface.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800267
268 Returns:
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000269 String, ip address of device on given interface (or test_interface)
270
271 Raises:
272 ConnectionError, if device does not have a valid ip address after
273 all retries.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800274 """
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000275 if channel <= MAX_2_4_CHANNEL:
276 subnet = self.access_point._AP_2G_SUBNET_STR
277 else:
278 subnet = self.access_point._AP_5G_SUBNET_STR
279 end_time = time.time() + self.time_to_wait_for_ip_addr
280 while time.time() < end_time:
281 if interface:
282 device_addresses = device.get_interface_ip_addresses(interface)
283 else:
284 device_addresses = device.get_interface_ip_addresses(
285 device.test_interface)
286
287 if device_addresses['ipv4_private']:
288 for ip_addr in device_addresses['ipv4_private']:
289 if utils.ip_in_subnet(ip_addr, subnet):
290 return ip_addr
291 else:
292 self.log.debug(
293 'Device has an ip address (%s), but it is not in '
294 'subnet %s' % (ip_addr, subnet))
295 else:
296 self.log.debug(
297 'Device does not have a valid ip address. Retrying.')
298 time.sleep(TIME_TO_SLEEP_BETWEEN_RETRIES)
299 raise ConnectionError('Device failed to get an ip address.')
300
301 def get_iperf_throughput(self,
302 iperf_server_address,
303 iperf_client_address,
304 reverse=False):
305 """Run iperf between client and server and get the throughput.
306
307 Args:
308 iperf_server_address: string, ip address of running iperf server
309 iperf_client_address: string, ip address of iperf client (dut)
310 reverse (default: False): If True, run traffic in reverse direction,
311 from server to client.
312
313 Returns:
314 int, iperf throughput OR IPERF_NO_THROUGHPUT_VALUE, if iperf fails
315 """
316 if reverse:
317 self.log.info(
318 'Running IPerf traffic from server (%s) to dut (%s).' %
319 (iperf_server_address, iperf_client_address))
320 iperf_results_file = self.iperf_client.start(
321 iperf_server_address, '-i 1 -t 10 -R -J', 'channel_sweep_rx')
322 else:
323 self.log.info(
324 'Running IPerf traffic from dut (%s) to server (%s).' %
325 (iperf_client_address, iperf_server_address))
326 iperf_results_file = self.iperf_client.start(
327 iperf_server_address, '-i 1 -t 10 -J', 'channel_sweep_tx')
328 if iperf_results_file:
329 iperf_results = IPerfResult(iperf_results_file)
330 return iperf_results.avg_send_rate
331 else:
332 return IPERF_NO_THROUGHPUT_VALUE
333
334 def log_to_file_and_throughput_data(self, channel, channel_bandwidth,
335 tx_throughput, rx_throughput):
336 """Write performance info to csv file and to throughput data.
337
338 Args:
339 channel: int, channel that test was run on
340 channel_bandwidth: int, channel bandwidth the test used
341 tx_throughput: float, throughput value from dut to iperf server
342 rx_throughput: float, throughput value from iperf server to dut
343 """
344 test_name = self.throughput_data['test']
345 output_path = context.get_current_context().get_base_output_path()
346 log_path = '%s/ChannelSweepTest/%s' % (output_path, test_name)
347 if not os.path.exists(log_path):
348 os.makedirs(log_path)
349 log_file = '%s/%s_%smhz.csv' % (log_path, test_name, channel_bandwidth)
350 self.log.info('Writing IPerf results for %s to %s' %
351 (test_name, log_file))
352 with open(log_file, 'a') as csv_file:
353 csv_file.write('%s,%s,%s\n' %
354 (channel, tx_throughput, rx_throughput))
355 self.throughput_data['results'][str(channel)] = {
356 'tx_throughput': tx_throughput,
357 'rx_throughput': rx_throughput
358 }
359
360 def write_graph(self):
361 """Create graph html files from throughput data, plotting channel vs
362 tx_throughput and channel vs rx_throughput.
363 """
364 output_path = context.get_current_context().get_base_output_path()
365 test_name = self.throughput_data['test']
366 channel_bandwidth = self.throughput_data['channel_bandwidth']
367 output_file_name = '%s/ChannelSweepTest/%s/%s_%smhz.html' % (
368 output_path, test_name, test_name, channel_bandwidth)
369 output_file(output_file_name)
370 channels = []
371 tx_throughputs = []
372 rx_throughputs = []
373 for channel in self.throughput_data['results']:
374 channels.append(str(channel))
375 tx_throughputs.append(
376 self.throughput_data['results'][channel]['tx_throughput'])
377 rx_throughputs.append(
378 self.throughput_data['results'][channel]['rx_throughput'])
379 channel_vs_throughput_data = ColumnDataSource(
380 data=dict(channels=channels,
381 tx_throughput=tx_throughputs,
382 rx_throughput=rx_throughputs))
383 TOOLTIPS = [('Channel', '@channels'),
384 ('TX_Throughput', '@tx_throughput'),
385 ('RX_Throughput', '@rx_throughput')]
386 channel_vs_throughput_graph = figure(title='Channels vs. Throughput',
387 x_axis_label='Channels',
388 x_range=channels,
389 y_axis_label='Throughput',
390 tooltips=TOOLTIPS)
391 channel_vs_throughput_graph.sizing_mode = 'stretch_both'
392 channel_vs_throughput_graph.title.align = 'center'
393 channel_vs_throughput_graph.line('channels',
394 'tx_throughput',
395 source=channel_vs_throughput_data,
396 line_width=2,
397 line_color='blue',
398 legend_label='TX_Throughput')
399 channel_vs_throughput_graph.circle('channels',
400 'tx_throughput',
401 source=channel_vs_throughput_data,
402 size=GRAPH_CIRCLE_SIZE,
403 color='blue')
404 channel_vs_throughput_graph.line('channels',
405 'rx_throughput',
406 source=channel_vs_throughput_data,
407 line_width=2,
408 line_color='red',
409 legend_label='RX_Throughput')
410 channel_vs_throughput_graph.circle('channels',
411 'rx_throughput',
412 source=channel_vs_throughput_data,
413 size=GRAPH_CIRCLE_SIZE,
414 color='red')
415
416 channel_vs_throughput_graph.legend.location = "top_left"
417 graph_file = save([channel_vs_throughput_graph])
418 self.log.info('Saved graph to %s' % graph_file)
419
420 def verify_standard_deviation(self, max_std_dev):
421 """Verifies the standard deviation of the throughput across the channels
422 does not exceed the max_std_dev value.
423
424 Args:
425 max_std_dev: float, max standard deviation of throughput for a test
426 to pass (in mb/s)
427
428 Raises:
429 TestFailure, if standard deviation of throughput exceeds max_std_dev
430 """
431 self.log.info('Verifying standard deviation across channels does not '
432 'exceed max standard deviation of %s mb/s' % max_std_dev)
433 tx_values = []
434 rx_values = []
435 for channel in self.throughput_data['results']:
436 if self.throughput_data['results'][channel][
437 'tx_throughput'] is not None:
438 tx_values.append(
439 self.throughput_data['results'][channel]['tx_throughput'])
440 if self.throughput_data['results'][channel][
441 'rx_throughput'] is not None:
442 rx_values.append(
443 self.throughput_data['results'][channel]['rx_throughput'])
444 tx_std_dev = pstdev(tx_values)
445 rx_std_dev = pstdev(rx_values)
446 if tx_std_dev > max_std_dev or rx_std_dev > max_std_dev:
447 asserts.fail(
448 'With %smhz channel bandwidth, throughput standard '
Hayden Nix484f48c2020-04-14 20:54:17 +0000449 'deviation (tx: %s mb/s, rx: %s mb/s) exceeds max standard '
450 'deviation (%s mb/s).' %
451 (self.throughput_data['channel_bandwidth'], tx_std_dev,
452 rx_std_dev, max_std_dev))
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000453 else:
454 asserts.explicit_pass(
455 'Throughput standard deviation (tx: %s mb/s, rx: %s mb/s) '
456 'with %smhz channel bandwidth does not exceed maximum (%s mb/s).'
457 % (tx_std_dev, rx_std_dev,
458 self.throughput_data['channel_bandwidth'], max_std_dev))
459
460 def run_channel_performance_tests(self, settings):
461 """Test function for running channel performance tests. Used by both
462 explicit test cases and debug test cases from config. Runs a performance
463 test for each channel in test_channels with test_channel_bandwidth, then
464 writes a graph and csv file of the channel vs throughput.
465
466 Args:
467 settings: dict, containing the following test settings
468 test_channels: list of channels to test.
469 test_channel_bandwidth: int, channel bandwidth to use for test.
470 test_security (optional): string, security type to use for test.
471 min_tx_throughput (optional, default: 0): float, minimum tx
472 throughput threshold to pass individual channel tests
473 (in mb/s).
474 min_rx_throughput (optional, default: 0): float, minimum rx
475 throughput threshold to pass individual channel tests
476 (in mb/s).
477 max_std_dev (optional, default: 1): float, maximum standard
478 deviation of throughput across all test channels to pass
479 test (in mb/s).
480 base_test_name (optional): string, test name prefix to use with
481 generated subtests.
Hayden Nix484f48c2020-04-14 20:54:17 +0000482 country_name (optional): string, country name from
483 hostapd_constants to set on device.
484 country_code (optional): string, two-char country code to set on
485 the DUT. Takes priority over country_name.
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000486 test_name (debug tests only): string, the test name for this
487 parent test case from the config file. In explicit tests,
488 this is not necessary.
489
490 Writes:
491 CSV file: channel, tx_throughput, rx_throughput
492 for every test channel.
493 Graph: channel vs tx_throughput & channel vs rx_throughput
494
495 Raises:
496 TestFailure, if throughput standard deviation across channels
497 exceeds max_std_dev
498
499 Example Explicit Test (see EOF for debug JSON example):
500 def test_us_2g_20mhz_wpa2(self):
501 self.run_channel_performance_tests(
502 dict(
503 test_channels=hostapd_constants.US_CHANNELS_2G,
504 test_channel_bandwidth=20,
505 test_security=hostapd_constants.WPA2_STRING,
506 min_tx_throughput=2,
507 min_rx_throughput=4,
508 max_std_dev=0.75,
Hayden Nix484f48c2020-04-14 20:54:17 +0000509 country_code='US',
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000510 base_test_name='test_us'))
511 """
512 test_channels = settings['test_channels']
513 test_channel_bandwidth = settings['test_channel_bandwidth']
514 test_security = settings.get('test_security')
515 test_name = settings.get('test_name', self.test_name)
516 base_test_name = settings.get('base_test_name', 'test')
517 min_tx_throughput = settings.get('min_tx_throughput',
518 DEFAULT_MIN_THROUGHPUT)
519 min_rx_throughput = settings.get('min_rx_throughput',
520 DEFAULT_MIN_THROUGHPUT)
521 max_std_dev = settings.get('max_std_dev', DEFAULT_MAX_STD_DEV)
Hayden Nix484f48c2020-04-14 20:54:17 +0000522 country_code = settings.get('country_code')
523 country_name = settings.get('country_name')
524 country_label = None
525
526 if country_code:
527 country_label = country_code
528 self.set_dut_country_code(country_code)
529 elif country_name:
530 country_label = country_name
531 code = hostapd_constants.COUNTRY_CODE[country_name]['country_code']
532 self.set_dut_country_code(code)
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000533
534 self.throughput_data = {
535 'test': test_name,
536 'channel_bandwidth': test_channel_bandwidth,
537 'results': {}
538 }
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800539 test_list = []
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000540 for channel in test_channels:
Hayden Nix484f48c2020-04-14 20:54:17 +0000541 sub_test_name = '%schannel_%s_%smhz_performance' % (
542 '%s_' % country_label if country_label else '', channel,
543 test_channel_bandwidth)
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000544 test_list.append({
545 'test_name': sub_test_name,
546 'channel': int(channel),
547 'channel_bandwidth': int(test_channel_bandwidth),
548 'security': test_security,
549 'min_tx_throughput': min_tx_throughput,
550 'min_rx_throughput': min_rx_throughput
551 })
552 self.run_generated_testcases(self.get_channel_performance,
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800553 settings=test_list,
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000554 name_func=get_test_name)
555 self.log.info('Channel tests completed.')
556 self.write_graph()
557 self.verify_standard_deviation(max_std_dev)
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800558
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000559 def get_channel_performance(self, settings):
560 """Run a single channel performance test and logs results to csv file
561 and throughput data. Run with generated sub test cases in
562 run_channel_performance_tests.
563
564 1. Sets up network with test settings
565 2. Associates DUT
566 3. Runs traffic between DUT and iperf server (both directions)
567 4. Logs channel, tx_throughput (mb/s), and rx_throughput (mb/s) to
568 log file and throughput data.
569 5. Checks throughput values against minimum throughput thresholds.
570
571 Args:
572 settings: see run_channel_performance_tests
573
574 Raises:
575 TestFailure, if throughput (either direction) is less than
576 the directions given minimum throughput threshold.
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800577 """
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000578 channel = settings['channel']
579 channel_bandwidth = settings['channel_bandwidth']
580 security = settings['security']
581 test_name = settings['test_name']
582 min_tx_throughput = settings['min_tx_throughput']
583 min_rx_throughput = settings['min_rx_throughput']
584 if security:
585 if security == hostapd_constants.WEP_STRING:
586 password = utils.rand_hex_str(WEP_HEX_STRING_LENGTH)
587 else:
588 password = utils.rand_ascii_str(
589 hostapd_constants.MIN_WPA_PSK_LENGTH)
590 security_profile = Security(security_mode=security,
591 password=password)
592 else:
593 password = None
594 security_profile = None
595 ssid = self.setup_ap(channel, channel_bandwidth, security_profile)
596 associated = wlan_utils.associate(client=self.dut,
597 ssid=ssid,
598 password=password)
599 if not associated:
600 self.log_to_file_and_throughput_data(channel, channel_bandwidth,
601 None, None)
602 asserts.fail('Device failed to associate with network %s' % ssid)
603 self.log.info('DUT (%s) connected to network %s.' %
604 (self.dut.device.ip, ssid))
605 self.iperf_server.renew_test_interface_ip_address()
606 self.log.info(
607 'Getting ip address for iperf server. Will retry for %s seconds.' %
608 self.time_to_wait_for_ip_addr)
609 iperf_server_address = self.get_and_verify_iperf_address(
610 channel, self.iperf_server)
611 self.log.info(
612 'Getting ip address for DUT. Will retry for %s seconds.' %
613 self.time_to_wait_for_ip_addr)
614 iperf_client_address = self.get_and_verify_iperf_address(
615 channel, self.dut, self.iperf_client.test_interface)
616 tx_throughput = self.get_iperf_throughput(iperf_server_address,
617 iperf_client_address)
618 rx_throughput = self.get_iperf_throughput(iperf_server_address,
619 iperf_client_address,
620 reverse=True)
621 self.log_to_file_and_throughput_data(channel, channel_bandwidth,
622 tx_throughput, rx_throughput)
623 self.log.info('Throughput (tx, rx): (%s mb/s, %s mb/s), '
624 'Minimum threshold (tx, rx): (%s mb/s, %s mb/s)' %
625 (tx_throughput, rx_throughput, min_tx_throughput,
626 min_rx_throughput))
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000627 base_message = (
628 'Actual throughput (on channel: %s, channel bandwidth: '
629 '%s, security: %s)' % (channel, channel_bandwidth, security))
Hayden Nix484f48c2020-04-14 20:54:17 +0000630 if (tx_throughput < min_tx_throughput
631 or rx_throughput < min_rx_throughput):
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000632 asserts.fail('%s below the minimum threshold.' % base_message)
633 asserts.explicit_pass('%s above the minimum threshold.' % base_message)
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800634
Hayden Nix484f48c2020-04-14 20:54:17 +0000635 def verify_regulatory_compliance(self, settings):
636 """Test function for regulatory compliance tests. Verify device complies
637 with provided regulatory requirements.
638
639 Args:
640 settings: dict, containing the following test settings
641 test_channels: dict, mapping channels to a set of the channel
642 bandwidths to test (see example for using JSON). Defaults
643 to hostapd_constants.ALL_CHANNELS.
644 country_code: string, two-char country code to set on device
645 (prioritized over country_name)
646 country_name: string, country name from hostapd_constants to set
647 on device.
648 base_test_name (optional): string, test name prefix to use with
649 generatedsubtests.
650 test_name: string, the test name for this
651 parent test case from the config file. In explicit tests,
652 this is not necessary.
653 """
654 country_name = settings.get('country_name')
655 country_code = settings.get('country_code')
656 if not (country_code or country_name):
657 raise ValueError('No country code or name provided.')
658
659 test_channels = settings.get('test_channels',
660 hostapd_constants.ALL_CHANNELS)
661 allowed_channels = settings['allowed_channels']
662
663 base_test_name = settings.get('base_test_name', 'test_compliance')
664
665 if country_code:
666 code = country_code
667 else:
668 code = hostapd_constants.COUNTRY_CODE[country_name]['country_code']
669
670 self.set_dut_country_code(code)
671
672 test_list = []
673 for channel in test_channels:
674 for channel_bandwidth in test_channels[channel]:
675 sub_test_name = '%s_channel_%s_%smhz' % (
676 base_test_name, channel, channel_bandwidth)
677 should_associate = (
678 channel in allowed_channels
679 and channel_bandwidth in allowed_channels[channel])
680 # Note: these int conversions because when these tests are
681 # imported via JSON, they may be strings since the channels
682 # will be keys. This makes the json/list test_channels param
683 # behave exactly like the in code dict/set test_channels.
684 test_list.append({
685 'country_code': code,
686 'channel': int(channel),
687 'channel_bandwidth': int(channel_bandwidth),
688 'should_associate': should_associate,
689 'test_name': sub_test_name
690 })
691 self.run_generated_testcases(test_func=self.verify_channel_compliance,
692 settings=test_list,
693 name_func=get_test_name)
694
695 def verify_channel_compliance(self, settings):
696 """Verify device complies with provided regulatory requirements for a
697 specific channel and channel bandwidth. Run with generated test cases
698 in the verify_regulatory_compliance parent test.
699_
700 Args:
701 settings: see verify_regulatory_compliance`
702 """
703 channel = settings['channel']
704 channel_bandwidth = settings['channel_bandwidth']
705 code = settings['country_code']
706 should_associate = settings['should_associate']
707
708 ssid = self.setup_ap(channel, channel_bandwidth)
709
710 self.log.info(
711 'Attempting to associate with network (%s) on channel %s @ %smhz. '
712 'Expected behavior: %s' %
713 (ssid, channel, channel_bandwidth, 'Device should associate'
714 if should_associate else 'Device should NOT associate.'))
715
716 associated = wlan_utils.associate(client=self.dut, ssid=ssid)
717 if associated == should_associate:
718 asserts.explicit_pass(
719 'Device complied with %s regulatory requirement for channel %s '
720 ' with channel bandwidth %smhz. %s' %
721 (code, channel, channel_bandwidth,
722 'Associated.' if associated else 'Refused to associate.'))
723 else:
724 asserts.fail(
725 'Device failed compliance with regulatory domain %s for '
726 'channel %s with channel bandwidth %smhz. Expected: %s, Got: %s'
727 % (code, channel, channel_bandwidth, 'Should associate'
728 if should_associate else 'Should not associate',
729 'Associated' if associated else 'Did not associate'))
730
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000731 # Helper functions to allow explicit tests throughput and standard deviation
732 # thresholds to be passed in via config.
733 def _get_min_tx_throughput(self, test_name):
734 return self.user_params.get('channel_sweep_test_params',
735 {}).get(test_name,
736 {}).get('min_tx_throughput',
737 DEFAULT_MIN_THROUGHPUT)
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800738
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000739 def _get_min_rx_throughput(self, test_name):
740 return self.user_params.get('channel_sweep_test_params',
741 {}).get(test_name,
742 {}).get('min_rx_throughput',
743 DEFAULT_MIN_THROUGHPUT)
744
745 def _get_max_std_dev(self, test_name):
746 return self.user_params.get('channel_sweep_test_params',
747 {}).get(test_name,
748 {}).get('min_std_dev',
749 DEFAULT_MAX_STD_DEV)
750
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000751 # Channel Performance of US Channels: 570 Test Cases
752 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000753 def test_us_20mhz_open_channel_performance(self):
754 self.run_channel_performance_tests(
755 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
756 hostapd_constants.US_CHANNELS_5G,
757 test_channel_bandwidth=hostapd_constants.
758 CHANNEL_BANDWIDTH_20MHZ,
759 base_test_name=self.test_name,
760 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
761 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
762 max_std_dev=self._get_max_std_dev(self.test_name)))
763
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000764 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000765 def test_us_40mhz_open_channel_performance(self):
766 self.run_channel_performance_tests(
767 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
768 hostapd_constants.US_CHANNELS_5G[:-1],
769 test_channel_bandwidth=hostapd_constants.
770 CHANNEL_BANDWIDTH_40MHZ,
771 base_test_name=self.test_name,
772 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
773 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
774 max_std_dev=self._get_max_std_dev(self.test_name)))
775
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000776 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000777 def test_us_80mhz_open_channel_performance(self):
778 self.run_channel_performance_tests(
779 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
780 test_channel_bandwidth=hostapd_constants.
781 CHANNEL_BANDWIDTH_80MHZ,
782 base_test_name=self.test_name,
783 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
784 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
785 max_std_dev=self._get_max_std_dev(self.test_name)))
786
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000787 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000788 def test_us_20mhz_wep_channel_performance(self):
789 self.run_channel_performance_tests(
790 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
791 hostapd_constants.US_CHANNELS_5G,
792 test_channel_bandwidth=hostapd_constants.
793 CHANNEL_BANDWIDTH_20MHZ,
794 test_security=hostapd_constants.WEP_STRING,
795 base_test_name=self.test_name,
796 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
797 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
798 max_std_dev=self._get_max_std_dev(self.test_name)))
799
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000800 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000801 def test_us_40mhz_wep_channel_performance(self):
802 self.run_channel_performance_tests(
803 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
804 hostapd_constants.US_CHANNELS_5G[:-1],
805 test_channel_bandwidth=hostapd_constants.
806 CHANNEL_BANDWIDTH_40MHZ,
807 test_security=hostapd_constants.WEP_STRING,
808 base_test_name=self.test_name,
809 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
810 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
811 max_std_dev=self._get_max_std_dev(self.test_name)))
812
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000813 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000814 def test_us_80mhz_wep_channel_performance(self):
815 self.run_channel_performance_tests(
816 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
817 test_channel_bandwidth=hostapd_constants.
818 CHANNEL_BANDWIDTH_80MHZ,
819 test_security=hostapd_constants.WEP_STRING,
820 base_test_name=self.test_name,
821 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
822 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
823 max_std_dev=self._get_max_std_dev(self.test_name)))
824
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000825 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000826 def test_us_20mhz_wpa_channel_performance(self):
827 self.run_channel_performance_tests(
828 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
829 hostapd_constants.US_CHANNELS_5G,
830 test_channel_bandwidth=hostapd_constants.
831 CHANNEL_BANDWIDTH_20MHZ,
832 test_security=hostapd_constants.WPA_STRING,
833 base_test_name=self.test_name,
834 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
835 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
836 max_std_dev=self._get_max_std_dev(self.test_name)))
837
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000838 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000839 def test_us_40mhz_wpa_channel_performance(self):
840 self.run_channel_performance_tests(
841 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
842 hostapd_constants.US_CHANNELS_5G[:-1],
843 test_channel_bandwidth=hostapd_constants.
844 CHANNEL_BANDWIDTH_40MHZ,
845 test_security=hostapd_constants.WPA_STRING,
846 base_test_name=self.test_name,
847 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
848 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
849 max_std_dev=self._get_max_std_dev(self.test_name)))
850
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000851 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000852 def test_us_80mhz_wpa_channel_performance(self):
853 self.run_channel_performance_tests(
854 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
855 test_channel_bandwidth=hostapd_constants.
856 CHANNEL_BANDWIDTH_80MHZ,
857 test_security=hostapd_constants.WPA_STRING,
858 base_test_name=self.test_name,
859 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
860 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
861 max_std_dev=self._get_max_std_dev(self.test_name)))
862
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000863 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000864 def test_us_20mhz_wpa2_channel_performance(self):
865 self.run_channel_performance_tests(
866 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
867 hostapd_constants.US_CHANNELS_5G,
868 test_channel_bandwidth=hostapd_constants.
869 CHANNEL_BANDWIDTH_20MHZ,
870 test_security=hostapd_constants.WPA2_STRING,
871 base_test_name=self.test_name,
872 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
873 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
874 max_std_dev=self._get_max_std_dev(self.test_name)))
875
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000876 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000877 def test_us_40mhz_wpa2_channel_performance(self):
878 self.run_channel_performance_tests(
879 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
880 hostapd_constants.US_CHANNELS_5G[:-1],
881 test_channel_bandwidth=hostapd_constants.
882 CHANNEL_BANDWIDTH_40MHZ,
883 test_security=hostapd_constants.WPA2_STRING,
884 base_test_name=self.test_name,
885 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
886 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
887 max_std_dev=self._get_max_std_dev(self.test_name)))
888
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000889 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000890 def test_us_80mhz_wpa2_channel_performance(self):
891 self.run_channel_performance_tests(
892 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
893 test_channel_bandwidth=hostapd_constants.
894 CHANNEL_BANDWIDTH_80MHZ,
895 test_security=hostapd_constants.WPA2_STRING,
896 base_test_name=self.test_name,
897 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
898 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
899 max_std_dev=self._get_max_std_dev(self.test_name)))
900
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000901 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000902 def test_us_20mhz_wpa_wpa2_channel_performance(self):
903 self.run_channel_performance_tests(
904 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
905 hostapd_constants.US_CHANNELS_5G,
906 test_channel_bandwidth=hostapd_constants.
907 CHANNEL_BANDWIDTH_20MHZ,
908 test_security=hostapd_constants.WPA_MIXED_STRING,
909 base_test_name=self.test_name,
910 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
911 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
912 max_std_dev=self._get_max_std_dev(self.test_name)))
913
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000914 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000915 def test_us_40mhz_wpa_wpa2_channel_performance(self):
916 self.run_channel_performance_tests(
917 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
918 hostapd_constants.US_CHANNELS_5G[:-1],
919 test_channel_bandwidth=hostapd_constants.
920 CHANNEL_BANDWIDTH_40MHZ,
921 test_security=hostapd_constants.WPA_MIXED_STRING,
922 base_test_name=self.test_name,
923 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
924 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
925 max_std_dev=self._get_max_std_dev(self.test_name)))
926
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000927 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000928 def test_us_80mhz_wpa_wpa2_channel_performance(self):
929 self.run_channel_performance_tests(
930 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
931 test_channel_bandwidth=hostapd_constants.
932 CHANNEL_BANDWIDTH_80MHZ,
933 test_security=hostapd_constants.WPA_MIXED_STRING,
934 base_test_name=self.test_name,
935 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
936 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
937 max_std_dev=self._get_max_std_dev(self.test_name)))
938
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000939 # 36 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000940 def test_us_20mhz_wpa3_channel_performance(self):
941 self.run_channel_performance_tests(
942 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
943 hostapd_constants.US_CHANNELS_5G,
944 test_channel_bandwidth=hostapd_constants.
945 CHANNEL_BANDWIDTH_20MHZ,
946 test_security=hostapd_constants.WPA3_STRING,
947 base_test_name=self.test_name,
948 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
949 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
950 max_std_dev=self._get_max_std_dev(self.test_name)))
951
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000952 # 35 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000953 def test_us_40mhz_wpa3_channel_performance(self):
954 self.run_channel_performance_tests(
955 dict(test_channels=hostapd_constants.US_CHANNELS_2G +
956 hostapd_constants.US_CHANNELS_5G[:-1],
957 test_channel_bandwidth=hostapd_constants.
958 CHANNEL_BANDWIDTH_40MHZ,
959 test_security=hostapd_constants.WPA3_STRING,
960 base_test_name=self.test_name,
961 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
962 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
963 max_std_dev=self._get_max_std_dev(self.test_name)))
964
Hayden Nix6f3d71c2020-05-20 00:10:39 +0000965 # 24 Test Cases
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000966 def test_us_80mhz_wpa3_channel_performance(self):
967 self.run_channel_performance_tests(
968 dict(test_channels=hostapd_constants.US_CHANNELS_5G[:-1],
969 test_channel_bandwidth=hostapd_constants.
970 CHANNEL_BANDWIDTH_80MHZ,
971 test_security=hostapd_constants.WPA3_STRING,
972 base_test_name=self.test_name,
973 min_tx_throughput=self._get_min_tx_throughput(self.test_name),
974 min_rx_throughput=self._get_min_rx_throughput(self.test_name),
975 max_std_dev=self._get_max_std_dev(self.test_name)))
976
977 def test_channel_performance_debug(self):
978 """Run channel performance test cases from the ACTS config file.
979
980 Example:
981 "channel_sweep_test_params": {
982 "debug_channel_performance_tests": [
983 {
984 "test_name": "test_123_20mhz_wpa2_performance"
985 "test_channels": [1, 2, 3],
986 "test_channel_bandwidth": 20,
987 "test_security": "wpa2",
988 "base_test_name": "test_123_perf",
989 "min_tx_throughput": 1.1,
990 "min_rx_throughput": 3,
991 "max_std_dev": 0.5
992 },
993 ...
994 ]
995 }
996
Hayden Nix3f2eebf2020-01-14 10:39:21 -0800997 """
Hayden Nixc8a02bf2020-04-14 19:12:34 +0000998 asserts.skip_if(
999 'debug_channel_performance_tests' not in self.user_params.get(
1000 'channel_sweep_test_params', {}),
1001 'No custom channel performance tests provided in config.')
1002 base_tests = self.user_params['channel_sweep_test_params'][
1003 'debug_channel_performance_tests']
1004 self.run_generated_testcases(self.run_channel_performance_tests,
1005 settings=base_tests,
1006 name_func=get_test_name)
Hayden Nix484f48c2020-04-14 20:54:17 +00001007
1008 def test_regulatory_compliance(self):
1009 """Run regulatory compliance test case from the ACTS config file.
1010 Note: only one country_name OR country_code is required.
1011
1012 Example:
1013 "channel_sweep_test_params": {
1014 "regulatory_compliance_tests": [
1015 {
1016 "test_name": "test_japan_compliance_1_13_36"
1017 "country_name": "JAPAN",
1018 "country_code": "JP",
1019 "test_channels": {
1020 "1": [20, 40], "13": [40], "36": [20, 40, 80]
1021 },
1022 "allowed_channels": {
1023 "1": [20, 40], "36": [20, 40, 80]
1024 },
1025 "base_test_name": "test_japan"
1026 },
1027 ...
1028 ]
1029 }
1030 """
1031 asserts.skip_if(
1032 'regulatory_compliance_tests' not in self.user_params.get(
1033 'channel_sweep_test_params', {}),
1034 'No custom regulatory compliance tests provided in config.')
1035 base_tests = self.user_params['channel_sweep_test_params'][
1036 'regulatory_compliance_tests']
1037 self.run_generated_testcases(self.verify_regulatory_compliance,
1038 settings=base_tests,
1039 name_func=get_test_name)