1# Copyright (C) 2024 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""This test suite batches all tests to run in sequence. 16 17This requires 3 APs to be ready and configured in testbed. 182G AP (wifi_2g_ssid): channel 6 (2437) 195G AP (wifi_5g_ssid): channel 36 (5180) 20DFS 5G AP(wifi_dfs_5g_ssid): channel 52 (5260) 21""" 22 23import os 24import sys 25 26# Allows local imports to be resolved via relative path, so the test can be run 27# without building. 28_betocq_dir = os.path.dirname(os.path.dirname(__file__)) 29if _betocq_dir not in sys.path: 30 sys.path.append(_betocq_dir) 31 32from mobly import suite_runner 33 34from betocq import base_betocq_suite 35from betocq import nc_constants 36from betocq.compound_tests import bt_2g_wifi_coex_test 37from betocq.compound_tests import mcc_5g_all_wifi_non_dbs_2g_sta_test 38from betocq.compound_tests import scc_2g_all_wifi_sta_test 39from betocq.compound_tests import scc_5g_all_wifi_dbs_2g_sta_test 40from betocq.compound_tests import scc_5g_all_wifi_sta_test 41from betocq.directed_tests import ble_performance_test 42from betocq.directed_tests import bt_performance_test 43from betocq.directed_tests import mcc_2g_wfd_indoor_5g_sta_test 44from betocq.directed_tests import mcc_5g_hotspot_dfs_5g_sta_test 45from betocq.directed_tests import mcc_5g_wfd_dfs_5g_sta_test 46from betocq.directed_tests import mcc_5g_wfd_non_dbs_2g_sta_test 47from betocq.directed_tests import mcc_aware_2g_5g_sta_test 48from betocq.directed_tests import scc_2g_wfd_sta_test 49from betocq.directed_tests import scc_2g_wlan_sta_test 50from betocq.directed_tests import scc_5g_aware_sta_test 51from betocq.directed_tests import scc_5g_wfd_dbs_2g_sta_test 52from betocq.directed_tests import scc_5g_wfd_sta_test 53from betocq.directed_tests import scc_5g_wlan_sta_test 54from betocq.directed_tests import scc_dfs_5g_hotspot_sta_test 55from betocq.directed_tests import scc_dfs_5g_wfd_sta_test 56from betocq.directed_tests import scc_indoor_5g_wfd_sta_test 57from betocq.function_tests import beto_cq_function_group_test 58from betocq.function_tests import nearbyconnections_function_test 59 60 61class BetoCqPerformanceTestSuite(base_betocq_suite.BaseBetocqSuite): 62 """Add all BetoCQ tests to run in sequence.""" 63 64 def __init__(self, runner, config): 65 super().__init__(runner, config) 66 self._enabled_test_classes = {} 67 68 def enable_test_class(self, clazz, config=None): 69 """Enable the test class within the suite. 70 71 Once enabled, the test class will run if the user selects it explicitly from 72 the command line, or by default if no user selection is made. 73 74 Args: 75 clazz: class, a Mobly test class. 76 config: config_parser.TestRunConfig, the config to run the class with. If 77 not specified, the loaded config file is used as is. 78 """ 79 self._enabled_test_classes[clazz] = config 80 81 def add_enabled_test_classes_from_selection(self): 82 """Add enabled test classes to run, based on the user selection.""" 83 test_selector = suite_runner._parse_cli_args(None).tests 84 selected_tests = suite_runner.compute_selected_tests( 85 self._enabled_test_classes.keys(), test_selector 86 ) 87 for test_class, tests in selected_tests.items(): 88 self.add_test_class( 89 test_class, config=self._enabled_test_classes[test_class], tests=tests 90 ) 91 92 def setup_suite(self, config): 93 """Add all BetoCQ tests to the suite.""" 94 test_parameters = nc_constants.TestParameters.from_user_params( 95 config.user_params 96 ) 97 98 if test_parameters.target_cuj_name == nc_constants.TARGET_CUJ_ESIM: 99 self.enable_test_class(bt_performance_test.BtPerformanceTest) 100 return 101 102 # enable function tests if required 103 if ( 104 test_parameters.run_function_tests_with_performance_tests 105 or test_parameters.use_auto_controlled_wifi_ap 106 ): 107 self.enable_test_class( 108 beto_cq_function_group_test.BetoCqFunctionGroupTest 109 ) 110 111 # enable nearby connections function tests if required 112 if test_parameters.run_nearby_connections_function_tests: 113 self.add_test_class( 114 nearbyconnections_function_test.NearbyConnectionsFunctionTest 115 ) 116 117 if test_parameters.run_bt_coex_test: 118 self.enable_test_class(bt_2g_wifi_coex_test.Bt2gWifiCoexTest) 119 120 # enable bt and ble test 121 if test_parameters.run_bt_performance_test: 122 self.enable_test_class(bt_performance_test.BtPerformanceTest) 123 124 if test_parameters.run_ble_performance_test: 125 self.enable_test_class(ble_performance_test.BlePerformanceTest) 126 127 # enable directed/cuj tests which requires 2G wlan AP - channel 6 128 if ( 129 test_parameters.wifi_2g_ssid 130 or test_parameters.use_auto_controlled_wifi_ap 131 ): 132 config = self._config.copy() 133 config.user_params['wifi_channel'] = 6 134 135 if test_parameters.run_directed_test: 136 self.enable_test_class( 137 clazz=mcc_5g_wfd_non_dbs_2g_sta_test.Mcc5gWfdNonDbs2gStaTest, 138 config=config, 139 ) 140 self.enable_test_class( 141 clazz=scc_2g_wfd_sta_test.Scc2gWfdStaTest, 142 config=config, 143 ) 144 self.enable_test_class( 145 clazz=scc_2g_wlan_sta_test.Scc2gWlanStaTest, 146 config=config, 147 ) 148 self.enable_test_class( 149 clazz=scc_5g_wfd_dbs_2g_sta_test.Scc5gWfdDbs2gStaTest, 150 config=config, 151 ) 152 if test_parameters.run_compound_test: 153 self.enable_test_class( 154 clazz=mcc_5g_all_wifi_non_dbs_2g_sta_test.Mcc5gAllWifiNonDbs2gStaTest, 155 config=config, 156 ) 157 self.enable_test_class( 158 clazz=scc_2g_all_wifi_sta_test.Scc2gAllWifiStaTest, 159 config=config, 160 ) 161 self.enable_test_class( 162 clazz=scc_5g_all_wifi_dbs_2g_sta_test.Scc5gAllWifiDbs2gStaTest, 163 config=config, 164 ) 165 166 # enable directed tests which requires 5G wlan AP - channel 36 167 if ( 168 test_parameters.wifi_5g_ssid 169 or test_parameters.use_auto_controlled_wifi_ap 170 ): 171 config = self._config.copy() 172 config.user_params['wifi_channel'] = 36 173 174 if test_parameters.run_directed_test: 175 self.enable_test_class( 176 clazz=mcc_2g_wfd_indoor_5g_sta_test.Mcc2gWfdIndoor5gStaTest, 177 config=config, 178 ) 179 self.enable_test_class( 180 clazz=scc_5g_wfd_sta_test.Scc5gWfdStaTest, 181 config=config, 182 ) 183 if test_parameters.run_aware_test: 184 self.add_test_class( 185 clazz=scc_5g_aware_sta_test.Scc5gAwareStaTest, 186 config=config, 187 ) 188 self.add_test_class( 189 clazz=mcc_aware_2g_5g_sta_test.MccAware2g5gStaTest, 190 config=config, 191 ) 192 self.enable_test_class( 193 clazz=scc_5g_wlan_sta_test.Scc5gWifiLanStaTest, 194 config=config, 195 ) 196 self.enable_test_class( 197 clazz=scc_indoor_5g_wfd_sta_test.SccIndoor5gWfdStaTest, 198 config=config, 199 ) 200 if test_parameters.run_compound_test: 201 self.enable_test_class( 202 clazz=scc_5g_all_wifi_sta_test.Scc5gAllWifiStaTest, 203 config=config, 204 ) 205 206 # enable directed/cuj tests which requires DFS 5G wlan AP - channel 52 207 if ( 208 test_parameters.wifi_dfs_5g_ssid 209 or test_parameters.use_auto_controlled_wifi_ap 210 ): 211 config = self._config.copy() 212 config.user_params['wifi_channel'] = 52 213 214 if test_parameters.run_directed_test: 215 self.enable_test_class( 216 clazz=mcc_5g_hotspot_dfs_5g_sta_test.Mcc5gHotspotDfs5gStaTest, 217 config=config, 218 ) 219 self.enable_test_class( 220 clazz=mcc_5g_wfd_dfs_5g_sta_test.Mcc5gWfdDfs5gStaTest, 221 config=config, 222 ) 223 self.enable_test_class( 224 clazz=scc_dfs_5g_hotspot_sta_test.SccDfs5gHotspotStaTest, 225 config=config, 226 ) 227 self.enable_test_class( 228 clazz=scc_dfs_5g_wfd_sta_test.SccDfs5gWfdStaTest, 229 config=config, 230 ) 231 232 self.add_enabled_test_classes_from_selection() 233 234 235if __name__ == '__main__': 236 # Use suite_runner's `main`. 237 suite_runner.run_suite_class() 238