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

Side by Side Diff: build/android/pylib/perf/perf_control_unittest.py

Issue 338233003: Telemetry: Set scaling governor on all cpus (on all devices) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback. Created 6 years, 6 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 import sys 6 import sys
7 import unittest 7 import unittest
8 8
9 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) 9 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
10 10
11 from pylib import android_commands 11 from pylib import android_commands
12 from pylib.device import device_utils 12 from pylib.device import device_utils
13 from pylib.perf import perf_control 13 from pylib.perf import perf_control
14 14
15
16 class TestPerfControl(unittest.TestCase): 15 class TestPerfControl(unittest.TestCase):
17 def setUp(self): 16 def setUp(self):
18 if not os.getenv('BUILDTYPE'): 17 if not os.getenv('BUILDTYPE'):
19 os.environ['BUILDTYPE'] = 'Debug' 18 os.environ['BUILDTYPE'] = 'Debug'
20 19
21 devices = android_commands.GetAttachedDevices() 20 devices = android_commands.GetAttachedDevices()
22 self.assertGreater(len(devices), 0, 'No device attached!') 21 self.assertGreater(len(devices), 0, 'No device attached!')
23 self._device = device_utils.DeviceUtils( 22 self._device = device_utils.DeviceUtils(
24 android_commands.AndroidCommands(device=devices[0])) 23 android_commands.AndroidCommands(device=devices[0]))
25 24
26 def testForceAllCpusOnline(self): 25 def testHighPerfMode(self):
27 perf = perf_control.PerfControl(self._device) 26 perf = perf_control.PerfControl(self._device)
28 cpu_online_files = self._device.RunShellCommand(
29 'ls -d /sys/devices/system/cpu/cpu[0-9]*/online')
30 try: 27 try:
31 perf.ForceAllCpusOnline(True) 28 perf.ForceHighPerfMode()
pasko 2014/06/19 17:48:32 It was like that before, but this does not really
Sami 2014/06/19 18:12:43 Cue age old debate about integration vs. unit test
32 for path in cpu_online_files: 29 for cpu in range(perf.NumCpuCores()):
30 path = perf.CpuOnlineFormat() % cpu
33 self.assertEquals('1', 31 self.assertEquals('1',
34 self._device.old_interface.GetFileContents(path)[0]) 32 self._device.old_interface.GetFileContents(path)[0])
35 mode = self._device.RunShellCommand('ls -l %s' % path)[0] 33 path = perf.ScalingGovernorFormat() % cpu
36 self.assertEquals('-r--r--r--', mode[:10]) 34 self.assertEquals('performance',
35 self._device.old_interface.GetFileContents(path)[0])
37 finally: 36 finally:
38 perf.ForceAllCpusOnline(False) 37 perf.SetDefaultPerfMode()
39
40 for path in cpu_online_files:
41 mode = self._device.RunShellCommand('ls -l %s' % path)[0]
42 self.assertEquals('-rw-r--r--', mode[:10])
43
44 38
45 if __name__ == '__main__': 39 if __name__ == '__main__':
46 unittest.main() 40 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698