Home | History | Annotate | Download | only in kernel_TPMStress
      1 # Copyright (c) 2011 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 from autotest_lib.client.bin import test, utils
      6 from autotest_lib.client.common_lib import error
      7 from autotest_lib.client.cros import service_stopper
      8 
      9 
     10 class kernel_TPMStress(test.test):
     11     "TPM communication stress test"
     12     version = 1
     13 
     14 
     15     def initialize(self):
     16         self._services = service_stopper.ServiceStopper(['cryptohomed',
     17                                                          'chapsd', 'tcsd'])
     18         self._services.stop_services()
     19 
     20 
     21     def run_once(self):
     22         # On a Mario, running the test with 1000 iterations takes 89 seconds,
     23         # and with 2000 iterations 163 seconds, i.e. the incremental time for 1
     24         # iteration is 74ms.
     25         n_iterations = 3000
     26 
     27         try:
     28             for iteration in range(n_iterations):
     29                 utils.system("tpmc getpf")
     30         except Exception:
     31             raise error.TestError(("TPM communication error at " +
     32                                    "iteration %d of %d") %
     33                                   (iteration, n_iterations))
     34 
     35 
     36     def cleanup(self):
     37         self._services.restore_services()
     38