Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor_unittest.py

Issue 635313002: [Telemetry] Fix C-State stat reading for Note 3 and S5. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Unit test for SysfsPowerMonitor.GetCpuState Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor_unittest.py
diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor_unittest.py b/tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor_unittest.py
index a01862433c29125b6ffe6b7ecf9a31697e36f245..0d06eeda3dea77e5179a0464b960b921b964a9a3 100644
--- a/tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor_unittest.py
+++ b/tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor_unittest.py
@@ -193,3 +193,32 @@ class SysfsPowerMonitorMonitorTest(unittest.TestCase):
for freq in results[cpu]:
self.assertAlmostEqual(results[cpu][freq],
self.expected_freq_percents[cpu][freq])
+
+ def testGetCpuState(self):
+ class PlatformStub(object):
+ def __init__(self, run_command_return_value):
+ self._run_command_return_value = run_command_return_value
+ def RunCommand(self, _cmd):
+ return self._run_command_return_value
+
+ cpu_state_from_samsung_note3 = (
+ "C0\n\nC1\n\nC2\n\nC3\n\n"
+ "53658520886\n1809072\n7073\n1722554\n"
+ "1\n35\n300\n500\n"
+ "1412949256\n")
+ numOfCStates = 4
+
+ sysfsmon = sysfs_power_monitor.SysfsPowerMonitor(
+ PlatformStub(cpu_state_from_samsung_note3))
+ # pylint: disable=W0212
+ sysfsmon._cpus = ["cpu%d" % cpu for cpu in range(2)]
+ state = sysfsmon.GetCpuState()
+
nednguyen 2014/10/10 16:11:52 Instead of the assertions below, how about asserti
+ self.assertSetEqual(set(state.iterkeys()), set(sysfsmon._cpus))
+ for cpuState in state.itervalues():
+ lines = cpuState.splitlines()
+ self.assertEquals(len(lines), numOfCStates * 3 + 1)
+ try:
+ [int(line) for line in lines[numOfCStates:]]
+ except ValueError:
+ self.fail("Invalid integer in CPU state string: '%s'" % line)
« no previous file with comments | « tools/telemetry/telemetry/core/platform/power_monitor/sysfs_power_monitor.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698