1# Lint as: python2, python3 2# Copyright 2020 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6"""A Batch of Bluetooth advertising tests""" 7 8from autotest_lib.server.cros.bluetooth.bluetooth_adapter_tests import ( 9 SUSPEND_POWER_DOWN_CHIPSETS, SUSPEND_RESET_IF_NO_PEER_CHIPSETS, 10 SUSPEND_POWER_DOWN_MODELS) 11from autotest_lib.server.cros.bluetooth import advertisements_data 12from autotest_lib.server.cros.bluetooth.bluetooth_adapter_quick_tests import \ 13 BluetoothAdapterQuickTests 14from autotest_lib.server.cros.bluetooth.bluetooth_adapter_leadvertising_tests \ 15 import bluetooth_AdapterLEAdvertising 16 17class bluetooth_AdapterAdvHealth(BluetoothAdapterQuickTests, 18 bluetooth_AdapterLEAdvertising): 19 20 """A Batch of Bluetooth advertising tests. This test is written as 21 a batch of tests in order to reduce test time, since auto-test ramp up 22 time is costy. The batch is using BluetoothAdapterQuickTests wrapper 23 methods to start and end a test and a batch of tests. 24 25 This class can be called to run the entire test batch or to run a 26 specific test only 27 """ 28 29 test_wrapper = BluetoothAdapterQuickTests.quick_test_test_decorator 30 batch_wrapper = BluetoothAdapterQuickTests.quick_test_batch_decorator 31 32 33 # TODO(b/192419579) - RTL8822 and 8852 can't advertise 4 connectable 34 # advertisements. 35 @test_wrapper('Multiple LE advertising test', 36 skip_chipsets=[ 37 'Realtek-RTL8822C-USB', 'Realtek-RTL8822C-UART', 38 'Realtek-RTL8852A-USB' 39 ], 40 skip_common_errors=True) 41 def adv_multiple_advertising_test(self): 42 """Run all test cases for multiple advertisements.""" 43 self.run_le_advertising_test( 44 self.host, advertisements_data.ADVERTISEMENTS, 45 'multi_advertising', num_iterations=1) 46 47 48 @test_wrapper('Single LE advertising test') 49 def adv_single_advertising_test(self): 50 """Run all test cases for single advertisements.""" 51 self.run_le_advertising_test( 52 self.host, advertisements_data.ADVERTISEMENTS, 53 'single_advertising', num_iterations=1) 54 55 56 # TODO(b/150897528) - Scarlet Dru loses firmware around suspend 57 # TODO(b/182172118) - Winky has suspend test issues 58 # TODO(b/189813813) - Scarlet Dumo loses firmware around suspend 59 @test_wrapper('Suspend resume LE advertising test', 60 skip_models=SUSPEND_POWER_DOWN_MODELS + ['winky'], 61 skip_chipsets=SUSPEND_POWER_DOWN_CHIPSETS + 62 SUSPEND_RESET_IF_NO_PEER_CHIPSETS, 63 skip_common_errors=True) 64 def adv_suspend_resume_advertising_test(self): 65 """Run all test cases for advertisements involving suspend resume.""" 66 self.run_le_advertising_test( 67 self.host, advertisements_data.ADVERTISEMENTS, 68 'suspend_resume', num_iterations=1) 69 70 71 @test_wrapper('Reboot LE advertising test') 72 def adv_reboot_advertising_test(self): 73 """Run all test cases for advertisements involving reboot.""" 74 self.run_le_advertising_test( 75 self.host, advertisements_data.ADVERTISEMENTS, 76 'reboot', num_iterations=1) 77 78 79 @test_wrapper('Advertising peer test', devices={'BLE_MOUSE':1}) 80 def adv_peer_test(self): 81 """Verify advertising from a peer""" 82 83 device = self.devices['BLE_MOUSE'][0] 84 85 self.advertising_peer_test(device) 86 87 @test_wrapper('Advertising Nearby test') 88 def adv_nearby_test(self): 89 """Verify minimal Nearby advertising requirements""" 90 91 self.run_le_advertising_test(self.host, 92 advertisements_data.ADVERTISEMENTS, 93 'nearby', 94 num_iterations=1) 95 96 @test_wrapper('Broadcast advertising test') 97 def adv_broadcast_test(self): 98 """Verify broadcast advertising capability""" 99 100 self.run_le_advertising_test(self.host, 101 advertisements_data.ADVERTISEMENTS, 102 'broadcast', 103 num_iterations=1) 104 105 # TODO(b/150897528) - Scarlet Dru loses firmware around suspend 106 # TODO(b/189813813) - Scarlet Dumo loses firmware around suspend 107 @test_wrapper('Advertising suspend peer test', 108 devices={'BLE_MOUSE': 1}, 109 skip_models=SUSPEND_POWER_DOWN_MODELS, 110 skip_chipsets=SUSPEND_POWER_DOWN_CHIPSETS + 111 SUSPEND_RESET_IF_NO_PEER_CHIPSETS, 112 skip_common_errors=True) 113 def adv_suspend_peer_test(self): 114 """Verify advertising around suspend from a peer""" 115 116 device = self.devices['BLE_MOUSE'][0] 117 118 self.advertising_peer_suspend_resume_test(device) 119 120 @batch_wrapper('Advertising Health') 121 def adv_health_batch_run(self, num_iterations=1, test_name=None): 122 """Run the advertising health test batch or a specific given test. 123 The wrapper of this method is implemented in batch_decorator. 124 Using the decorator a test batch method can implement the only its 125 core tests invocations and let the decorator handle the wrapper, 126 which is taking care for whether to run a specific test or the 127 batch as a whole, and running the batch in iterations 128 129 @param num_iterations: how many iterations to run 130 @param test_name: specific test to run otherwise None to run the 131 whole batch 132 """ 133 self.adv_peer_test() 134 self.adv_multiple_advertising_test() 135 self.adv_single_advertising_test() 136 self.adv_suspend_resume_advertising_test() 137 self.adv_reboot_advertising_test() 138 self.adv_nearby_test() 139 140 141 def run_once(self, 142 host, 143 num_iterations=1, 144 args_dict=None, 145 test_name=None, 146 flag='Quick Health', 147 peer_required=True): 148 """Run the batch of Bluetooth advertising health tests 149 150 @param host: the DUT, usually a chromebook 151 @param num_iterations: the number of rounds to execute the test 152 """ 153 # Initialize and run the test batch or the requested specific test 154 self.quick_test_init(host, 155 use_btpeer=peer_required, 156 flag=flag, 157 args_dict=args_dict) 158 self.adv_health_batch_run(num_iterations, test_name) 159 self.quick_test_cleanup() 160