blob: 9df96b5caf76abe5fe895752b31aeee4caa38c00 [file] [log] [blame]
# Copyright 2019 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.
import logging
import re
import time
from autotest_lib.client.common_lib import error
from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
class firmware_Cr50TpmManufactured(FirmwareTest):
"""Check if the TPM is manufactured."""
version = 1
MANUFACTURED_RE = 'tpm_manufactured:( NOT)? manufactured'
def run_once(self):
"""Check if the TPM is manufactured."""
# Signing is different in dev signed images. This test doesn't really
# apply.
if not self.cr50.using_prod_rw_keys():
raise error.TestNAError('Running dev signed image')
# Reset the AP a couple of times in case the console drops any
# characters.
for i in range(self.NUM_RESETS):
# Use cr50 uart capture to check the cr50 console messages. We could
# send sysrst pulse and check the cr50 response, but that would require
# opening cr50 which may not be possible if the TPM isn't manufactured.
# We want to make this as accessible as possible and checking the
# captured uart is the best way to do that.
with open(self.cr50_uart_file, 'r') as f:
contents =
logging.debug('Cr50 reset logs:\n%s', contents)
found = re.findall(self.MANUFACTURED_RE, contents)
# The uart won't be captured if someone has the cr50 console open.
if not found:
raise error.TestNAError('Could not find %r. Close cr50 console' %
logging.debug('Matches for tpm_manufactured: %r', found)
res = set(found)
if len(res) > 1:
raise error.TestError('Found more than one manufacture setting')
manufactured_state = res.pop()'tpm%s manufactured', manufactured_state)
if ' NOT' == manufactured_state:
raise error.TestFail('TPM not manufactured')