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 5from autotest_lib.client.common_lib import error 6from autotest_lib.client.common_lib.cros import tpm_utils 7from autotest_lib.server import autotest 8from autotest_lib.server import test 9 10 11class firmware_Cr50VirtualNVRamServer(test.test): 12 """ 13 A test that runs firmware_Cr50VirtualNVRam, clearing the TPM first as 14 necessary. 15 """ 16 version = 1 17 18 def run_once(self, host=None): 19 """Runs a single iteration of the test.""" 20 self.client = host 21 22 # Skip the test if the TPM is unavailable. 23 tpm_status = tpm_utils.TPMStatus(self.client) 24 if 'is_enabled' not in tpm_status: 25 raise error.TestError('Error obtaining TPM enabled state. Status ' 26 'returned by cryptohome: ' + str(tpm_status)) 27 if not tpm_status['is_enabled']: 28 raise error.TestNAError("TPM is not enabled") 29 30 # Clear the TPM, so that the client test is able to obtain the TPM owner 31 # password. 32 tpm_utils.ClearTPMOwnerRequest(self.client, wait_for_ready=True) 33 34 # Run the client test which executes the Cr50VirtualNVRam test. 35 autotest.Autotest(self.client).run_test( 36 'firmware_Cr50VirtualNVRam', check_client_result=True) 37 38 # Clean the TPM up, so that the TPM state set by the firmware 39 # tests doesn't affect subsequent tests. 40 tpm_utils.ClearTPMOwnerRequest(self.client) 41