1 # Copyright 2016 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 from autotest_lib.client.common_lib import error 6 from autotest_lib.server import test 7 8 9 # Max number of devices to check in /sys/class/input to see if one of them is an 10 # input device. 11 _MAX_DEVICES = 100 12 13 14 class brillo_KernelHeadsetTest(test.test): 15 """Verify that a Brillo device supports headsets. 16 17 This test is required if the Brillo board has an audio jack.""" 18 version = 1 19 20 def run_once(self, host=None): 21 """Runs the test. 22 23 @param host: A host object representing the DUT. 24 25 """ 26 # Check for headset support. 27 found_headset = False 28 for device_num in range(_MAX_DEVICES): 29 result = host.run_output( 30 'cat sys/class/input/event%i/device/name' % device_num, 31 ignore_status=True) 32 if 'Headset' in result: 33 found_headset = True 34 35 if not found_headset: 36 raise error.TestNAError('Could not find headset input device.') 37 38 # Check for h2w driver. 39 result = host.run_output('cat /sys/class/switch/h2w/name', 40 ignore_status=True) 41 if 'h2w' not in result: 42 raise error.TestNAError('h2w driver not found.') 43