| 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 unittest | 5 import unittest |
| 6 | 6 |
| 7 from telemetry import decorators | 7 from telemetry import decorators |
| 8 from telemetry.internal.platform import android_device | 8 from telemetry.internal.platform import android_device |
| 9 from telemetry.internal.platform import android_platform_backend | 9 from telemetry.internal.platform import android_platform_backend |
| 10 from telemetry.testing import system_stub | 10 from telemetry.testing import system_stub |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 with mock.patch('devil.android.device_utils.DeviceUtils.ReadFile', | 94 with mock.patch('devil.android.device_utils.DeviceUtils.ReadFile', |
| 95 return_value=''): | 95 return_value=''): |
| 96 backend = android_platform_backend.AndroidPlatformBackend( | 96 backend = android_platform_backend.AndroidPlatformBackend( |
| 97 android_device.AndroidDevice('1234')) | 97 android_device.AndroidDevice('1234')) |
| 98 cpu_stats = backend.GetCpuStats('7702') | 98 cpu_stats = backend.GetCpuStats('7702') |
| 99 self.assertEquals(cpu_stats, {}) | 99 self.assertEquals(cpu_stats, {}) |
| 100 | 100 |
| 101 @decorators.Disabled('chromeos', 'mac', 'win') | 101 @decorators.Disabled('chromeos', 'mac', 'win') |
| 102 def testAndroidParseCpuStates(self): | 102 def testAndroidParseCpuStates(self): |
| 103 cstate = { | 103 cstate = { |
| 104 'cpu0': 'C0\nC1\n103203424\n5342040\n300\n500\n1403232500', | 104 'cpu0': 'C0\nC1\n103203424\n5342040\n300\n500\n1403232500', |
| 105 'cpu1': 'C0\n124361858\n300\n1403232500' | 105 'cpu1': 'C0\n124361858\n300\n1403232500' |
| 106 } | 106 } |
| 107 expected_cstate = { | 107 expected_cstate = { |
| 108 'cpu0': { | 108 'cpu0': { |
| 109 'WFI': 103203424, | 109 'WFI': 103203424, |
| 110 'C0': 1403232391454536, | 110 'C0': 1403232391454536, |
| 111 'C1': 5342040 | 111 'C1': 5342040 |
| 112 }, | 112 }, |
| 113 'cpu1': { | 113 'cpu1': { |
| 114 'WFI': 124361858, | 114 'WFI': 124361858, |
| 115 'C0': 1403232375638142 | 115 'C0': 1403232375638142 |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 # Use mock start and end times to allow for the test to calculate C0. | 118 # Use mock start and end times to allow for the test to calculate C0. |
| 119 result = android_platform_backend.AndroidPlatformBackend.ParseCStateSample( | 119 result = android_platform_backend.AndroidPlatformBackend.ParseCStateSample( |
| 120 cstate) | 120 cstate) |
| 121 for cpu in result: | 121 for cpu in result: |
| 122 for state in result[cpu]: | 122 for state in result[cpu]: |
| 123 self.assertAlmostEqual(result[cpu][state], expected_cstate[cpu][state]) | 123 self.assertAlmostEqual(result[cpu][state], expected_cstate[cpu][state]) |
| 124 | 124 |
| 125 @decorators.Disabled('chromeos', 'mac', 'win') | 125 @decorators.Disabled('chromeos', 'mac', 'win') |
| 126 def testInstallTestCaSuccess(self): | 126 def testInstallTestCaSuccess(self): |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 android_platform_backend.psutil = psutil | 223 android_platform_backend.psutil = psutil |
| 224 | 224 |
| 225 # Mock an empty /proc/pid/stat. | 225 # Mock an empty /proc/pid/stat. |
| 226 with mock.patch('devil.android.device_utils.DeviceUtils.ReadFile', | 226 with mock.patch('devil.android.device_utils.DeviceUtils.ReadFile', |
| 227 return_value=''): | 227 return_value=''): |
| 228 backend = android_platform_backend.AndroidPlatformBackend( | 228 backend = android_platform_backend.AndroidPlatformBackend( |
| 229 android_device.AndroidDevice('1234')) | 229 android_device.AndroidDevice('1234')) |
| 230 cpu_stats = backend.GetCpuStats('7702') | 230 cpu_stats = backend.GetCpuStats('7702') |
| 231 self.assertEquals({}, cpu_stats) | 231 self.assertEquals({}, cpu_stats) |
| 232 self.assertEquals([[0]], psutil.set_cpu_affinity_args) | 232 self.assertEquals([[0]], psutil.set_cpu_affinity_args) |
| OLD | NEW |