blob: 1ebc3fb7c4b1478bc6e97ce288876cd6dc31f505 [file] [log] [blame]
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from autotest_lib.client.bin import test
from autotest_lib.client.common_lib import error, pexpect
from autotest_lib.client.cros import cryptohome
class factory_TPM(test.test):
""" Tests the TPM for a valid endorsement key."""
version = 1
def __tpm_clear(self, tpm_password):
"""Clear the TPM using a previously saved password."""
tpm_clear = pexpect.spawn('tpm_clear')
tpm_clear.expect('password: ')
out =
if 'failed' in out:
raise error.TestError('tpm_clear failed: %s' % out)
def run_once(self, clear_tpm_owner=True):
status = cryptohome.get_tpm_status()
if not status['Enabled']:
raise error.TestError("TPM is not enabled.")
if not status['Owned']:
result = cryptohome.verify_ek()
if clear_tpm_owner:
status = cryptohome.get_tpm_status()
if status['Password'] == '':
raise error.TestError("TPM owner password is not available. "
"Boot in recovery mode to clear the TPM.")
if not result:
raise error.TestFail("TPM endorsement key is not valid.")