Zdenek Behan | 6667f0a | 2010-09-07 18:06:38 -0700 | [diff] [blame] | 1 | # 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 | |
| 5 | import logging, os, re, sys, shutil |
| 6 | from autotest_lib.client.bin import test, utils |
| 7 | |
| 8 | class 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 Behan | 6667f0a | 2010-09-07 18:06:38 -0700 | [diff] [blame] | 16 | def setup(self): |
Zdenek Behan | 6667f0a | 2010-09-07 18:06:38 -0700 | [diff] [blame] | 17 | utils.make('-C %s' % self.srcdir) |
| 18 | |
Zdenek Behan | 6667f0a | 2010-09-07 18:06:38 -0700 | [diff] [blame] | 19 | # 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 Behan | 6667f0a | 2010-09-07 18:06:38 -0700 | [diff] [blame] | 26 | def run_once(self, subtest='None'): |
| 27 | logging.info("Running TPM firmware client subtest %s", subtest) |
Luigi Semenzato | 9565edc | 2010-09-30 13:44:00 -0700 | [diff] [blame^] | 28 | 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 Behan | 6667f0a | 2010-09-07 18:06:38 -0700 | [diff] [blame] | 36 | cmd = os.path.join(self.srcdir, subtest) |
| 37 | self.tpm_run(cmd, ignore_status=True) |