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 """Run TPM live tests.""" 17 cryptohome.take_tpm_ownership(wait_for_ownership=True) 18 19 tpm_owner_password = cryptohome.get_tpm_password() 20 if not tpm_owner_password: 21 raise error.TestError('TPM owner password is empty after taking ' 22 'ownership.') 23 24 # Execute the program which runs the actual test cases. When some test 25 # cases fail, the program will return with a non-zero exit code, 26 # resulting in raising the CmdError exception and failing the autotest. 27 utils.system_output('cryptohome-tpm-live-test', retain_output=True, 28 args=['--owner_password=' + tpm_owner_password]) 29