1# Lint as: python2, python3 2# Copyright 2021 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 7Bluetooth tests which involve modifying attenuation between the 8DUT and peer using controllable variable attentuator. 9 10These tests can only be run in test bed containing variable attenuator 11and bluetooth peer. 12 13""" 14 15 16 17 18import logging 19 20from autotest_lib.server.cros.bluetooth.bluetooth_adapter_quick_tests import ( 21 BluetoothAdapterQuickTests) 22from autotest_lib.server.cros.bluetooth.bluetooth_rvr_tests import ( 23 BluetoothAdapterRvRTests) 24 25test_wrapper = BluetoothAdapterQuickTests.quick_test_test_decorator 26batch_wrapper = BluetoothAdapterQuickTests.quick_test_batch_decorator 27 28 29class bluetooth_AdapterRvR(BluetoothAdapterQuickTests, 30 BluetoothAdapterRvRTests): 31 """ Collection of Bluetooth Range vs Rate tests. 32 33 rvr_show_rssi_vs_attenuation : This is not a test. It display RSSI vs 34 attenutation for the test bed. This is used lab team to verify test beds. 35 36 """ 37 38 @test_wrapper( 39 'RSSI vs Attenuation', 40 devices={'MOUSE': 1}, 41 ) 42 def rvr_show_rssi_vs_attenuation(self): 43 """ Record RSSI at increasing attenuation """ 44 try: 45 device_type = 'MOUSE' 46 device = self.devices[device_type][0] 47 logging.debug(' attenutor is %s', self.bt_attenuator) 48 rssi_dict = self.check_rssi_vs_attenuation(device, 49 self.bt_attenuator) 50 if rssi_dict == {}: 51 logging.info( 52 'check_rssi_vs_attenuation did not return any data') 53 return False 54 else: 55 logging.info('--------------------------') 56 logging.info('Total attenutation : RSSI') 57 for attn in sorted(list(rssi_dict.keys())): 58 rssi = rssi_dict[attn] 59 logging.info('%s : %s', attn, rssi) 60 logging.info('--------------------------') 61 return True 62 except Exception as e: 63 logging.error('Exception in rvr_show_rssi_vs_attenuation %s', 64 str(e)) 65 return False 66 67 @batch_wrapper('Range vs Rate tests') 68 def rvr_health_batch_run(self, num_iterations=1, test_name=None): 69 """ Batch of Range vs Rate tests health tests. """ 70 self.rvr_show_rssi_vs_attenutation() 71 72 def run_once(self, 73 host, 74 num_iterations=1, 75 args_dict=None, 76 test_name=None, 77 flag='Quick Health'): 78 """Running Bluetooth adapter suspend resume with peer autotest. 79 80 @param host: the DUT, usually a chromebook 81 @param num_iterations: the number of times to execute the test 82 @param test_name: the test to run or None for all tests 83 @param flag: run tests with this flag (default: Quick Health) 84 85 """ 86 87 # Initialize and run the test batch or the requested specific test 88 self.quick_test_init(host, 89 use_btpeer=True, 90 flag=flag, 91 args_dict=args_dict) 92 self.rvr_health_batch_run(num_iterations, test_name) 93 self.quick_test_cleanup() 94