Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / core / platform / cros_platform_backend_unittest.py
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import unittest
6
7 from telemetry.core.platform import cros_platform_backend
8
9
10 class CrosPlatformBackendTest(unittest.TestCase):
11   initial_cstate = {
12     'cpu0': 'POLL\nC1\nC2\nC3\n0\n138356189\n102416540\n'
13             '17158209182\n0\n1\n500\n1000\n1403211341',
14     'cpu1': 'POLL\nC1\nC2\nC3\n0\n107318149\n81786238\n'
15             '17348563431\n0\n1\n500\n1000\n1403211341'
16   }
17   expected_cstate = {
18     'cpu0': {
19       'C0': 1403193942018089,
20       'C1': 138356189,
21       'C2': 102416540,
22       'C3': 17158209182
23     },
24     'cpu1': {
25       'C0': 1403193803332182,
26       'C1': 107318149,
27       'C2': 81786238,
28       'C3': 17348563431
29     }
30   }
31   def testCrosParseCpuStates(self):
32     # Use mock start and end times to allow for the test to calculate C0.
33     results = cros_platform_backend.CrosPlatformBackend.ParseCStateSample(
34         self.initial_cstate)
35     for cpu in results:
36       for state in results[cpu]:
37         self.assertAlmostEqual(results[cpu][state],
38                                self.expected_cstate[cpu][state])