| 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 59da7345668fa53fde00def1e321d42770ab08e4..b6a41b4f14aa63dfba28c64f82e1148f1aadd4fa 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]
|
|
|
|
|
| @@ -64,3 +66,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 = {
|
| + 2901000000: 28560119,
|
| + 2900000000: 20,
|
| + 2800000000: 2,
|
| + 2700000000: 32,
|
| + 2500000000: 3,
|
| + 2400000000: 4,
|
| + 2300000000: 0,
|
| + 2200000000: 0,
|
| + 2000000000: 0,
|
| + 1900000000: 0,
|
| + 1800000000: 0,
|
| + 1700000000: 0,
|
| + 1600000000: 0,
|
| + 1400000000: 0,
|
| + 1300000000: 0,
|
| + 1200000000: 0,
|
| + }
|
| + self.assertEquals(expected, result['GlobalCpuFrequencyStats'])
|
|
|