1# Copyright 2018 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 5from autotest_lib.client.bin import test 6from autotest_lib.client.bin import utils 7from autotest_lib.client.common_lib import error 8from autotest_lib.client.cros import cryptohome 9 10 11class platform_CryptohomeTpmLiveTest(test.test): 12 """Run cryptohome's TPM live tests.""" 13 version = 1 14 15 def run_once(self): 16 cryptohome.take_tpm_ownership(wait_for_ownership=True) 17 18 tpm_owner_password = cryptohome.get_tpm_status()['Password'] 19 if not tpm_owner_password: 20 raise error.TestError('TPM owner password is empty after taking ' 21 'ownership.') 22 23 # Execute the program which runs the actual test cases. When some test 24 # cases fail, the program will return with a non-zero exit code, 25 # resulting in raising the CmdError exception and failing the autotest. 26 utils.system_output('cryptohome-tpm-live-test', retain_output=True, 27 args=['--owner_password=' + tpm_owner_password]) 28