blob: 9fc9a82a6f887ed9bf05114e6aa3500ee44309da [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
# Cross-compiles TLCL test suite and other needed code.
# TODO(semenzato): tpm_takeownership is currently available by making
# tpm-tools an RDEPEND in the autotest ebuild. See that file for a
# better way.
def setup(self):
sysroot = os.environ['SYSROOT']
bin_path = os.path.join(sysroot, 'usr/sbin/tpm_takeownership')
shutil.copy(bin_path, self.bindir)
utils.make('-C %s' % self.srcdir)
# 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):'/usr/sbin/tcsd')
# It will be a problem if upstart automatically restarts tcsd.'pkill 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 = os.path.join(self.bindir, "tpm_takeownership -y -z")
cmd = os.path.join(self.srcdir, subtest)
self.tpm_run(cmd, ignore_status=True)