blob: 274befbd70a55f8595aa1da850d66b623bd1e72c [file] [log] [blame]
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
from autotest_lib.client.bin import utils
from autotest_lib.client.common_lib import error
from autotest_lib.client.cros.bluetooth import bluetooth_semiauto_helper
class bluetooth_AdapterSanity(
"""Checks whether the Bluetooth adapter is present and working."""
version = 1
def _find_kernel_errors(self):
"""Fail test for any suspicious log entries from kernel.
Ignore some known errors in order to find new ones.
fail_terms = ['[^a-z]err[^a-z]']
ignore_terms = ['RFKILL control',
'"Service Changed" characteristic',
'Unknown Evt ID: 19',
'Failed to set privacy: Rejected']
log_cmd = 'grep -i bluetooth /var/log/messages'
for term in ignore_terms:
log_cmd += ' | grep -v \'%s\'' % term
for term in fail_terms:
search_cmd = '%s | grep -i \'%s\'' % (log_cmd, term)
log_entries =, ignore_status=True).stdout
if len(log_entries) > 0:
log_entries = [l for l in log_entries.split('\n') if l != '']
self.collect_logs('Bluetooth kernel error')
# Add snippet of the log to the error message
# unless there are many errors (>5)
# This is helpful when looking at stainless results
error_str = 'Bluetooth kernel error found!'
if len(log_entries) <= 5:
error_str = error_str + ' | '
for l in log_entries:
error_str = error_str + l.split('ERR')[1] + ' | '
raise error.TestFail(error_str)
def warmup(self):
"""Overwrite parent warmup; no need to log in."""
def run_once(self):
"""Entry point of this test."""
if not self.supports_bluetooth():
# Start btmon running.
# Enable then disable adapter.
# Check for errors in logs.