Home | History | Annotate | Download | only in firmware_Cr50VirtualNVRamServer
      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 from autotest_lib.client.common_lib import error
      6 from autotest_lib.client.common_lib.cros import tpm_utils
      7 from autotest_lib.server import autotest
      8 from autotest_lib.server import test
      9 
     10 
     11 class 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         self.client = host
     20 
     21         # Skip the test if the TPM is unavailable.
     22         tpm_status = tpm_utils.TPMStatus(self.client)
     23         if 'Enabled' not in tpm_status:
     24             raise error.TestError('Error obtaining TPM enabled state. Status '
     25                                   'returned by cryptohome: ' + str(tpm_status))
     26         if not tpm_status['Enabled']:
     27             raise error.TestNAError("TPM is not enabled")
     28 
     29         # Clear the TPM, so that the client test is able to obtain the TPM owner
     30         # password.
     31         tpm_utils.ClearTPMOwnerRequest(self.client, wait_for_ready=True)
     32 
     33         # Run the client test which executes the Cr50VirtualNVRam test.
     34         autotest.Autotest(self.client).run_test(
     35                 'firmware_Cr50VirtualNVRam', check_client_result=True)
     36 
     37         # Clean the TPM up, so that the TPM state set by the firmware
     38         # tests doesn't affect subsequent tests.
     39         tpm_utils.ClearTPMOwnerRequest(self.client)
     40