summaryrefslogtreecommitdiff
path: root/autotest
diff options
context:
space:
mode:
authorZdenek Behan <zbehan@chromium.org>2010-09-07 18:06:38 -0700
committerZdenek Behan <zbehan@chromium.org>2010-09-07 18:06:38 -0700
commit6667f0ad82c3c6634b102f8c30a72eebe576b3f4 (patch)
tree579886e3f850afbb4081f6b5b10fba37bacf60b8 /autotest
parentb3e07ca7931b4326e00b9ab256e9f4356f3aabab (diff)
downloadvboot-6667f0ad82c3c6634b102f8c30a72eebe576b3f4.tar.gz
vboot_reference: add hardware_TPMFirmware test case into vboot_reference repo
* The files it needs to build are here Change-Id: I95973a9d96e7be6d7359a44b44337fdb9bfe0d92 BUG= TEST= Review URL: http://codereview.chromium.org/3335010
Diffstat (limited to 'autotest')
-rw-r--r--autotest/hardware_TPMFirmware/control20
-rw-r--r--autotest/hardware_TPMFirmware/hardware_TPMFirmware.py61
-rw-r--r--autotest/hardware_TPMFirmware/src/Makefile35
3 files changed, 116 insertions, 0 deletions
diff --git a/autotest/hardware_TPMFirmware/control b/autotest/hardware_TPMFirmware/control
new file mode 100644
index 00000000..e59b7d20
--- /dev/null
+++ b/autotest/hardware_TPMFirmware/control
@@ -0,0 +1,20 @@
+# 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.
+
+AUTHOR = "Chrome OS Team"
+NAME = "hardware_TPMFirmware"
+PURPOSE = "Verify that system firmware is compatible with TPM device."
+CRITERIA = "This will run a suite of server-side TPM tests."
+TIME = "MEDIUM"
+TEST_CATEGORY = "Functionality"
+TEST_CLASS = "hardware"
+TEST_TYPE = "client"
+
+DOC = """
+Hardware test for the TPM functionality needed in the firmware.
+This test requires a modified BIOS that issues no commands to the TPM.
+This test is driven by a server-side test (hardware_TPMFirmwareServer).
+"""
+
+job.run_test('hardware_TPMFirmware')
diff --git a/autotest/hardware_TPMFirmware/hardware_TPMFirmware.py b/autotest/hardware_TPMFirmware/hardware_TPMFirmware.py
new file mode 100644
index 00000000..9fc9a82a
--- /dev/null
+++ b/autotest/hardware_TPMFirmware/hardware_TPMFirmware.py
@@ -0,0 +1,61 @@
+# 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 = utils.run(cmd, ignore_status=ignore_status)
+ logging.info(output)
+ 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):
+ utils.run('mknod /dev/tpm c 10 224', ignore_status=True)
+ utils.run('mknod /dev/tpm0 c 10 224', ignore_status=True)
+ utils.run('modprobe tpm_tis force=1 interrupts=0', ignore_status=True)
+
+ if (with_tcsd):
+ utils.run('/usr/sbin/tcsd')
+ else:
+ # It will be a problem if upstart automatically restarts tcsd.
+ utils.run('pkill tcsd', ignore_status=True)
+
+
+ def run_once(self, subtest='None'):
+ logging.info("Running TPM firmware client subtest %s", subtest)
+ if (subtest == 'setup'):
+ self.tpm_setup()
+ self.tpm_write_status(0)
+ elif (subtest == 'takeownership'):
+ self.tpm_setup(with_tcsd=True)
+ own_cmd = os.path.join(self.bindir, "tpm_takeownership -y -z")
+ self.tpm_run(own_cmd)
+ else:
+ self.tpm_setup()
+ cmd = os.path.join(self.srcdir, subtest)
+ self.tpm_run(cmd, ignore_status=True)
diff --git a/autotest/hardware_TPMFirmware/src/Makefile b/autotest/hardware_TPMFirmware/src/Makefile
new file mode 100644
index 00000000..d864f40d
--- /dev/null
+++ b/autotest/hardware_TPMFirmware/src/Makefile
@@ -0,0 +1,35 @@
+# 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.
+
+TPM = tpm
+TPM_SRC_DIR = $(GCLIENT_ROOT)/src/third_party/$(TPM)
+TPM_WORK_DIR = $(TPM)
+
+TLCL = tpm_lite
+TLCL_SRC_DIR = $(GCLIENT_ROOT)/src/platform/$(TLCL)
+TLCL_WORK_DIR = $(TLCL)
+
+BINDIR = .
+PROGRAMS = \
+ clear \
+ enable \
+ globallock \
+ lock \
+ readonly \
+ writelimit
+
+all:
+ rm -rf $(TPM_WORK_DIR)
+ cp -a $(TPM_SRC_DIR) $(TPM_WORK_DIR)
+ $(MAKE) -C $(TPM_WORK_DIR)/nvtool clean
+ $(MAKE) -C $(TPM_WORK_DIR)/nvtool
+ rm -rf $(TLCL_WORK_DIR)
+ cp -a $(TLCL_SRC_DIR) $(TLCL_WORK_DIR)
+ $(MAKE) -C $(TLCL_WORK_DIR)/src clean
+ $(MAKE) cross USE_TPM_EMULATOR=0 -C $(TLCL_WORK_DIR)/src
+ # gets rid of host binary which confuses ARM build
+ rm $(TLCL_WORK_DIR)/src/tlcl/generator
+ cp $(TPM_WORK_DIR)/nvtool/tpm-nvtool $(BINDIR)
+ set -e; for i in $(PROGRAMS); \
+ do cp $(TLCL_WORK_DIR)/src/testsuite/tpmtest_$$i $(BINDIR); done