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',
     18                                                          'attestationd',
     19                                                          'tpm_managerd',
     20                                                          'tcsd', 'trunksd'])
     21         self._services.stop_services()
     22 
     23 
     24     def run_once(self):
     25         # On a Mario, running the test with 1000 iterations takes 89 seconds,
     26         # and with 2000 iterations 163 seconds, i.e. the incremental time for 1
     27         # iteration is 74ms.
     28         n_iterations = 3000
     29 
     30         try:
     31             for iteration in range(n_iterations):
     32                 utils.system("tpmc getpf")
     33         except Exception:
     34             raise error.TestError(("TPM communication error at " +
     35                                    "iteration %d of %d") %
     36                                   (iteration, n_iterations))
     37 
     38 
     39     def cleanup(self):
     40         self._services.restore_services()
     41