Commit d3538166 authored by nednguyen's avatar nednguyen Committed by Commit bot

Handle the case freq state data read from file is empty for sysfs_power_montior.

Breakage caused by this case can be found in http://build.chromium.org/p/chromium.perf/builders/Android%20Nexus4%20Perf/builds/1416/steps/page_cycler.bloat/logs/stdio

BUG=

Review URL: https://codereview.chromium.org/610483002

Cr-Commit-Position: refs/heads/master@{#296861}
parent 3510e667
......@@ -162,7 +162,7 @@ class SysfsPowerMonitor(power_monitor.PowerMonitor):
for cpu in initial:
current_cpu = {}
total = 0
if initial[cpu] is None or final[cpu] is None:
if not initial[cpu] or not final[cpu]:
cpu_stats[cpu] = collections.defaultdict(int)
continue
for state in initial[cpu]:
......
......@@ -16,7 +16,8 @@ class SysfsPowerMonitorMonitorTest(unittest.TestCase):
'1200000 2082\n1100000 2943\n1000000 6560\n900000 12517\n'
'800000 8690\n700000 5105\n600000 3800\n500000 5131\n400000 5479\n'
'300000 7571\n200000 133618',
'cpu2': '1700000 1131'
'cpu2': '1700000 1131',
'cpu3': '1700000 1131'
}
final_freq = {
'cpu0': '1700000 7159\n1600000 0\n1500000 0\n1400000 68\n1300000 134\n'
......@@ -27,7 +28,8 @@ class SysfsPowerMonitorMonitorTest(unittest.TestCase):
'1200000 2272\n1100000 3163\n1000000 7039\n900000 13800\n'
'800000 9599\n700000 5655\n600000 4144\n500000 5655\n400000 6005\n'
'300000 8288\n200000 149724',
'cpu2': None
'cpu2': None,
'cpu3': ''
}
expected_initial_freq = {
'cpu0': {
......@@ -68,6 +70,9 @@ class SysfsPowerMonitorMonitorTest(unittest.TestCase):
},
'cpu2': {
1700000000: 1131
},
'cpu3': {
1700000000: 1131
}
}
expected_final_freq = {
......@@ -107,7 +112,8 @@ class SysfsPowerMonitorMonitorTest(unittest.TestCase):
300000000: 8288,
200000000: 149724
},
'cpu2': None
'cpu2': None,
'cpu3': {}
}
expected_freq_percents = {
'whole_package': {
......@@ -166,7 +172,10 @@ class SysfsPowerMonitorMonitorTest(unittest.TestCase):
},
'cpu2': {
1700000000: 0.0,
}
},
'cpu3': {
1700000000: 0.0,
}
}
def testParseCpuFreq(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment