1# Lint as: python2, python3 2# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6from autotest_lib.client.bin import test, utils 7from autotest_lib.client.common_lib import error 8from autotest_lib.client.cros import service_stopper 9 10 11class kernel_TPMStress(test.test): 12 "TPM communication stress test" 13 version = 1 14 15 16 def initialize(self): 17 self._services = service_stopper.ServiceStopper(['cryptohomed', 18 'chapsd', 19 'attestationd', 20 'tpm_managerd', 21 'tcsd', 'trunksd']) 22 self._services.stop_services() 23 24 25 def run_once(self): 26 # On a Mario, running the test with 1000 iterations takes 89 seconds, 27 # and with 2000 iterations 163 seconds, i.e. the incremental time for 1 28 # iteration is 74ms. 29 n_iterations = 3000 30 31 try: 32 for iteration in range(n_iterations): 33 utils.system("tpmc getpf") 34 except Exception: 35 raise error.TestError(("TPM communication error at " + 36 "iteration %d of %d") % 37 (iteration, n_iterations)) 38 39 40 def cleanup(self): 41 self._services.restore_services() 42