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 5import logging 6 7from autotest_lib.client.common_lib import error 8from autotest_lib.server.cros.faft.firmware_test import FirmwareTest 9 10 11class firmware_Cr50Open(FirmwareTest): 12 """Verify cr50 unlock. 13 14 Enable the lock on cr50, run 'lock disable', and then press the power 15 button until it is unlocked. 16 """ 17 version = 1 18 19 def initialize(self, host, cmdline_args): 20 """Initialize the test""" 21 super(firmware_Cr50Open, self).initialize(host, cmdline_args) 22 23 if not hasattr(self, 'cr50'): 24 raise error.TestNAError('Test can only be run on devices with ' 25 'access to the Cr50 console') 26 if self.cr50.using_ccd(): 27 raise error.TestNAError('Use a flex cable instead of CCD cable.') 28 29 if not self.cr50.has_command('ccdstate'): 30 raise error.TestNAError('Cannot test on Cr50 with old CCD version') 31 32 33 def run_once(self, ccd_lockout): 34 """Lock CCD and then Open it.""" 35 self.cr50.set_ccd_level('lock') 36 try: 37 self.cr50.set_ccd_level('open') 38 success = True 39 except error.TestFail, e: 40 logging.debug(e) 41 if 'Access Denied' in e.message: 42 success = False 43 else: 44 raise 45 46 ccd_status_str = 'locked out' if ccd_lockout else 'accessible' 47 # Make sure we only got 'Access Denied' when ccd is locked out and open 48 # was successful only when ccd is accessible. 49 if success == ccd_lockout: 50 raise error.TestFail('ccd open %sed with ccd %s' % ('succeed' 51 if success else 'fail', ccd_status_str)) 52 logging.info('ccd open is %s', ccd_status_str) 53 54