1"""Suite collecting bluetooth test classes for acceptance testing.""" 2 3import logging 4 5from mobly import test_runner_suite 6 7from blueberry.tests.a2dp import bluetooth_a2dp_test 8from blueberry.tests.avrcp import bluetooth_avrcp_test 9from blueberry.tests.connectivity import ble_pairing_test 10from blueberry.tests.connectivity import bluetooth_pairing_test 11from blueberry.tests.hfp import bluetooth_hfp_test 12from blueberry.tests.map import bluetooth_map_test 13from blueberry.tests.opp import bluetooth_opp_test 14from blueberry.tests.pan import bluetooth_pan_test 15from blueberry.tests.pbap import bluetooth_pbap_test 16 17# Test classes for the Bluetooth acceptance suite. 18TEST_CLASSES = [ 19 bluetooth_pairing_test.BluetoothPairingTest, 20 ble_pairing_test.BlePairingTest, 21 bluetooth_a2dp_test.BluetoothA2dpTest, 22 bluetooth_avrcp_test.BluetoothAvrcpTest, 23 bluetooth_hfp_test.BluetoothHfpTest, 24 bluetooth_map_test.BluetoothMapTest, 25 bluetooth_pbap_test.BluetoothPbapTest, 26 bluetooth_opp_test.BluetoothOppTest, 27 bluetooth_pan_test.BluetoothPanTest 28] 29 30 31class BluetoothAcceptanceSuite(mobly_g3_suite.BaseSuite): 32 """Bluetooth Acceptance Suite. 33 34 Usage of Test selector: 35 Add the parameter "acceptance_test_selector" in the Mobly configuration, it's 36 value is like "test_method_1,test_method_2,...". If this parameter is not 37 used, all tests will be running. 38 """ 39 40 def setup_suite(self, config): 41 selected_tests = None 42 selector = config.user_params.get('acceptance_test_selector') 43 if selector: 44 selected_tests = selector.split(',') 45 logging.info('Selected tests: %s', ' '.join(selected_tests)) 46 # Enable all Bluetooth logging in the first test. 47 first_test_config = config.copy() 48 first_test_config.user_params.update({ 49 'enable_hci_snoop_logging': 1, 50 }) 51 for index, clazz in enumerate(TEST_CLASSES): 52 if selected_tests: 53 matched_tests = None 54 # Gets the same elements between selected_tests and dir(clazz). 55 matched_tests = list(set(selected_tests) & set(dir(clazz))) 56 # Adds the test class if it contains the selected tests. 57 if matched_tests: 58 self.add_test_class( 59 clazz=clazz, 60 config=first_test_config if index == 0 else config, 61 tests=matched_tests) 62 logging.info('Added the tests of "%s": %s', clazz.__name__, 63 ' '.join(matched_tests)) 64 else: 65 self.add_test_class( 66 clazz=clazz, 67 config=first_test_config if index == 0 else config) 68 69 70if __name__ == '__main__': 71 mobly_g3_suite.main() 72