| Index: tools/telemetry/telemetry/core/platform/power_monitor/cros_sysfs_platform_unittest.py
|
| diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/cros_sysfs_platform_unittest.py b/tools/telemetry/telemetry/core/platform/power_monitor/cros_sysfs_platform_unittest.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4504848a01a076d97eddbebc15ef6b8510ec04c9
|
| --- /dev/null
|
| +++ b/tools/telemetry/telemetry/core/platform/power_monitor/cros_sysfs_platform_unittest.py
|
| @@ -0,0 +1,39 @@
|
| +# Copyright 2014 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import unittest
|
| +
|
| +from telemetry.core.platform.power_monitor import cros_sysfs_platform
|
| +
|
| +
|
| +class CrosSysfsPlatformTest(unittest.TestCase):
|
| + start_time = 1403211341
|
| + initial_cstate = {
|
| + 'cpu0': 'POLL\nC1\nC2\nC3\n0\n138356189\n102416540\n'
|
| + '17158209182\n0\n1\n500\n1000',
|
| + 'cpu1': 'POLL\nC1\nC2\nC3\n0\n107318149\n81786238\n'
|
| + '17348563431\n0\n1\n500\n1000'
|
| + }
|
| + expected_cstate = {
|
| + 'cpu0': {
|
| + 'C0': 1403193942018089,
|
| + 'C1': 138356189,
|
| + 'C2': 102416540,
|
| + 'C3': 17158209182
|
| + },
|
| + 'cpu1': {
|
| + 'C0': 1403193803332182,
|
| + 'C1': 107318149,
|
| + 'C2': 81786238,
|
| + 'C3': 17348563431
|
| + }
|
| + }
|
| + def testCrosParseCpuStates(self):
|
| + # Use mock start and end times to allow for the test to calculate C0.
|
| + results = cros_sysfs_platform.CrosSysfsPlatform.ParseStateSample(
|
| + self.initial_cstate, self.start_time)
|
| + for cpu in results:
|
| + for state in results[cpu]:
|
| + self.assertAlmostEqual(results[cpu][state],
|
| + self.expected_cstate[cpu][state])
|
|
|