| Index: tools/telemetry/telemetry/core/platform/proc_supporting_platform_backend_unittest.py
|
| diff --git a/tools/telemetry/telemetry/core/platform/proc_supporting_platform_backend_unittest.py b/tools/telemetry/telemetry/core/platform/proc_supporting_platform_backend_unittest.py
|
| index 81069b841cf3dec57ea2888aa99cd33d5f8d33f1..0e5a6a2766b8f88e33b38fb2ac15239a8a3b2d0d 100644
|
| --- a/tools/telemetry/telemetry/core/platform/proc_supporting_platform_backend_unittest.py
|
| +++ b/tools/telemetry/telemetry/core/platform/proc_supporting_platform_backend_unittest.py
|
| @@ -22,6 +22,8 @@ class TestBackend(
|
| self._mock_files[filename] = output
|
|
|
| def _GetFileContents(self, filename):
|
| + if filename not in self._mock_files:
|
| + raise IOError(filename)
|
| return self._mock_files[filename]
|
|
|
|
|
| @@ -70,3 +72,36 @@ class ProcSupportingPlatformBackendTest(unittest.TestCase):
|
| 'VMPeak': 1025978368,
|
| 'WorkingSetSize': 84000768,
|
| 'WorkingSetSizePeak': 84000768})
|
| +
|
| + def testGlobalCpuStats(self):
|
| + if not proc_supporting_platform_backend.resource:
|
| + logging.warning('Test not supported')
|
| + return
|
| +
|
| + backend = TestBackend()
|
| + backend.SetMockFile('/sys/devices/system/cpu/kernel_max', '63')
|
| + for cpu in range(2, 5):
|
| + backend.SetMockFile(
|
| + '/sys/devices/system/cpu/cpu%d/cpufreq/stats/time_in_state' % cpu,
|
| + open(os.path.join(util.GetUnittestDataDir(),
|
| + 'cpu_%d_time_in_state' % cpu)).read())
|
| + result = backend.GetGlobalCpuStats()
|
| + expected = {
|
| + 2901000: 28560119,
|
| + 2900000: 20,
|
| + 2800000: 2,
|
| + 2700000: 32,
|
| + 2500000: 3,
|
| + 2400000: 4,
|
| + 2300000: 0,
|
| + 2200000: 0,
|
| + 2000000: 0,
|
| + 1900000: 0,
|
| + 1800000: 0,
|
| + 1700000: 0,
|
| + 1600000: 0,
|
| + 1400000: 0,
|
| + 1300000: 0,
|
| + 1200000: 0,
|
| + }
|
| + self.assertEquals(expected, result['GlobalCpuFrequencyStats'])
|
|
|