1# Copyright 2018 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 6import logging 7import subprocess 8 9from autotest_lib.client.common_lib import error 10 11 12def detect(): 13 """ 14 Checks whether or not a device equips kepler by using 'lspci'. 15 16 @returns string: 'kepler' if a device equips kepler, empty string otherwise. 17 """ 18 kepler_id = '1ae0:001a' 19 try: 20 lspci_result = subprocess.check_output(['lspci', '-n', '-d', kepler_id]) 21 logging.debug("lspci output:\n%s", lspci_result) 22 return 'kepler' if lspci_result.strip() else '' 23 except subprocess.CalledProcessError: 24 logging.exception('lspci failed.') 25 raise error.TestFail('Fail to execute "lspci"') 26