1# Copyright 2017 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5"""Server side bluetooth adapter stress tests involving reboot. 6First we test powering on the adapter, reboot the DUT, and make sure 7the adapter is still powered on and in a working state. 8 9Next we test powering off the adapter, reboot, and verify the adapter 10is still powered off. 11""" 12 13import logging 14 15from autotest_lib.client.bin import utils 16from autotest_lib.client.common_lib import error 17from autotest_lib.server.cros.bluetooth import bluetooth_adapter_tests 18from autotest_lib.server.cros.multimedia import bluetooth_le_facade_adapter 19 20 21test_case_log = bluetooth_adapter_tests.test_case_log 22 23 24class bluetooth_AdapterReboot( 25 bluetooth_adapter_tests.BluetoothAdapterTests): 26 """Server side bluetooth adapter reboot test.""" 27 28 # --------------------------------------------------------------- 29 # Definitions of all test cases 30 # --------------------------------------------------------------- 31 32 @test_case_log 33 def test_case_adapter_on_reboot(self): 34 """Test Case: Power on - reboot""" 35 self.test_power_on_adapter() 36 self.test_bluetoothd_running() 37 self.host.reboot() 38 # NOTE: We need to recreate the bluetooth_facade after a reboot. 39 self.bluetooth_facade = self.ble_adapter(self.host) 40 self.test_bluetoothd_running() 41 self.test_adapter_work_state() 42 self.test_power_on_adapter() 43 44 @test_case_log 45 def test_case_adapter_off_reboot(self): 46 """Test Case: Power on - reboot""" 47 self.test_power_off_adapter() 48 self.test_bluetoothd_running() 49 self.host.reboot() 50 # NOTE: We need to recreate the bluetooth_facade after a reboot. 51 self.bluetooth_facade = self.ble_adapter(self.host) 52 self.test_power_off_adapter() 53 self.test_bluetoothd_running() 54 55 56 def run_once(self, host, num_iterations=1): 57 """Running Bluetooth adapter reboot autotest. 58 59 @param host: device under test host. 60 @param num_iterations: number of times to perform reboot tests. 61 62 """ 63 self.host = host 64 self.ble_adapter = bluetooth_le_facade_adapter.BluetoothLEFacadeRemoteAdapter 65 self.bluetooth_facade = self.ble_adapter(self.host) 66 67 for i in xrange(num_iterations): 68 logging.debug('Starting loop #%d', i) 69 self.test_case_adapter_on_reboot() 70 self.test_case_adapter_off_reboot() 71 72 if self.fails: 73 raise error.TestFail(self.fails) 74