• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5import logging
6import os
7import shutil
8import sys
9from autotest_lib.server import test, autotest
10from autotest_lib.client.bin import utils
11from autotest_lib.client.common_lib import error
12
13class hardware_TPMFirmwareServer(test.test):
14    """
15    Test of TPM functionality needed in firmware (server side of the test).
16    See also client/site_tests/hardware_TPMFirmware.  The server side of the
17    test is used to coordinate the multiple reboots needed to bring the TPM to
18    a new state (for instance between owned and unowned).
19    """
20    version = 1
21    n_client_reboots = 0
22    client_at = None
23
24    # Run the client subtest named [subtest].
25    def tpm_run(self, subtest, ignore_status=False):
26        self.client_at.run_test(self.client_test, subtest=subtest)
27        cstatus = self.job.get_state("client_status")
28        logging.info("server: client status = %s", cstatus)
29        self.job.set_state("client_status", None)
30        if not ignore_status and cstatus != 0:
31            error.TestFail("client subtest %s failed with status %s" %
32                           (subtest, cstatus))
33        return cstatus
34
35
36    def reboot_client(self):
37        # Reboot the client
38        logging.info('TPMFirmwareServer: rebooting %s number %d' %
39                     (self.client.hostname, self.n_client_reboots))
40        self.client.reboot()
41        self.n_client_reboots += 1
42
43
44    def run_once(self, host=None):
45        self.client = host
46        self.client_at = autotest.Autotest(self.client)
47        self.client_test = 'hardware_TPMFirmware'
48
49        self.job.set_state("client_status", None)
50
51        # Set up the client in the unowned state.
52        self.reboot_client()
53        self.tpm_run("tpmtest_clear", ignore_status=True)
54
55        self.reboot_client()
56        self.tpm_run("tpmtest_enable", ignore_status=True)
57
58        self.reboot_client()
59        self.tpm_run("tpmtest_readonly")
60
61        self.reboot_client()
62        self.tpm_run("tpmtest_globallock")
63
64        self.reboot_client()
65        self.tpm_run("takeownership")
66
67        self.reboot_client()
68        self.tpm_run("tpmtest_readonly")
69
70        self.reboot_client()
71        self.tpm_run("tpmtest_globallock")
72