Home | History | Annotate | Download | only in firmware_ECPeci
      1 # Copyright (c) 2012 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 import logging
      6 
      7 from autotest_lib.client.common_lib import error
      8 from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
      9 
     10 
     11 class firmware_ECPeci(FirmwareTest):
     12     """
     13     Servo based EC PECI test.
     14     """
     15     version = 1
     16 
     17     # Repeat read count
     18     READ_COUNT = 200
     19 
     20     def initialize(self, host, cmdline_args):
     21         super(firmware_ECPeci, self).initialize(host, cmdline_args)
     22         self.ec.send_command("chan 0")
     23 
     24     def cleanup(self):
     25         self.ec.send_command("chan 0xffffffff")
     26         super(firmware_ECPeci, self).cleanup()
     27 
     28     def _check_read(self):
     29         """Read CPU temperature through PECI.
     30 
     31         Raises:
     32           error.TestFail: Raised when read fails.
     33         """
     34         t = int(self.ec.send_command_get_output("pecitemp",
     35                 ["CPU temp = (\d+) K"])[0][1])
     36         if t < 273 or t > 400:
     37             raise error.TestFail("Abnormal CPU temperature %d K" % t)
     38 
     39     def run_once(self):
     40         if not self.check_ec_capability(['peci']):
     41             raise error.TestNAError("Nothing needs to be tested on this device")
     42         logging.info("Reading PECI CPU temperature for %d times.",
     43                      self.READ_COUNT)
     44         for _ in xrange(self.READ_COUNT):
     45             self._check_read()
     46