blob: 8be2b791235c05733f16c3c8c8326e51391fb3b2 [file] [log] [blame]
Zdenek Behan6667f0a2010-09-07 18:06:38 -07001# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import logging, os, re, sys, shutil
6from autotest_lib.client.bin import test, utils
7
8class hardware_TPMFirmware(test.test):
9 """
10 Test of TPM functionality needed in firmware (client side of the test).
11 See also server/site_tests/hardware_TPMFirmwareServer.
12 """
13 version = 1
14 preserve_srcdir = True
15
Zdenek Behan6667f0a2010-09-07 18:06:38 -070016 def setup(self):
Zdenek Behan6667f0a2010-09-07 18:06:38 -070017 utils.make('-C %s' % self.srcdir)
18
Zdenek Behan6667f0a2010-09-07 18:06:38 -070019 # Runs a command, logs the output, and returns the exit status.
20 def tpm_run(self, cmd, ignore_status=False):
21 output = utils.run(cmd, ignore_status=ignore_status)
22 logging.info(output)
23 self.job.set_state("client_status", output.exit_status)
24
25
Zdenek Behan6667f0a2010-09-07 18:06:38 -070026 def run_once(self, subtest='None'):
27 logging.info("Running TPM firmware client subtest %s", subtest)
Luigi Semenzato9565edc2010-09-30 13:44:00 -070028 if (subtest == 'takeownership'):
29 output = utils.run("start tcsd", ignore_status=False)
30 # When TCSD is running, the system might try to take ownership as
31 # well. We don't care.
32 logging.info(output)
33 own_cmd = "tpm_takeownership -y -z"
34 self.tpm_run(own_cmd, ignore_status=True)
35 else:
Zdenek Behan6667f0a2010-09-07 18:06:38 -070036 cmd = os.path.join(self.srcdir, subtest)
37 self.tpm_run(cmd, ignore_status=True)