Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python3.4 |
| 2 | # |
| 3 | # Copyright 2017 - The Android Open Source Project |
| 4 | # |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 5 | # Licensed under the Apache License, Version 2.0 (the 'License'); |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 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 |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 12 | # distributed under the License is distributed on an 'AS IS' BASIS, |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 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 | |
| 17 | import collections |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 18 | import csv |
| 19 | import itertools |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 20 | import json |
| 21 | import logging |
Omar El Ayach | e972596 | 2019-09-18 17:30:17 -0700 | [diff] [blame] | 22 | import numpy |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 23 | import os |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 24 | from acts import asserts |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 25 | from acts import context |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 26 | from acts import base_test |
| 27 | from acts import utils |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 28 | from acts.controllers import iperf_client |
Omar El Ayach | 14416ac | 2019-01-30 14:58:19 -0800 | [diff] [blame] | 29 | from acts.controllers.utils_lib import ssh |
Xianyuan Jia | 976d404 | 2019-09-30 17:19:47 -0700 | [diff] [blame] | 30 | from acts.metrics.loggers.blackbox import BlackboxMappedMetricLogger |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 31 | from acts.test_utils.wifi import ota_chamber |
Omar El Ayach | 6e518a2 | 2019-06-13 13:55:42 -0700 | [diff] [blame] | 32 | from acts.test_utils.wifi import wifi_performance_test_utils as wputils |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 33 | from acts.test_utils.wifi import wifi_test_utils as wutils |
| 34 | from acts.test_utils.wifi import wifi_retail_ap as retail_ap |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 35 | from functools import partial |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 36 | from WifiRvrTest import WifiRvrTest |
| 37 | from WifiPingTest import WifiPingTest |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 38 | |
| 39 | |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 40 | class WifiSensitivityTest(WifiRvrTest, WifiPingTest): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 41 | """Class to test WiFi sensitivity tests. |
| 42 | |
| 43 | This class implements measures WiFi sensitivity per rate. It heavily |
| 44 | leverages the WifiRvrTest class and introduced minor differences to set |
| 45 | specific rates and the access point, and implements a different pass/fail |
| 46 | check. For an example config file to run this test class see |
| 47 | example_connectivity_performance_ap_sta.json. |
| 48 | """ |
| 49 | |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 50 | RSSI_POLL_INTERVAL = 0.2 |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 51 | VALID_TEST_CONFIGS = { |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 52 | 1: ['legacy', 'VHT20'], |
| 53 | 2: ['legacy', 'VHT20'], |
| 54 | 6: ['legacy', 'VHT20'], |
| 55 | 10: ['legacy', 'VHT20'], |
| 56 | 11: ['legacy', 'VHT20'], |
| 57 | 36: ['legacy', 'VHT20', 'VHT40', 'VHT80'], |
| 58 | 40: ['legacy', 'VHT20'], |
| 59 | 44: ['legacy', 'VHT20'], |
| 60 | 48: ['legacy', 'VHT20'], |
| 61 | 149: ['legacy', 'VHT20', 'VHT40', 'VHT80'], |
| 62 | 153: ['legacy', 'VHT20'], |
| 63 | 157: ['legacy', 'VHT20'], |
| 64 | 161: ['legacy', 'VHT20'] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 65 | } |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 66 | RateTuple = collections.namedtuple(('RateTuple'), |
| 67 | ['mcs', 'streams', 'data_rate']) |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 68 | #yapf:disable |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 69 | VALID_RATES = { |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 70 | 'legacy_2GHz': [ |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 71 | RateTuple(54, 1, 54), RateTuple(48, 1, 48), |
| 72 | RateTuple(36, 1, 36), RateTuple(24, 1, 24), |
| 73 | RateTuple(18, 1, 18), RateTuple(12, 1, 12), |
| 74 | RateTuple(11, 1, 11), RateTuple(9, 1, 9), |
| 75 | RateTuple(6, 1, 6), RateTuple(5.5, 1, 5.5), |
| 76 | RateTuple(2, 1, 2), RateTuple(1, 1, 1)], |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 77 | 'legacy_5GHz': [ |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 78 | RateTuple(54, 1, 54), RateTuple(48, 1, 48), |
| 79 | RateTuple(36, 1, 36), RateTuple(24, 1, 24), |
| 80 | RateTuple(18, 1, 18), RateTuple(12, 1, 12), |
| 81 | RateTuple(9, 1, 9), RateTuple(6, 1, 6)], |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 82 | 'HT20': [ |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 83 | RateTuple(7, 1, 72.2), RateTuple(6, 1, 65), |
| 84 | RateTuple(5, 1, 57.8), RateTuple(4, 1, 43.3), |
| 85 | RateTuple(3, 1, 26), RateTuple(2, 1, 21.7), |
| 86 | RateTuple(1, 1, 14.4), RateTuple(0, 1, 7.2), |
| 87 | RateTuple(15, 2, 144.4), RateTuple(14, 2, 130), |
| 88 | RateTuple(13, 2, 115.6), RateTuple(12, 2, 86.7), |
| 89 | RateTuple(11, 2, 57.8), RateTuple(10, 2, 43.4), |
| 90 | RateTuple(9, 2, 28.9), RateTuple(8, 2, 14.4)], |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 91 | 'VHT20': [ |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 92 | RateTuple(9, 1, 96), RateTuple(8, 1, 86.7), |
| 93 | RateTuple(7, 1, 72.2), RateTuple(6, 1, 65), |
| 94 | RateTuple(5, 1, 57.8), RateTuple(4, 1, 43.3), |
| 95 | RateTuple(3, 1, 28.9), RateTuple(2, 1, 21.7), |
| 96 | RateTuple(1, 1, 14.4), RateTuple(0, 1, 7.2), |
| 97 | RateTuple(9, 2, 192), RateTuple(8, 2, 173.3), |
| 98 | RateTuple(7, 2, 144.4), RateTuple(6, 2, 130.3), |
| 99 | RateTuple(5, 2, 115.6), RateTuple(4, 2, 86.7), |
| 100 | RateTuple(3, 2, 57.8), RateTuple(2, 2, 43.3), |
| 101 | RateTuple(1, 2, 28.9), RateTuple(0, 2, 14.4)], |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 102 | 'VHT40': [ |
Omar El Ayach | 03e4061 | 2019-05-01 16:25:39 -0700 | [diff] [blame] | 103 | RateTuple(9, 1, 96), RateTuple(8, 1, 86.7), |
| 104 | RateTuple(7, 1, 72.2), RateTuple(6, 1, 65), |
| 105 | RateTuple(5, 1, 57.8), RateTuple(4, 1, 43.3), |
| 106 | RateTuple(3, 1, 28.9), RateTuple(2, 1, 21.7), |
| 107 | RateTuple(1, 1, 14.4), RateTuple(0, 1, 7.2), |
| 108 | RateTuple(9, 2, 192), RateTuple(8, 2, 173.3), |
| 109 | RateTuple(7, 2, 144.4), RateTuple(6, 2, 130.3), |
| 110 | RateTuple(5, 2, 115.6), RateTuple(4, 2, 86.7), |
| 111 | RateTuple(3, 2, 57.8), RateTuple(2, 2, 43.3), |
| 112 | RateTuple(1, 2, 28.9), RateTuple(0, 2, 14.4)], |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 113 | 'VHT80': [ |
Omar El Ayach | 03e4061 | 2019-05-01 16:25:39 -0700 | [diff] [blame] | 114 | RateTuple(9, 1, 96), RateTuple(8, 1, 86.7), |
| 115 | RateTuple(7, 1, 72.2), RateTuple(6, 1, 65), |
| 116 | RateTuple(5, 1, 57.8), RateTuple(4, 1, 43.3), |
| 117 | RateTuple(3, 1, 28.9), RateTuple(2, 1, 21.7), |
| 118 | RateTuple(1, 1, 14.4), RateTuple(0, 1, 7.2), |
| 119 | RateTuple(9, 2, 192), RateTuple(8, 2, 173.3), |
| 120 | RateTuple(7, 2, 144.4), RateTuple(6, 2, 130.3), |
| 121 | RateTuple(5, 2, 115.6), RateTuple(4, 2, 86.7), |
| 122 | RateTuple(3, 2, 57.8), RateTuple(2, 2, 43.3), |
| 123 | RateTuple(1, 2, 28.9), RateTuple(0, 2, 14.4)], |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 124 | } |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 125 | #yapf:enable |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 126 | |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 127 | def __init__(self, controllers): |
| 128 | base_test.BaseTestClass.__init__(self, controllers) |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 129 | self.testcase_metric_logger = ( |
Xianyuan Jia | 976d404 | 2019-09-30 17:19:47 -0700 | [diff] [blame] | 130 | BlackboxMappedMetricLogger.for_test_case()) |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 131 | self.testclass_metric_logger = ( |
Xianyuan Jia | 976d404 | 2019-09-30 17:19:47 -0700 | [diff] [blame] | 132 | BlackboxMappedMetricLogger.for_test_class()) |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 133 | self.publish_testcase_metrics = True |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 134 | |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 135 | def setup_class(self): |
| 136 | """Initializes common test hardware and parameters. |
| 137 | |
| 138 | This function initializes hardwares and compiles parameters that are |
| 139 | common to all tests in this class. |
| 140 | """ |
Omar El Ayach | 656bf3d | 2019-07-31 15:04:53 -0700 | [diff] [blame] | 141 | self.dut = self.android_devices[-1] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 142 | req_params = [ |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 143 | 'RetailAccessPoints', 'sensitivity_test_params', 'testbed_params', |
| 144 | 'RemoteServer' |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 145 | ] |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 146 | opt_params = ['main_network', 'golden_files_list'] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 147 | self.unpack_userparams(req_params, opt_params) |
| 148 | self.testclass_params = self.sensitivity_test_params |
| 149 | self.num_atten = self.attenuators[0].instrument.num_atten |
Omar El Ayach | 14416ac | 2019-01-30 14:58:19 -0800 | [diff] [blame] | 150 | self.ping_server = ssh.connection.SshConnection( |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 151 | ssh.settings.from_config(self.RemoteServer[0]['ssh_config'])) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 152 | self.iperf_server = self.iperf_servers[0] |
Omar El Ayach | 14416ac | 2019-01-30 14:58:19 -0800 | [diff] [blame] | 153 | self.iperf_client = self.iperf_clients[0] |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 154 | self.access_point = retail_ap.create(self.RetailAccessPoints)[0] |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 155 | self.log.info('Access Point Configuration: {}'.format( |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 156 | self.access_point.ap_settings)) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 157 | self.log_path = os.path.join(logging.log_path, 'results') |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 158 | utils.create_dir(self.log_path) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 159 | if not hasattr(self, 'golden_files_list'): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 160 | self.golden_files_list = [ |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 161 | os.path.join(self.testbed_params['golden_results_path'], file) |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 162 | for file in os.listdir( |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 163 | self.testbed_params['golden_results_path']) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 164 | ] |
Omar El Ayach | 9c56cf3 | 2019-09-19 13:07:51 -0700 | [diff] [blame] | 165 | if hasattr(self, 'bdf'): |
| 166 | self.log.info('Pushing WiFi BDF to DUT.') |
| 167 | wputils.push_bdf(self.dut, self.bdf) |
| 168 | if hasattr(self, 'firmware'): |
| 169 | self.log.info('Pushing WiFi firmware to DUT.') |
| 170 | wlanmdsp = [ |
| 171 | file for file in self.firmware if "wlanmdsp.mbn" in file |
| 172 | ][0] |
| 173 | data_msc = [file for file in self.firmware |
| 174 | if "Data.msc" in file][0] |
| 175 | wputils.push_firmware(self.dut, wlanmdsp, data_msc) |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 176 | self.atten_dut_chain_map = {} |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 177 | self.testclass_results = [] |
| 178 | |
| 179 | # Turn WiFi ON |
Omar El Ayach | d710909 | 2019-09-29 18:31:33 -0700 | [diff] [blame] | 180 | if self.testclass_params.get('airplane_mode', 1): |
| 181 | self.log.info('Turning on airplane mode.') |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 182 | asserts.assert_true(utils.force_airplane_mode(self.dut, True), |
| 183 | "Can not turn on airplane mode.") |
Omar El Ayach | 9c56cf3 | 2019-09-19 13:07:51 -0700 | [diff] [blame] | 184 | wutils.wifi_toggle_state(self.dut, True) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 185 | |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 186 | def teardown_class(self): |
| 187 | # Turn WiFi OFF |
| 188 | for dev in self.android_devices: |
| 189 | wutils.wifi_toggle_state(dev, False) |
| 190 | self.process_testclass_results() |
| 191 | |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 192 | def pass_fail_check(self, result): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 193 | """Checks sensitivity against golden results and decides on pass/fail. |
| 194 | |
| 195 | Args: |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 196 | result: dict containing attenuation, throughput and other meta |
Mark De Ruyter | e54396c | 2019-08-20 12:54:37 -0700 | [diff] [blame] | 197 | data |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 198 | """ |
| 199 | try: |
| 200 | golden_path = next(file_name |
| 201 | for file_name in self.golden_files_list |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 202 | if 'sensitivity_targets' in file_name) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 203 | with open(golden_path, 'r') as golden_file: |
| 204 | golden_results = json.load(golden_file) |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 205 | golden_sensitivity = golden_results[ |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 206 | self.current_test_name]['sensitivity'] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 207 | except: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 208 | golden_sensitivity = float('nan') |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 209 | |
Mark De Ruyter | e54396c | 2019-08-20 12:54:37 -0700 | [diff] [blame] | 210 | result_string = ('Throughput = {}%, Sensitivity = {}.' |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 211 | 'Target Sensitivity = {}'.format( |
| 212 | result['peak_throughput_pct'], |
| 213 | result['sensitivity'], golden_sensitivity)) |
Omar El Ayach | e972596 | 2019-09-18 17:30:17 -0700 | [diff] [blame] | 214 | if result['peak_throughput_pct'] < 95: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 215 | self.log.warning('Result unreliable. Peak rate unstable') |
| 216 | if result['sensitivity'] - golden_sensitivity < self.testclass_params[ |
| 217 | 'sensitivity_tolerance']: |
| 218 | asserts.explicit_pass('Test Passed. {}'.format(result_string)) |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 219 | else: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 220 | asserts.fail('Test Failed. {}'.format(result_string)) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 221 | |
| 222 | def process_testclass_results(self): |
| 223 | """Saves and plots test results from all executed test cases.""" |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 224 | # write json output |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 225 | testclass_results_dict = collections.OrderedDict() |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 226 | id_fields = ['mode', 'rate', 'num_streams', 'chain_mask'] |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 227 | channels_tested = [] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 228 | for result in self.testclass_results: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 229 | testcase_params = result['testcase_params'] |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 230 | test_id = collections.OrderedDict( |
| 231 | (key, value) for key, value in testcase_params.items() |
| 232 | if key in id_fields) |
| 233 | test_id = tuple(test_id.items()) |
Omar El Ayach | 6e518a2 | 2019-06-13 13:55:42 -0700 | [diff] [blame] | 234 | if test_id not in testclass_results_dict: |
| 235 | testclass_results_dict[test_id] = collections.OrderedDict() |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 236 | channel = testcase_params['channel'] |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 237 | if channel not in channels_tested: |
| 238 | channels_tested.append(channel) |
Omar El Ayach | e972596 | 2019-09-18 17:30:17 -0700 | [diff] [blame] | 239 | if result['peak_throughput_pct'] >= 95: |
Omar El Ayach | 6e518a2 | 2019-06-13 13:55:42 -0700 | [diff] [blame] | 240 | testclass_results_dict[test_id][channel] = result[ |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 241 | 'sensitivity'] |
Omar El Ayach | 6e518a2 | 2019-06-13 13:55:42 -0700 | [diff] [blame] | 242 | else: |
| 243 | testclass_results_dict[test_id][channel] = '' |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 244 | |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 245 | # write csv |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 246 | csv_header = ['Mode', 'MCS', 'Streams', 'Chain', 'Rate (Mbps)'] |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 247 | for channel in channels_tested: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 248 | csv_header.append('Ch. ' + str(channel)) |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 249 | results_file_path = os.path.join(self.log_path, 'results.csv') |
| 250 | with open(results_file_path, mode='w') as csv_file: |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 251 | writer = csv.DictWriter(csv_file, fieldnames=csv_header) |
| 252 | writer.writeheader() |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 253 | for test_id, test_results in testclass_results_dict.items(): |
| 254 | test_id_dict = dict(test_id) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 255 | if 'legacy' in test_id_dict['mode']: |
| 256 | rate_list = self.VALID_RATES['legacy_2GHz'] |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 257 | else: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 258 | rate_list = self.VALID_RATES[test_id_dict['mode']] |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 259 | data_rate = next(rate.data_rate for rate in rate_list |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 260 | if rate[:-1] == (test_id_dict['rate'], |
| 261 | test_id_dict['num_streams'])) |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 262 | row_value = { |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 263 | 'Mode': test_id_dict['mode'], |
| 264 | 'MCS': test_id_dict['rate'], |
| 265 | 'Streams': test_id_dict['num_streams'], |
| 266 | 'Chain': test_id_dict['chain_mask'], |
| 267 | 'Rate (Mbps)': data_rate, |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 268 | } |
| 269 | for channel in channels_tested: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 270 | row_value['Ch. ' + str(channel)] = test_results.pop( |
| 271 | channel, ' ') |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 272 | writer.writerow(row_value) |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 273 | |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 274 | if not self.testclass_params['traffic_type'].lower() == 'ping': |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 275 | WifiRvrTest.process_testclass_results(self) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 276 | |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 277 | def process_rvr_test_results(self, testcase_params, rvr_result): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 278 | """Post processes RvR results to compute sensitivity. |
| 279 | |
| 280 | Takes in the results of the RvR tests and computes the sensitivity of |
| 281 | the current rate by looking at the point at which throughput drops |
| 282 | below the percentage specified in the config file. The function then |
| 283 | calls on its parent class process_test_results to plot the result. |
| 284 | |
| 285 | Args: |
| 286 | rvr_result: dict containing attenuation, throughput and other meta |
| 287 | data |
| 288 | """ |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 289 | rvr_result['peak_throughput'] = max(rvr_result['throughput_receive']) |
| 290 | rvr_result['peak_throughput_pct'] = 100 |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 291 | throughput_check = [ |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 292 | throughput < rvr_result['peak_throughput'] * |
| 293 | (self.testclass_params['throughput_pct_at_sensitivity'] / 100) |
| 294 | for throughput in rvr_result['throughput_receive'] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 295 | ] |
| 296 | consistency_check = [ |
| 297 | idx for idx in range(len(throughput_check)) |
| 298 | if all(throughput_check[idx:]) |
| 299 | ] |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 300 | rvr_result['atten_at_range'] = rvr_result['attenuation'][ |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 301 | consistency_check[0] - 1] |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 302 | rvr_result['range'] = rvr_result['fixed_attenuation'] + ( |
| 303 | rvr_result['atten_at_range']) |
| 304 | rvr_result['sensitivity'] = self.testclass_params['ap_tx_power'] + ( |
| 305 | self.testbed_params['ap_tx_power_offset'][str( |
| 306 | testcase_params['channel'])] - rvr_result['range']) |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 307 | WifiRvrTest.process_test_results(self, rvr_result) |
| 308 | |
| 309 | def process_ping_test_results(self, testcase_params, ping_result): |
| 310 | """Post processes RvR results to compute sensitivity. |
| 311 | |
| 312 | Takes in the results of the RvR tests and computes the sensitivity of |
| 313 | the current rate by looking at the point at which throughput drops |
| 314 | below the percentage specified in the config file. The function then |
| 315 | calls on its parent class process_test_results to plot the result. |
| 316 | |
| 317 | Args: |
| 318 | rvr_result: dict containing attenuation, throughput and other meta |
| 319 | data |
| 320 | """ |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 321 | WifiPingTest.process_ping_results(self, testcase_params, ping_result) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 322 | ping_result['sensitivity'] = self.testclass_params['ap_tx_power'] + ( |
| 323 | self.testbed_params['ap_tx_power_offset'][str( |
| 324 | testcase_params['channel'])] - ping_result['range']) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 325 | |
Omar El Ayach | 03e4061 | 2019-05-01 16:25:39 -0700 | [diff] [blame] | 326 | def setup_sensitivity_test(self, testcase_params): |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 327 | if testcase_params['traffic_type'].lower() == 'ping': |
Omar El Ayach | 03e4061 | 2019-05-01 16:25:39 -0700 | [diff] [blame] | 328 | self.setup_ping_test(testcase_params) |
| 329 | self.run_sensitivity_test = self.run_ping_test |
| 330 | self.process_sensitivity_test_results = ( |
| 331 | self.process_ping_test_results) |
| 332 | else: |
| 333 | self.setup_rvr_test(testcase_params) |
| 334 | self.run_sensitivity_test = self.run_rvr_test |
| 335 | self.process_sensitivity_test_results = ( |
| 336 | self.process_rvr_test_results) |
| 337 | |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 338 | def setup_ap(self, testcase_params): |
Omar El Ayach | 5a1496bf | 2019-01-09 11:43:02 -0800 | [diff] [blame] | 339 | """Sets up the AP and attenuator to compensate for AP chain imbalance. |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 340 | |
| 341 | Args: |
| 342 | testcase_params: dict containing AP and other test params |
| 343 | """ |
| 344 | band = self.access_point.band_lookup_by_channel( |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 345 | testcase_params['channel']) |
| 346 | if '2G' in band: |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 347 | frequency = wutils.WifiEnums.channel_2G_to_freq[ |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 348 | testcase_params['channel']] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 349 | else: |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 350 | frequency = wutils.WifiEnums.channel_5G_to_freq[ |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 351 | testcase_params['channel']] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 352 | if frequency in wutils.WifiEnums.DFS_5G_FREQUENCIES: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 353 | self.access_point.set_region(self.testbed_params['DFS_region']) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 354 | else: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 355 | self.access_point.set_region(self.testbed_params['default_region']) |
| 356 | self.access_point.set_channel(band, testcase_params['channel']) |
| 357 | self.access_point.set_bandwidth(band, testcase_params['mode']) |
| 358 | self.access_point.set_power(band, testcase_params['ap_tx_power']) |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 359 | self.access_point.set_rate(band, testcase_params['mode'], |
| 360 | testcase_params['num_streams'], |
| 361 | testcase_params['rate'], |
| 362 | testcase_params['short_gi']) |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 363 | # Set attenuator offsets and set attenuators to initial condition |
| 364 | atten_offsets = self.testbed_params['chain_offset'][str( |
| 365 | testcase_params['channel'])] |
Omar El Ayach | 5a1496bf | 2019-01-09 11:43:02 -0800 | [diff] [blame] | 366 | for atten in self.attenuators: |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 367 | if 'AP-Chain-0' in atten.path: |
| 368 | atten.offset = atten_offsets[0] |
| 369 | elif 'AP-Chain-1' in atten.path: |
| 370 | atten.offset = atten_offsets[1] |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 371 | else: |
| 372 | atten.offset = 0 |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 373 | self.log.info('Access Point Configuration: {}'.format( |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 374 | self.access_point.ap_settings)) |
| 375 | |
Omar El Ayach | 6e518a2 | 2019-06-13 13:55:42 -0700 | [diff] [blame] | 376 | def setup_dut(self, testcase_params): |
| 377 | """Sets up the DUT in the configuration required by the test. |
| 378 | |
| 379 | Args: |
| 380 | testcase_params: dict containing AP and other test params |
| 381 | """ |
Omar El Ayach | 656bf3d | 2019-07-31 15:04:53 -0700 | [diff] [blame] | 382 | # Check battery level before test |
| 383 | if not wputils.health_check(self.dut, 10): |
| 384 | asserts.skip('Battery level too low. Skipping test.') |
| 385 | # Turn screen off to preserve battery |
| 386 | self.dut.go_to_sleep() |
Omar El Ayach | 6e518a2 | 2019-06-13 13:55:42 -0700 | [diff] [blame] | 387 | band = self.access_point.band_lookup_by_channel( |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 388 | testcase_params['channel']) |
Omar El Ayach | 39acf80 | 2019-08-02 17:52:39 -0700 | [diff] [blame] | 389 | current_network = self.dut.droid.wifiGetConnectionInfo() |
Omar El Ayach | fc74c4d | 2019-09-27 18:15:48 -0700 | [diff] [blame] | 390 | try: |
| 391 | connected = wutils.validate_connection(self.dut) is not None |
| 392 | except: |
| 393 | connected = False |
| 394 | if connected and current_network['SSID'] == self.main_network[band][ |
| 395 | 'SSID']: |
Omar El Ayach | 39acf80 | 2019-08-02 17:52:39 -0700 | [diff] [blame] | 396 | self.log.info('Already connected to desired network') |
| 397 | else: |
| 398 | wutils.reset_wifi(self.dut) |
Girish Moturu | 2b7afe7 | 2019-09-17 20:35:54 +0000 | [diff] [blame] | 399 | self.dut.droid.wifiSetCountryCode( |
| 400 | self.testclass_params['country_code']) |
Omar El Ayach | 39acf80 | 2019-08-02 17:52:39 -0700 | [diff] [blame] | 401 | self.main_network[band]['channel'] = testcase_params['channel'] |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 402 | wutils.wifi_connect(self.dut, |
| 403 | self.main_network[band], |
| 404 | num_of_tries=5, |
| 405 | check_connectivity=False) |
Omar El Ayach | 39acf80 | 2019-08-02 17:52:39 -0700 | [diff] [blame] | 406 | self.dut_ip = self.dut.droid.connectivityGetIPv4Addresses('wlan0')[0] |
Omar El Ayach | 16f5f34 | 2019-11-23 12:27:56 -0800 | [diff] [blame^] | 407 | if testcase_params['channel'] not in self.atten_dut_chain_map.keys(): |
| 408 | self.atten_dut_chain_map[testcase_params[ |
| 409 | 'channel']] = wputils.get_current_atten_dut_chain_map( |
| 410 | self.attenuators, self.dut, self.ping_server) |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 411 | self.log.info("Current Attenuator-DUT Chain Map: {}".format( |
| 412 | self.atten_dut_chain_map[testcase_params['channel']])) |
Omar El Ayach | 6e518a2 | 2019-06-13 13:55:42 -0700 | [diff] [blame] | 413 | for idx, atten in enumerate(self.attenuators): |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 414 | if self.atten_dut_chain_map[testcase_params['channel']][ |
| 415 | idx] == testcase_params['attenuated_chain']: |
Omar El Ayach | 6e518a2 | 2019-06-13 13:55:42 -0700 | [diff] [blame] | 416 | atten.offset = atten.instrument.max_atten |
| 417 | |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 418 | def extract_test_id(self, testcase_params, id_fields): |
| 419 | test_id = collections.OrderedDict( |
| 420 | (param, testcase_params[param]) for param in id_fields) |
| 421 | return test_id |
| 422 | |
| 423 | def get_start_atten(self, testcase_params): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 424 | """Gets the starting attenuation for this sensitivity test. |
| 425 | |
| 426 | The function gets the starting attenuation by checking whether a test |
| 427 | as the next higher MCS has been executed. If so it sets the starting |
| 428 | point a configurable number of dBs below the next MCS's sensitivity. |
| 429 | |
| 430 | Returns: |
| 431 | start_atten: starting attenuation for current test |
| 432 | """ |
| 433 | # Get the current and reference test config. The reference test is the |
| 434 | # one performed at the current MCS+1 |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 435 | current_rate = testcase_params['rate'] |
| 436 | ref_test_params = self.extract_test_id( |
| 437 | testcase_params, |
| 438 | ['channel', 'mode', 'rate', 'num_streams', 'chain_mask']) |
| 439 | if 'legacy' in testcase_params['mode']: |
| 440 | if testcase_params['channel'] <= 13: |
| 441 | rate_list = self.VALID_RATES['legacy_2GHz'] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 442 | else: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 443 | rate_list = self.VALID_RATES['legacy_5GHz'] |
Omar El Ayach | 03e4061 | 2019-05-01 16:25:39 -0700 | [diff] [blame] | 444 | ref_index = max( |
| 445 | 0, |
| 446 | rate_list.index(self.RateTuple(current_rate, 1, current_rate)) |
| 447 | - 1) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 448 | ref_test_params['rate'] = rate_list[ref_index].mcs |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 449 | else: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 450 | ref_test_params['rate'] = current_rate + 1 |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 451 | |
| 452 | # Check if reference test has been run and set attenuation accordingly |
| 453 | previous_params = [ |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 454 | self.extract_test_id( |
| 455 | result['testcase_params'], |
| 456 | ['channel', 'mode', 'rate', 'num_streams', 'chain_mask']) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 457 | for result in self.testclass_results |
| 458 | ] |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 459 | |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 460 | try: |
| 461 | ref_index = previous_params.index(ref_test_params) |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 462 | start_atten = self.testclass_results[ref_index][ |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 463 | 'atten_at_range'] - ( |
| 464 | self.testclass_params['adjacent_mcs_range_gap']) |
Omar El Ayach | 03e4061 | 2019-05-01 16:25:39 -0700 | [diff] [blame] | 465 | except ValueError: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 466 | self.log.warning( |
| 467 | 'Reference test not found. Starting from {} dB'.format( |
| 468 | self.testclass_params['atten_start'])) |
| 469 | start_atten = self.testclass_params['atten_start'] |
Omar El Ayach | 49141c0 | 2019-09-16 16:43:51 -0700 | [diff] [blame] | 470 | start_atten = max(start_atten, 0) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 471 | return start_atten |
| 472 | |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 473 | def compile_test_params(self, testcase_params): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 474 | """Function that generates test params based on the test name.""" |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 475 | if testcase_params['chain_mask'] in ['0', '1']: |
| 476 | testcase_params['attenuated_chain'] = 'DUT-Chain-{}'.format( |
| 477 | 1 if testcase_params['chain_mask'] == '0' else 0) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 478 | else: |
Omar El Ayach | df470fb | 2019-09-16 12:22:28 -0700 | [diff] [blame] | 479 | # Set attenuated chain to -1. Do not set to None as this will be |
| 480 | # compared to RF chain map which may include None |
| 481 | testcase_params['attenuated_chain'] = -1 |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 482 | |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 483 | self.testclass_params[ |
| 484 | 'range_ping_loss_threshold'] = 100 - self.testclass_params[ |
| 485 | 'throughput_pct_at_sensitivity'] |
| 486 | if self.testclass_params['traffic_type'] == 'UDP': |
| 487 | testcase_params['iperf_args'] = '-i 1 -t {} -J -u -b {}'.format( |
| 488 | self.testclass_params['iperf_duration'], |
| 489 | self.testclass_params['UDP_rates'][testcase_params['mode']]) |
| 490 | elif self.testclass_params['traffic_type'] == 'TCP': |
| 491 | testcase_params['iperf_args'] = '-i 1 -t {} -J'.format( |
| 492 | self.testclass_params['iperf_duration']) |
Omar El Ayach | 14416ac | 2019-01-30 14:58:19 -0800 | [diff] [blame] | 493 | |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 494 | if self.testclass_params['traffic_type'] != 'ping' and isinstance( |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 495 | self.iperf_client, iperf_client.IPerfClientOverAdb): |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 496 | testcase_params['iperf_args'] += ' -R' |
| 497 | testcase_params['use_client_output'] = True |
Omar El Ayach | 14416ac | 2019-01-30 14:58:19 -0800 | [diff] [blame] | 498 | else: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 499 | testcase_params['use_client_output'] = False |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 500 | |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 501 | return testcase_params |
| 502 | |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 503 | def _test_sensitivity(self, testcase_params): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 504 | """ Function that gets called for each test case |
| 505 | |
| 506 | The function gets called in each rvr test case. The function customizes |
| 507 | the rvr test based on the test name of the test that called it |
| 508 | """ |
| 509 | # Compile test parameters from config and test name |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 510 | testcase_params = self.compile_test_params(testcase_params) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 511 | testcase_params.update(self.testclass_params) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 512 | testcase_params['atten_start'] = self.get_start_atten(testcase_params) |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 513 | num_atten_steps = int( |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 514 | (testcase_params['atten_stop'] - testcase_params['atten_start']) / |
| 515 | testcase_params['atten_step']) |
| 516 | testcase_params['atten_range'] = [ |
| 517 | testcase_params['atten_start'] + x * testcase_params['atten_step'] |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 518 | for x in range(0, num_atten_steps) |
| 519 | ] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 520 | |
| 521 | # Prepare devices and run test |
Omar El Ayach | 03e4061 | 2019-05-01 16:25:39 -0700 | [diff] [blame] | 522 | self.setup_sensitivity_test(testcase_params) |
| 523 | result = self.run_sensitivity_test(testcase_params) |
| 524 | self.process_sensitivity_test_results(testcase_params, result) |
| 525 | |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 526 | # Post-process results |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 527 | self.testclass_results.append(result) |
| 528 | self.pass_fail_check(result) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 529 | |
Omar El Ayach | ffb5a46 | 2019-09-16 21:05:44 -0700 | [diff] [blame] | 530 | def generate_test_cases(self, channels, modes, chain_mask): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 531 | """Function that auto-generates test cases for a test class.""" |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 532 | test_cases = [] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 533 | for channel in channels: |
Omar El Ayach | ffb5a46 | 2019-09-16 21:05:44 -0700 | [diff] [blame] | 534 | requested_modes = set(modes).intersection( |
| 535 | set(self.VALID_TEST_CONFIGS[channel])) |
| 536 | for mode in requested_modes: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 537 | if 'VHT' in mode: |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 538 | rates = self.VALID_RATES[mode] |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 539 | elif 'HT' in mode: |
Omar El Ayach | a210d57 | 2019-03-14 17:31:38 -0700 | [diff] [blame] | 540 | rates = self.VALID_RATES[mode] |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 541 | elif 'legacy' in mode and channel < 14: |
| 542 | rates = self.VALID_RATES['legacy_2GHz'] |
| 543 | elif 'legacy' in mode and channel > 14: |
| 544 | rates = self.VALID_RATES['legacy_5GHz'] |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 545 | else: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 546 | raise ValueError('Invalid test mode.') |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 547 | for chain, rate in itertools.product(chain_mask, rates): |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 548 | testcase_params = collections.OrderedDict( |
| 549 | channel=channel, |
| 550 | mode=mode, |
| 551 | rate=rate.mcs, |
| 552 | num_streams=rate.streams, |
| 553 | short_gi=1, |
| 554 | chain_mask=chain) |
| 555 | if chain in ['0', '1'] and rate[1] == 2: |
Omar El Ayach | 96714c8 | 2019-01-28 18:51:46 -0800 | [diff] [blame] | 556 | # Do not test 2-stream rates in single chain mode |
| 557 | continue |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 558 | if 'legacy' in mode: |
| 559 | testcase_name = ('test_sensitivity_ch{}_{}_{}_nss{}' |
| 560 | '_ch{}'.format( |
Omar El Ayach | 03e4061 | 2019-05-01 16:25:39 -0700 | [diff] [blame] | 561 | channel, mode, |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 562 | str(rate.mcs).replace('.', 'p'), |
Omar El Ayach | 03e4061 | 2019-05-01 16:25:39 -0700 | [diff] [blame] | 563 | rate.streams, chain)) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 564 | else: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 565 | testcase_name = ('test_sensitivity_ch{}_{}_mcs{}_nss{}' |
| 566 | '_ch{}'.format( |
Omar El Ayach | 03e4061 | 2019-05-01 16:25:39 -0700 | [diff] [blame] | 567 | channel, mode, rate.mcs, |
| 568 | rate.streams, chain)) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 569 | setattr(self, testcase_name, |
| 570 | partial(self._test_sensitivity, testcase_params)) |
| 571 | test_cases.append(testcase_name) |
Omar El Ayach | ab047c0 | 2019-09-03 11:38:30 -0700 | [diff] [blame] | 572 | return test_cases |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 573 | |
| 574 | |
| 575 | class WifiSensitivity_AllChannels_Test(WifiSensitivityTest): |
| 576 | def __init__(self, controllers): |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 577 | super().__init__(controllers) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 578 | self.tests = self.generate_test_cases( |
Omar El Ayach | ffb5a46 | 2019-09-16 21:05:44 -0700 | [diff] [blame] | 579 | [6, 36, 40, 44, 48, 149, 153, 157, 161], |
| 580 | ['VHT20', 'VHT40', 'VHT80'], ['0', '1', '2x2']) |
Omar El Ayach | 9873c08 | 2019-09-04 12:14:50 -0700 | [diff] [blame] | 581 | |
| 582 | |
| 583 | class WifiSensitivity_SampleChannels_Test(WifiSensitivityTest): |
| 584 | def __init__(self, controllers): |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 585 | super().__init__(controllers) |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 586 | self.tests = self.generate_test_cases([6, 36, 149], |
| 587 | ['VHT20', 'VHT40', 'VHT80'], |
| 588 | ['0', '1', '2x2']) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 589 | |
| 590 | |
| 591 | class WifiSensitivity_2GHz_Test(WifiSensitivityTest): |
| 592 | def __init__(self, controllers): |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 593 | super().__init__(controllers) |
Omar El Ayach | e972596 | 2019-09-18 17:30:17 -0700 | [diff] [blame] | 594 | self.tests = self.generate_test_cases([1, 2, 6, 10, 11], ['VHT20'], |
| 595 | ['0', '1', '2x2']) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 596 | |
| 597 | |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 598 | class WifiSensitivity_5GHz_Test(WifiSensitivityTest): |
| 599 | def __init__(self, controllers): |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 600 | super().__init__(controllers) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 601 | self.tests = self.generate_test_cases( |
Omar El Ayach | ffb5a46 | 2019-09-16 21:05:44 -0700 | [diff] [blame] | 602 | [36, 40, 44, 48, 149, 153, 157, 161], ['VHT20', 'VHT40', 'VHT80'], |
| 603 | ['0', '1', '2x2']) |
Omar El Ayach | 5fbc122 | 2018-12-07 18:10:05 -0800 | [diff] [blame] | 604 | |
| 605 | |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 606 | class WifiSensitivity_UNII1_Test(WifiSensitivityTest): |
| 607 | def __init__(self, controllers): |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 608 | super().__init__(controllers) |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 609 | self.tests = self.generate_test_cases([36, 40, 44, 48], |
| 610 | ['VHT20', 'VHT40', 'VHT80'], |
| 611 | ['0', '1', '2x2']) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 612 | |
| 613 | |
| 614 | class WifiSensitivity_UNII3_Test(WifiSensitivityTest): |
| 615 | def __init__(self, controllers): |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 616 | super().__init__(controllers) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 617 | self.tests = self.generate_test_cases([149, 153, 157, 161], |
Omar El Ayach | ffb5a46 | 2019-09-16 21:05:44 -0700 | [diff] [blame] | 618 | ['VHT20', 'VHT40', 'VHT80'], |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 619 | ['0', '1', '2x2']) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 620 | |
| 621 | |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 622 | # Over-the air version of senstivity tests |
| 623 | class WifiOtaSensitivityTest(WifiSensitivityTest): |
| 624 | """Class to test over-the-air senstivity. |
| 625 | |
| 626 | This class implements measures WiFi sensitivity tests in an OTA chamber. |
| 627 | It allows setting orientation and other chamber parameters to study |
| 628 | performance in varying channel conditions |
| 629 | """ |
Omar El Ayach | 40099d0 | 2019-09-12 15:17:33 -0700 | [diff] [blame] | 630 | def __init__(self, controllers): |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 631 | base_test.BaseTestClass.__init__(self, controllers) |
| 632 | self.testcase_metric_logger = ( |
Xianyuan Jia | 976d404 | 2019-09-30 17:19:47 -0700 | [diff] [blame] | 633 | BlackboxMappedMetricLogger.for_test_case()) |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 634 | self.testclass_metric_logger = ( |
Xianyuan Jia | 976d404 | 2019-09-30 17:19:47 -0700 | [diff] [blame] | 635 | BlackboxMappedMetricLogger.for_test_class()) |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 636 | self.publish_testcase_metrics = False |
Omar El Ayach | 40099d0 | 2019-09-12 15:17:33 -0700 | [diff] [blame] | 637 | |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 638 | def setup_class(self): |
| 639 | WifiSensitivityTest.setup_class(self) |
| 640 | self.ota_chamber = ota_chamber.create( |
| 641 | self.user_params['OTAChamber'])[0] |
| 642 | |
| 643 | def teardown_class(self): |
| 644 | WifiSensitivityTest.teardown_class(self) |
| 645 | self.ota_chamber.reset_chamber() |
| 646 | |
| 647 | def setup_sensitivity_test(self, testcase_params): |
| 648 | # Setup turntable |
| 649 | self.ota_chamber.set_orientation(testcase_params['orientation']) |
| 650 | # Continue test setup |
| 651 | WifiSensitivityTest.setup_sensitivity_test(self, testcase_params) |
| 652 | |
| 653 | def process_testclass_results(self): |
| 654 | """Saves and plots test results from all executed test cases.""" |
| 655 | testclass_results_dict = collections.OrderedDict() |
| 656 | id_fields = ['mode', 'rate', 'num_streams', 'chain_mask'] |
| 657 | plots = [] |
| 658 | for result in self.testclass_results: |
| 659 | test_id = self.extract_test_id(result['testcase_params'], |
| 660 | id_fields) |
| 661 | test_id = tuple(test_id.items()) |
| 662 | channel = result['testcase_params']['channel'] |
| 663 | if test_id not in testclass_results_dict: |
| 664 | testclass_results_dict[test_id] = collections.OrderedDict() |
| 665 | if channel not in testclass_results_dict[test_id]: |
| 666 | testclass_results_dict[test_id][channel] = { |
| 667 | 'orientation': [], |
| 668 | 'sensitivity': [] |
| 669 | } |
| 670 | testclass_results_dict[test_id][channel]['orientation'].append( |
| 671 | result['testcase_params']['orientation']) |
Omar El Ayach | e972596 | 2019-09-18 17:30:17 -0700 | [diff] [blame] | 672 | if result['peak_throughput_pct'] >= 95: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 673 | testclass_results_dict[test_id][channel]['sensitivity'].append( |
| 674 | result['sensitivity']) |
| 675 | else: |
| 676 | testclass_results_dict[test_id][channel]['sensitivity'].append( |
| 677 | float('nan')) |
| 678 | |
| 679 | for test_id, test_data in testclass_results_dict.items(): |
| 680 | test_id_dict = dict(test_id) |
| 681 | if 'legacy' in test_id_dict['mode']: |
| 682 | test_id_str = '{} {}Mbps, Chain Mask = {}'.format( |
| 683 | test_id_dict['mode'], test_id_dict['rate'], |
| 684 | test_id_dict['chain_mask']) |
Omar El Ayach | 49141c0 | 2019-09-16 16:43:51 -0700 | [diff] [blame] | 685 | metric_test_config = '{}_{}_ch{}'.format( |
| 686 | test_id_dict['mode'], test_id_dict['rate'], |
| 687 | test_id_dict['chain_mask']) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 688 | else: |
| 689 | test_id_str = '{} MCS{} Nss{}, Chain Mask = {}'.format( |
| 690 | test_id_dict['mode'], test_id_dict['rate'], |
| 691 | test_id_dict['num_streams'], test_id_dict['chain_mask']) |
Omar El Ayach | 49141c0 | 2019-09-16 16:43:51 -0700 | [diff] [blame] | 692 | metric_test_config = '{}_mcs{}_nss{}_ch{}'.format( |
| 693 | test_id_dict['mode'], test_id_dict['rate'], |
| 694 | test_id_dict['num_streams'], test_id_dict['chain_mask']) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 695 | curr_plot = wputils.BokehFigure( |
| 696 | title=str(test_id_str), |
| 697 | x_label='Orientation (deg)', |
Omar El Ayach | 954eb28 | 2019-09-30 15:33:32 -0700 | [diff] [blame] | 698 | primary_y_label='Sensitivity (dBm)') |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 699 | for channel, channel_results in test_data.items(): |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 700 | curr_plot.add_line(channel_results['orientation'], |
| 701 | channel_results['sensitivity'], |
| 702 | legend='Channel {}'.format(channel), |
| 703 | marker='circle') |
Omar El Ayach | 49141c0 | 2019-09-16 16:43:51 -0700 | [diff] [blame] | 704 | metric_tag = 'ota_summary_ch{}_{}'.format( |
| 705 | channel, metric_test_config) |
Omar El Ayach | 40099d0 | 2019-09-12 15:17:33 -0700 | [diff] [blame] | 706 | metric_name = metric_tag + '.avg_sensitivity' |
Omar El Ayach | e972596 | 2019-09-18 17:30:17 -0700 | [diff] [blame] | 707 | metric_value = numpy.nanmean(channel_results['sensitivity']) |
Omar El Ayach | 02a1cce | 2019-09-19 17:51:39 -0700 | [diff] [blame] | 708 | self.testclass_metric_logger.add_metric( |
| 709 | metric_name, metric_value) |
Omar El Ayach | e972596 | 2019-09-18 17:30:17 -0700 | [diff] [blame] | 710 | self.log.info(("Average Sensitivity for {}: {:.2f}").format( |
| 711 | metric_tag, metric_value)) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 712 | current_context = ( |
| 713 | context.get_current_context().get_full_output_path()) |
| 714 | output_file_path = os.path.join(current_context, |
| 715 | str(test_id_str) + '.html') |
| 716 | curr_plot.generate_figure(output_file_path) |
| 717 | plots.append(curr_plot) |
| 718 | output_file_path = os.path.join(current_context, 'results.html') |
| 719 | wputils.BokehFigure.save_figures(plots, output_file_path) |
| 720 | |
| 721 | def get_start_atten(self, testcase_params): |
| 722 | """Gets the starting attenuation for this sensitivity test. |
| 723 | |
| 724 | The function gets the starting attenuation by checking whether a test |
| 725 | at the same rate configuration has executed. If so it sets the starting |
| 726 | point a configurable number of dBs below the reference test. |
| 727 | |
| 728 | Returns: |
| 729 | start_atten: starting attenuation for current test |
| 730 | """ |
| 731 | # Get the current and reference test config. The reference test is the |
| 732 | # one performed at the current MCS+1 |
| 733 | ref_test_params = self.extract_test_id( |
| 734 | testcase_params, |
| 735 | ['channel', 'mode', 'rate', 'num_streams', 'chain_mask']) |
| 736 | # Check if reference test has been run and set attenuation accordingly |
| 737 | previous_params = [ |
| 738 | self.extract_test_id( |
| 739 | result['testcase_params'], |
| 740 | ['channel', 'mode', 'rate', 'num_streams', 'chain_mask']) |
| 741 | for result in self.testclass_results |
| 742 | ] |
| 743 | try: |
| 744 | ref_index = previous_params[::-1].index(ref_test_params) |
| 745 | ref_index = len(previous_params) - 1 - ref_index |
| 746 | start_atten = self.testclass_results[ref_index][ |
| 747 | 'atten_at_range'] - ( |
| 748 | self.testclass_params['adjacent_mcs_range_gap']) |
| 749 | except ValueError: |
| 750 | print('Reference test not found. Starting from {} dB'.format( |
| 751 | self.testclass_params['atten_start'])) |
| 752 | start_atten = self.testclass_params['atten_start'] |
Omar El Ayach | e972596 | 2019-09-18 17:30:17 -0700 | [diff] [blame] | 753 | start_atten = max(start_atten, 0) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 754 | return start_atten |
| 755 | |
Omar El Ayach | ffb5a46 | 2019-09-16 21:05:44 -0700 | [diff] [blame] | 756 | def generate_test_cases(self, channels, modes, requested_rates, chain_mask, |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 757 | angles): |
| 758 | """Function that auto-generates test cases for a test class.""" |
| 759 | test_cases = [] |
| 760 | for channel in channels: |
Omar El Ayach | ffb5a46 | 2019-09-16 21:05:44 -0700 | [diff] [blame] | 761 | requested_modes = set(modes).intersection( |
| 762 | set(self.VALID_TEST_CONFIGS[channel])) |
| 763 | for mode in requested_modes: |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 764 | if 'VHT' in mode: |
| 765 | valid_rates = self.VALID_RATES[mode] |
| 766 | elif 'HT' in mode: |
| 767 | valid_rates = self.VALID_RATES[mode] |
| 768 | elif 'legacy' in mode and channel < 14: |
| 769 | valid_rates = self.VALID_RATES['legacy_2GHz'] |
| 770 | elif 'legacy' in mode and channel > 14: |
| 771 | valid_rates = self.VALID_RATES['legacy_5GHz'] |
| 772 | else: |
| 773 | raise ValueError('Invalid test mode.') |
| 774 | for chain, rate, angle in itertools.product( |
| 775 | chain_mask, valid_rates, angles): |
| 776 | testcase_params = collections.OrderedDict( |
| 777 | channel=channel, |
| 778 | mode=mode, |
| 779 | rate=rate.mcs, |
| 780 | num_streams=rate.streams, |
| 781 | short_gi=1, |
| 782 | chain_mask=chain, |
| 783 | orientation=angle) |
| 784 | if rate not in requested_rates: |
| 785 | continue |
| 786 | if str(chain) in ['0', '1'] and rate[1] == 2: |
| 787 | # Do not test 2-stream rates in single chain mode |
| 788 | continue |
| 789 | if 'legacy' in mode: |
| 790 | testcase_name = ('test_sensitivity_ch{}_{}_{}_nss{}' |
| 791 | '_ch{}_{}deg'.format( |
| 792 | channel, mode, |
| 793 | str(rate.mcs).replace('.', 'p'), |
| 794 | rate.streams, chain, angle)) |
| 795 | else: |
| 796 | testcase_name = ('test_sensitivity_ch{}_{}_mcs{}_nss{}' |
| 797 | '_ch{}_{}deg'.format( |
| 798 | channel, mode, rate.mcs, |
| 799 | rate.streams, chain, angle)) |
| 800 | setattr(self, testcase_name, |
| 801 | partial(self._test_sensitivity, testcase_params)) |
| 802 | test_cases.append(testcase_name) |
Omar El Ayach | f2f99c3 | 2019-09-16 17:18:45 -0700 | [diff] [blame] | 803 | return test_cases |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 804 | |
| 805 | |
Omar El Ayach | a8ed99f | 2019-09-18 13:41:58 -0700 | [diff] [blame] | 806 | class WifiOtaSensitivity_TenDegree_Test(WifiOtaSensitivityTest): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 807 | def __init__(self, controllers): |
Omar El Ayach | 40099d0 | 2019-09-12 15:17:33 -0700 | [diff] [blame] | 808 | WifiOtaSensitivityTest.__init__(self, controllers) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 809 | requested_channels = [6, 36, 149] |
| 810 | requested_rates = [ |
| 811 | self.RateTuple(8, 1, 86.7), |
Omar El Ayach | d9024eb | 2019-09-16 18:22:46 -0700 | [diff] [blame] | 812 | self.RateTuple(2, 1, 21.7), |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 813 | self.RateTuple(8, 2, 173.3), |
Omar El Ayach | d9024eb | 2019-09-16 18:22:46 -0700 | [diff] [blame] | 814 | self.RateTuple(2, 2, 43.3) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 815 | ] |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 816 | self.tests = self.generate_test_cases(requested_channels, |
| 817 | ['VHT20', 'VHT80'], |
| 818 | requested_rates, ['2x2'], |
| 819 | list(range(0, 360, 10))) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 820 | |
| 821 | |
Omar El Ayach | a8ed99f | 2019-09-18 13:41:58 -0700 | [diff] [blame] | 822 | class WifiOtaSensitivity_SingleChain_TenDegree_Test(WifiOtaSensitivityTest): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 823 | def __init__(self, controllers): |
Omar El Ayach | 40099d0 | 2019-09-12 15:17:33 -0700 | [diff] [blame] | 824 | WifiOtaSensitivityTest.__init__(self, controllers) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 825 | requested_channels = [6, 36, 149] |
| 826 | requested_rates = [ |
| 827 | self.RateTuple(8, 1, 86.7), |
Omar El Ayach | d9024eb | 2019-09-16 18:22:46 -0700 | [diff] [blame] | 828 | self.RateTuple(2, 1, 21.7) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 829 | ] |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 830 | self.tests = self.generate_test_cases(requested_channels, |
| 831 | ['VHT20', 'VHT80'], |
| 832 | requested_rates, ['2x2'], |
| 833 | list(range(0, 360, 10))) |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 834 | |
| 835 | |
Omar El Ayach | d3850d0 | 2019-09-23 16:35:49 -0700 | [diff] [blame] | 836 | class WifiOtaSensitivity_ThirtyDegree_Test(WifiOtaSensitivityTest): |
| 837 | def __init__(self, controllers): |
| 838 | WifiOtaSensitivityTest.__init__(self, controllers) |
| 839 | requested_channels = [6, 36, 149] |
| 840 | requested_rates = [ |
| 841 | self.RateTuple(9, 1, 96), |
| 842 | self.RateTuple(8, 1, 86.7), |
| 843 | self.RateTuple(7, 1, 72.2), |
| 844 | self.RateTuple(4, 1, 43.3), |
| 845 | self.RateTuple(2, 1, 21.7), |
| 846 | self.RateTuple(0, 1, 7.2), |
| 847 | self.RateTuple(9, 2, 192), |
| 848 | self.RateTuple(8, 2, 173.3), |
| 849 | self.RateTuple(7, 2, 144.4), |
| 850 | self.RateTuple(4, 2, 86.7), |
| 851 | self.RateTuple(2, 2, 43.3), |
| 852 | self.RateTuple(0, 2, 14.4) |
| 853 | ] |
Omar El Ayach | a218f6b | 2019-11-22 18:24:48 -0800 | [diff] [blame] | 854 | self.tests = self.generate_test_cases(requested_channels, |
| 855 | ['VHT20', 'VHT80'], |
| 856 | requested_rates, ['2x2'], |
| 857 | list(range(0, 360, 30))) |
Omar El Ayach | d3850d0 | 2019-09-23 16:35:49 -0700 | [diff] [blame] | 858 | |
| 859 | |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 860 | class WifiOtaSensitivity_45Degree_Test(WifiOtaSensitivityTest): |
Omar El Ayach | 33f80c0 | 2018-09-27 15:02:03 -0700 | [diff] [blame] | 861 | def __init__(self, controllers): |
Omar El Ayach | 40099d0 | 2019-09-12 15:17:33 -0700 | [diff] [blame] | 862 | WifiOtaSensitivityTest.__init__(self, controllers) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 863 | requested_rates = [ |
| 864 | self.RateTuple(8, 1, 86.7), |
Omar El Ayach | d9024eb | 2019-09-16 18:22:46 -0700 | [diff] [blame] | 865 | self.RateTuple(2, 1, 21.7), |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 866 | self.RateTuple(8, 2, 173.3), |
Omar El Ayach | d9024eb | 2019-09-16 18:22:46 -0700 | [diff] [blame] | 867 | self.RateTuple(2, 2, 43.3) |
Omar El Ayach | bbc6a0a | 2019-07-22 10:26:11 -0700 | [diff] [blame] | 868 | ] |
| 869 | self.tests = self.generate_test_cases( |
Omar El Ayach | ffb5a46 | 2019-09-16 21:05:44 -0700 | [diff] [blame] | 870 | [1, 6, 11, 36, 40, 44, 48, 149, 153, 157, 161], ['VHT20', 'VHT80'], |
| 871 | requested_rates, ['2x2'], list(range(0, 360, 45))) |