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 def BecameThrottled(self, log_line): | 20 @staticmethod |
| 21 def BecameThrottled(log_line): |
21 return 'omap_thermal_throttle' in log_line | 22 return 'omap_thermal_throttle' in log_line |
22 | 23 |
23 def BecameUnthrottled(self, log_line): | 24 @staticmethod |
| 25 def BecameUnthrottled(log_line): |
24 return 'omap_thermal_unthrottle' in log_line | 26 return 'omap_thermal_unthrottle' in log_line |
25 | 27 |
26 def GetThrottlingTemperature(self, log_line): | 28 @staticmethod |
| 29 def GetThrottlingTemperature(log_line): |
27 if 'throttle_delayed_work_fn' in log_line: | 30 if 'throttle_delayed_work_fn' in log_line: |
28 return float([s for s in log_line.split() if s.isdigit()][0]) / 1000.0 | 31 return float([s for s in log_line.split() if s.isdigit()][0]) / 1000.0 |
29 | 32 |
30 def GetCurrentTemperature(self): | 33 def GetCurrentTemperature(self): |
31 tempdata = self._adb.GetFileContents(OmapThrottlingDetector.OMAP_TEMP_FILE) | 34 tempdata = self._adb.GetFileContents(OmapThrottlingDetector.OMAP_TEMP_FILE) |
32 return float(tempdata[0]) / 1000.0 | 35 return float(tempdata[0]) / 1000.0 |
33 | 36 |
34 | 37 |
35 class ExynosThrottlingDetector(object): | 38 class ExynosThrottlingDetector(object): |
36 """Class to detect and track thermal throttling on an Exynos 5.""" | 39 """Class to detect and track thermal throttling on an Exynos 5.""" |
37 @staticmethod | 40 @staticmethod |
38 def IsSupported(adb): | 41 def IsSupported(adb): |
39 return adb.FileExistsOnDevice('/sys/bus/exynos5-core') | 42 return adb.FileExistsOnDevice('/sys/bus/exynos5-core') |
40 | 43 |
41 def __init__(self, adb): | 44 def __init__(self, adb): |
42 pass | 45 pass |
43 | 46 |
44 def BecameThrottled(self, log_line): | 47 @staticmethod |
| 48 def BecameThrottled(log_line): |
45 return 'exynos_tmu: Throttling interrupt' in log_line | 49 return 'exynos_tmu: Throttling interrupt' in log_line |
46 | 50 |
47 def BecameUnthrottled(self, log_line): | 51 @staticmethod |
| 52 def BecameUnthrottled(log_line): |
48 return 'exynos_thermal_unthrottle: not throttling' in log_line | 53 return 'exynos_thermal_unthrottle: not throttling' in log_line |
49 | 54 |
50 def GetThrottlingTemperature(self, log_line): | 55 @staticmethod |
| 56 def GetThrottlingTemperature(_log_line): |
51 return None | 57 return None |
52 | 58 |
53 def GetCurrentTemperature(self): | 59 @staticmethod |
| 60 def GetCurrentTemperature(): |
54 return None | 61 return None |
55 | 62 |
56 | 63 |
57 class ThermalThrottle(object): | 64 class ThermalThrottle(object): |
58 """Class to detect and track thermal throttling. | 65 """Class to detect and track thermal throttling. |
59 | 66 |
60 Usage: | 67 Usage: |
61 Wait for IsThrottled() to be False before running test | 68 Wait for IsThrottled() to be False before running test |
62 After running test call HasBeenThrottled() to find out if the | 69 After running test call HasBeenThrottled() to find out if the |
63 test run was affected by thermal throttling. | 70 test run was affected by thermal throttling. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 122 |
116 # Print temperature of battery, to give a system temperature | 123 # Print temperature of battery, to give a system temperature |
117 dumpsys_log = self._adb.RunShellCommand('dumpsys battery') | 124 dumpsys_log = self._adb.RunShellCommand('dumpsys battery') |
118 for line in dumpsys_log: | 125 for line in dumpsys_log: |
119 if 'temperature' in line: | 126 if 'temperature' in line: |
120 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 | 127 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 |
121 logging.debug(u'Current battery temperature of %s = %3.1f%sC', | 128 logging.debug(u'Current battery temperature of %s = %3.1f%sC', |
122 serial_number, btemp, degree_symbol) | 129 serial_number, btemp, degree_symbol) |
123 | 130 |
124 return has_been_throttled | 131 return has_been_throttled |
OLD | NEW |