Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1283)

Side by Side Diff: autotest/server/hardware_TPMFirmwareServer/hardware_TPMFirmwareServer.py

Issue 3389029: Revive TPM firmware autotest. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: Add TODO. Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import shutil 7 import shutil
8 import sys 8 import sys
9 from autotest_lib.server import test, autotest 9 from autotest_lib.server import test, autotest
10 from autotest_lib.client.bin import utils 10 from autotest_lib.client.bin import utils
11 from autotest_lib.client.common_lib import error 11 from autotest_lib.client.common_lib import error
12 12
13 class hardware_TPMFirmwareServer(test.test): 13 class hardware_TPMFirmwareServer(test.test):
14 """ 14 """
15 Test of TPM functionality needed in firmware (server side of the test). 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 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 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). 18 a new state (for instance between owned and unowned).
19
20 IMPORTANT. This can only run on a machine modified as follows.
21
22 1. The TCSD daemon must not be started. Otherwise the machine might try to
23 take ownership and who knows what else. A good way of preventing this is
24 to comment out 'start tcsd' in /etc/init/tpm-probe.conf.
25
26 2. The firmware on the machine must not send any commands to the TPM,
27 including TPM_Startup.
19 """ 28 """
20 version = 1 29 version = 1
21 n_client_reboots = 0 30 n_client_reboots = 0
22 client_at = None 31 client_at = None
32 test_suffix = ""
23 33
24 # Run the client subtest named [subtest]. 34 # Run the client subtest named [subtest].
25 def tpm_run(self, subtest, ignore_status=False): 35 def tpm_run(self, subtest, ignore_status=False, reboot=True):
26 self.client_at.run_test(self.client_test, subtest=subtest) 36 if (reboot):
37 self.reboot_client()
38 ttag = subtest + self.test_suffix
39 self.client_at.run_test(self.client_test, subtest=subtest, tag=ttag)
27 cstatus = self.job.get_state("client_status") 40 cstatus = self.job.get_state("client_status")
28 logging.info("server: client status = %s", cstatus) 41 logging.info("server: client status = %s", cstatus)
29 self.job.set_state("client_status", None) 42 self.job.set_state("client_status", None)
30 if not ignore_status and cstatus != 0: 43 if not ignore_status and cstatus != 0:
31 error.TestFail("client subtest %s failed with status %s" % 44 error.TestFail("client subtest %s failed with status %s" %
32 (subtest, cstatus)) 45 (subtest, cstatus))
33 return cstatus 46 return cstatus
34 47
35 48
36 def reboot_client(self): 49 def reboot_client(self):
37 # Reboot the client 50 # Reboot the client
38 logging.info('TPMFirmwareServer: rebooting %s number %d' % 51 logging.info('TPMFirmwareServer: rebooting %s number %d' %
39 (self.client.hostname, self.n_client_reboots)) 52 (self.client.hostname, self.n_client_reboots))
40 self.client.reboot() 53 self.client.reboot()
41 self.n_client_reboots += 1 54 self.n_client_reboots += 1
42 55
43 56
57 def run_unowned_only(self):
58 # The fastenable test is implicit in testsetup, but run it anyhow.
59 self.tpm_run("tpmtest_fastenable")
60 # The writelimit test may redundantly clear the TPM.
61 self.tpm_run("tpmtest_writelimit")
62 self.tpm_run("tpmtest_redefine_unowned")
63
64
65 def run_owned_and_unowned(self, suffix):
66 self.test_suffix = suffix
67 self.tpm_run("tpmtest_earlyextend")
68 self.tpm_run("tpmtest_earlynvram")
69 self.tpm_run("tpmtest_earlynvram2")
70 self.tpm_run("tpmtest_globallock")
71 self.tpm_run("tpmtest_spaceperm")
72 self.tpm_run("tpmtest_timing")
73
44 def run_once(self, host=None): 74 def run_once(self, host=None):
45 self.client = host 75 self.client = host
46 self.client_at = autotest.Autotest(self.client) 76 self.client_at = autotest.Autotest(self.client)
47 self.client_test = 'hardware_TPMFirmware' 77 self.client_test = 'hardware_TPMFirmware'
48 78
49 self.job.set_state("client_status", None) 79 self.job.set_state("client_status", None)
50 80
51 # Set up the client in the unowned state. 81 # Set up the client in the unowned state.
52 self.reboot_client() 82 # TODO(semenzato): this should be in a separate "setup" function.
53 self.tpm_run("tpmtest_clear", ignore_status=True) 83 self.tpm_run("tpmtest_testsetup")
54 84
55 self.reboot_client() 85 # Run these unowned only.
56 self.tpm_run("tpmtest_enable", ignore_status=True) 86 self.run_unowned_only()
57 87
58 self.reboot_client() 88 # Run these both owned and unowned.
59 self.tpm_run("tpmtest_readonly") 89 self.run_owned_and_unowned("-u")
60
61 self.reboot_client()
62 self.tpm_run("tpmtest_globallock")
63
64 self.reboot_client()
65 self.tpm_run("takeownership") 90 self.tpm_run("takeownership")
66 91 self.run_owned_and_unowned("-o")
67 self.reboot_client()
68 self.tpm_run("tpmtest_readonly")
69
70 self.reboot_client()
71 self.tpm_run("tpmtest_globallock")
OLDNEW
« no previous file with comments | « autotest/client/hardware_TPMFirmware/hardware_TPMFirmware.py ('k') | tests/tpm_lite/testsetup.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698