1# Copyright 2022 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 6import time 7 8from autotest_lib.client.common_lib import error 9from autotest_lib.client.common_lib.cros import cr50_utils 10from autotest_lib.server.cros.faft.cr50_test import Cr50Test 11 12 13class firmware_Cr50FIPSDS(Cr50Test): 14 """ 15 Verify cr50 fips works after coming out of deep sleep. 16 """ 17 version = 1 18 19 def apshutdown(self): 20 """Shutdown the AP and give cr50 enough time to enter deep sleep.""" 21 self.cr50.ccd_disable() 22 self.set_ap_off_power_mode('shutdown') 23 self.cr50.clear_deep_sleep_count() 24 time.sleep(30) 25 26 def check_ds_resume(self): 27 """Check the system resumed ok.""" 28 29 if not self.cr50.fips_crypto_allowed(): 30 raise error.TestFail('Crypto not allowed after deep sleep') 31 # Make sure the EC jumped to RW. This could catch ec-efs issues. 32 logging.info( 33 self.ec.send_command_get_output('sysinfo', ['Jumped: yes'])) 34 if not self.cr50.get_deep_sleep_count(): 35 raise error.TestError('Cr50 did not enter deep sleep') 36 # Make sure the DUT fully booted and is sshable. 37 logging.info('Running %r', cr50_utils.GetRunningVersion(self.host)) 38 39 def run_once(self, host): 40 """Verify FIPS after deep sleep.""" 41 if not self.cr50.has_command('fips'): 42 raise error.TestNAError('Cr50 does not support fips') 43 44 # Verify EC sysjump works on deep sleep resume. 45 self.apshutdown() 46 self.ec.reboot() 47 time.sleep(7) 48 self.check_ds_resume() 49 50 # Verify the AP can boot after resume without EC reset. 51 self.apshutdown() 52 self.servo.power_normal_press() 53 time.sleep(7) 54 self.check_ds_resume() 55