OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2012 The Chromium 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 class ThermalThrottle(object): |
| 8 """Class to detect and track thermal throttling |
| 9 |
| 10 Usage: |
| 11 Wait for IsThrottled() to be False before running test |
| 12 After running test call HasBeenThrottled() to find out if the |
| 13 test run was affected by thermal throttling. |
| 14 |
| 15 Currently assumes an OMap device. |
| 16 """ |
| 17 def __init__(self, adb): |
| 18 self._adb = adb |
| 19 self._throttled = False |
| 20 |
| 21 |
| 22 def HasBeenThrottled(self): |
| 23 """ True if there has been any throttling since the last call to |
| 24 HasBeenThrottled or IsThrottled |
| 25 """ |
| 26 return self._ReadLog() |
| 27 |
| 28 def IsThrottled(self): |
| 29 """True if currently throttled""" |
| 30 self._ReadLog() |
| 31 return self._throttled |
| 32 |
| 33 def _ReadLog(self): |
| 34 has_been_throttled = False |
| 35 log = self._adb.RunShellCommand('dmesg -c') |
| 36 for line in log: |
| 37 if 'omap_thermal_throttle' in line: |
| 38 if not self._throttled: |
| 39 logging.warning('>>> Thermally Throttled') |
| 40 self._throttled = True |
| 41 has_been_throttled = True |
| 42 if 'omap_thermal_unthrottle' in line: |
| 43 if self._throttled: |
| 44 logging.warning('>>> Thermally Unthrottled') |
| 45 self._throttled = False |
| 46 has_been_throttled = True |
| 47 return has_been_throttled |
OLD | NEW |