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 6 import os 7 import shutil 8 import sys 9 from autotest_lib.server import test, autotest 10 from autotest_lib.client.bin import utils 11 from autotest_lib.client.common_lib import error 12 13 class platform_CryptohomeTPMReOwnServer(test.test): 14 """ 15 The server-side controller for verifying that cryptohome can re-create a 16 user's vault if the TPM is cleared and re-owned. 17 """ 18 version = 1 19 n_client_reboots = 0 20 client_at = None 21 22 # Run the client subtest named [subtest]. 23 def tpm_run(self, subtest, ignore_status=False): 24 self.client_at.run_test(self.client_test, subtest=subtest) 25 cstatus = self.job.get_state("client_status") 26 logging.info("server: client status = %s", cstatus) 27 self.job.set_state("client_status", None) 28 if not ignore_status and cstatus != 'Success': 29 error.TestFail("client subtest %s failed with status %s" % 30 (subtest, cstatus)) 31 return cstatus 32 33 34 def reboot_client(self): 35 # Reboot the client 36 logging.info('CryptohomeTPMReOwnServer: rebooting %s number %d' % 37 (self.client.hostname, self.n_client_reboots)) 38 self.client.reboot() 39 self.n_client_reboots += 1 40 41 42 def run_once(self, host=None): 43 self.client = host 44 self.client_at = autotest.Autotest(self.client) 45 self.client_test = 'platform_CryptohomeTPMReOwn' 46 47 self.job.set_state("client_status", None) 48 49 # Set up the client in the unowned state. 50 self.reboot_client() 51 self.tpm_run("clear_tpm", ignore_status=True) 52 53 self.reboot_client() 54 self.tpm_run("enable_tpm", ignore_status=True) 55 56 self.reboot_client() 57 self.tpm_run("mount_cryptohome") 58 59 self.reboot_client() 60 self.tpm_run("mount_cryptohome_after_reboot") 61 62 self.reboot_client() 63 self.tpm_run("clear_tpm", ignore_status=True) 64 65 self.reboot_client() 66 self.tpm_run("enable_tpm", ignore_status=True) 67 68 self.reboot_client() 69 self.tpm_run("mount_cryptohome_check_recreate") 70