blob: 2e964e7d05ca1ec7fafb80035beb353f67e9453b [file] [log] [blame]
# Copyright (c) 2010 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, os, re, sys, shutil
from autotest_lib.client.bin import test, utils
class hardware_TPMFirmware(test.test):
Test of TPM functionality needed in firmware (client side of the test).
See also server/site_tests/hardware_TPMFirmwareServer.
version = 1
preserve_srcdir = True
# Copies the TLCL test suite which is not installed by default on the test
# image.
def setup(self):
sysroot = os.environ.get('SYSROOT', '/')
bin_path = os.path.join(sysroot, 'usr/bin')
for f in os.listdir(bin_path):
if re.match('tpmtest_.*', f):
shutil.copy(os.path.join(bin_path, f), self.bindir)
# Runs a command, logs the output, and returns the exit status.
def tpm_run(self, cmd, ignore_status=False):
output =, ignore_status=ignore_status)
self.job.set_state("client_status", output.exit_status)
# Sets up the system (if it isn't already) to run the tpm binaries. This
# is mostly needed after a reboot. We don't rely on the system booting in
# any particular state.
def tpm_setup(self, with_tcsd=False):'mknod /dev/tpm c 10 224', ignore_status=True)'mknod /dev/tpm0 c 10 224', ignore_status=True)'modprobe tpm_tis force=1 interrupts=0', ignore_status=True)
if (with_tcsd):'start tcsd')
# It will be a problem if upstart automatically restarts tcsd.'stop tcsd', ignore_status=True)
def run_once(self, subtest='None'):"Running TPM firmware client subtest %s", subtest)
if (subtest == 'setup'):
elif (subtest == 'takeownership'):
own_cmd = '/usr/local/sbin/tpm_takeownership -y -z'
cmd = os.path.join(self.bindir, subtest)
self.tpm_run(cmd, ignore_status=True)