| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 | 6 |
| 7 | 7 |
| 8 class OmapThrottlingDetector(object): | 8 class OmapThrottlingDetector(object): |
| 9 """Class to detect and track thermal throttling on an OMAP 4.""" | 9 """Class to detect and track thermal throttling on an OMAP 4.""" |
| 10 OMAP_TEMP_FILE = ('/sys/devices/platform/omap/omap_temp_sensor.0/' | 10 OMAP_TEMP_FILE = ('/sys/devices/platform/omap/omap_temp_sensor.0/' |
| 11 'temperature') | 11 'temperature') |
| 12 | 12 |
| 13 @staticmethod | 13 @staticmethod |
| 14 def IsSupported(adb): | 14 def IsSupported(adb): |
| 15 return adb.FileExistsOnDevice(OmapThrottlingDetector.OMAP_TEMP_FILE) | 15 return adb.FileExistsOnDevice(OmapThrottlingDetector.OMAP_TEMP_FILE) |
| 16 | 16 |
| 17 def __init__(self, adb): | 17 def __init__(self, adb): |
| 18 self._adb = adb | 18 self._adb = adb |
| 19 | 19 |
| 20 @staticmethod | 20 def BecameThrottled(self, log_line): |
| 21 def BecameThrottled(log_line): | |
| 22 return 'omap_thermal_throttle' in log_line | 21 return 'omap_thermal_throttle' in log_line |
| 23 | 22 |
| 24 @staticmethod | 23 def BecameUnthrottled(self, log_line): |
| 25 def BecameUnthrottled(log_line): | |
| 26 return 'omap_thermal_unthrottle' in log_line | 24 return 'omap_thermal_unthrottle' in log_line |
| 27 | 25 |
| 28 @staticmethod | 26 def GetThrottlingTemperature(self, log_line): |
| 29 def GetThrottlingTemperature(log_line): | |
| 30 if 'throttle_delayed_work_fn' in log_line: | 27 if 'throttle_delayed_work_fn' in log_line: |
| 31 return float([s for s in log_line.split() if s.isdigit()][0]) / 1000.0 | 28 return float([s for s in log_line.split() if s.isdigit()][0]) / 1000.0 |
| 32 | 29 |
| 33 def GetCurrentTemperature(self): | 30 def GetCurrentTemperature(self): |
| 34 tempdata = self._adb.GetFileContents(OmapThrottlingDetector.OMAP_TEMP_FILE) | 31 tempdata = self._adb.GetFileContents(OmapThrottlingDetector.OMAP_TEMP_FILE) |
| 35 return float(tempdata[0]) / 1000.0 | 32 return float(tempdata[0]) / 1000.0 |
| 36 | 33 |
| 37 | 34 |
| 38 class ExynosThrottlingDetector(object): | 35 class ExynosThrottlingDetector(object): |
| 39 """Class to detect and track thermal throttling on an Exynos 5.""" | 36 """Class to detect and track thermal throttling on an Exynos 5.""" |
| 40 @staticmethod | 37 @staticmethod |
| 41 def IsSupported(adb): | 38 def IsSupported(adb): |
| 42 return adb.FileExistsOnDevice('/sys/bus/exynos5-core') | 39 return adb.FileExistsOnDevice('/sys/bus/exynos5-core') |
| 43 | 40 |
| 44 def __init__(self, adb): | 41 def __init__(self, adb): |
| 45 pass | 42 pass |
| 46 | 43 |
| 47 @staticmethod | 44 def BecameThrottled(self, log_line): |
| 48 def BecameThrottled(log_line): | |
| 49 return 'exynos_tmu: Throttling interrupt' in log_line | 45 return 'exynos_tmu: Throttling interrupt' in log_line |
| 50 | 46 |
| 51 @staticmethod | 47 def BecameUnthrottled(self, log_line): |
| 52 def BecameUnthrottled(log_line): | |
| 53 return 'exynos_thermal_unthrottle: not throttling' in log_line | 48 return 'exynos_thermal_unthrottle: not throttling' in log_line |
| 54 | 49 |
| 55 @staticmethod | 50 def GetThrottlingTemperature(self, log_line): |
| 56 def GetThrottlingTemperature(_log_line): | |
| 57 return None | 51 return None |
| 58 | 52 |
| 59 @staticmethod | 53 def GetCurrentTemperature(self): |
| 60 def GetCurrentTemperature(): | |
| 61 return None | 54 return None |
| 62 | 55 |
| 63 | 56 |
| 64 class ThermalThrottle(object): | 57 class ThermalThrottle(object): |
| 65 """Class to detect and track thermal throttling. | 58 """Class to detect and track thermal throttling. |
| 66 | 59 |
| 67 Usage: | 60 Usage: |
| 68 Wait for IsThrottled() to be False before running test | 61 Wait for IsThrottled() to be False before running test |
| 69 After running test call HasBeenThrottled() to find out if the | 62 After running test call HasBeenThrottled() to find out if the |
| 70 test run was affected by thermal throttling. | 63 test run was affected by thermal throttling. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 115 |
| 123 # Print temperature of battery, to give a system temperature | 116 # Print temperature of battery, to give a system temperature |
| 124 dumpsys_log = self._adb.RunShellCommand('dumpsys battery') | 117 dumpsys_log = self._adb.RunShellCommand('dumpsys battery') |
| 125 for line in dumpsys_log: | 118 for line in dumpsys_log: |
| 126 if 'temperature' in line: | 119 if 'temperature' in line: |
| 127 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 | 120 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 |
| 128 logging.debug(u'Current battery temperature of %s = %3.1f%sC', | 121 logging.debug(u'Current battery temperature of %s = %3.1f%sC', |
| 129 serial_number, btemp, degree_symbol) | 122 serial_number, btemp, degree_symbol) |
| 130 | 123 |
| 131 return has_been_throttled | 124 return has_been_throttled |
| OLD | NEW |