• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5import logging
6
7from autotest_lib.client.common_lib import error
8from autotest_lib.server.cros.faft.firmware_test import FirmwareTest
9
10
11class firmware_ECAdc(FirmwareTest):
12    """
13    Servo based EC ADC test.
14    """
15    version = 1
16
17    # Repeat read count
18    READ_COUNT = 200
19
20    def _check_read(self):
21        """Read EC internal temperature by EC ADC.
22
23        Raises:
24          error.TestFail: Raised when read fails.
25        """
26        t = int(self.ec.send_command_get_output("temps",
27                ["ECInternal\s+: (\d+) K"])[0][1])
28        if t < 273 or t > 373:
29            raise error.TestFail("Abnormal EC temperature %d K" % t)
30
31    def run_once(self):
32        if not self.check_ec_capability(['adc_ectemp']):
33            raise error.TestNAError("Nothing needs to be tested on this device")
34        logging.info("Reading EC internal temperature for %d times.",
35                     self.READ_COUNT)
36        for _ in xrange(self.READ_COUNT):
37            self._check_read()
38