| 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..4c14cc41d26a03ee17c3659c718d95e0d47962da 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_hz': 28560119,
|
| + '2900000_hz': 20,
|
| + '2800000_hz': 2,
|
| + '2700000_hz': 32,
|
| + '2500000_hz': 3,
|
| + '2400000_hz': 4,
|
| + '2300000_hz': 0,
|
| + '2200000_hz': 0,
|
| + '2000000_hz': 0,
|
| + '1900000_hz': 0,
|
| + '1800000_hz': 0,
|
| + '1700000_hz': 0,
|
| + '1600000_hz': 0,
|
| + '1400000_hz': 0,
|
| + '1300000_hz': 0,
|
| + '1200000_hz': 0,
|
| + }
|
| + self.assertEquals(expected, result['GlobalCpuFrequencyStats'])
|
|
|