blob: f860484c9b1a9f176500ea65fc8ec39bc962eefe [file] [log] [blame]
# Copyright 2016 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.
from autotest_lib.client.common_lib import error
from autotest_lib.server import test
# Max number of devices to check in /sys/class/input to see if one of them is an
# input device.
class brillo_KernelHeadsetTest(test.test):
"""Verify that a Brillo device supports headsets.
This test is required if the Brillo board has an audio jack."""
version = 1
def run_once(self, host=None):
"""Runs the test.
@param host: A host object representing the DUT.
# Check for headset support.
found_headset = False
for device_num in range(_MAX_DEVICES):
result = host.run_output(
'cat sys/class/input/event%i/device/name' % device_num,
if 'Headset' in result:
found_headset = True
if not found_headset:
raise error.TestNAError('Could not find headset input device.')
# Check for h2w driver.
result = host.run_output('cat /sys/class/switch/h2w/name',
if 'h2w' not in result:
raise error.TestNAError('h2w driver not found.')