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 # pylint: disable=W0212
10 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
12 from pylib import android_commands
13 from pylib.device import device_utils
14 from pylib.perf import perf_control
16 class TestPerfControl(unittest.TestCase):
18 if not os.getenv('BUILDTYPE'):
19 os.environ['BUILDTYPE'] = 'Debug'
21 devices = android_commands.GetAttachedDevices()
22 self.assertGreater(len(devices), 0, 'No device attached!')
23 self._device = device_utils.DeviceUtils(
24 android_commands.AndroidCommands(device=devices[0]))
26 def testHighPerfMode(self):
27 perf = perf_control.PerfControl(self._device)
29 perf.SetPerfProfilingMode()
30 for cpu in range(perf._NumCpuCores):
31 path = perf_control.PerfControl._CPU_ONLINE_FMT % cpu
32 self.assertEquals('1',
33 self._device.old_interface.GetFileContents(path)[0])
34 path = perf_control.PerfControl._SCALING_GOVERNOR_FMT % cpu
35 self.assertEquals('performance',
36 self._device.old_interface.GetFileContents(path)[0])
38 perf.SetDefaultPerfMode()
40 if __name__ == '__main__':