Home | History | Annotate | Download | only in perf
      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
      5 
      6 import os
      7 import sys
      8 import unittest
      9 
     10 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
     11 
     12 from devil.android import device_utils
     13 from devil.android.perf import perf_control
     14 
     15 
     16 class TestPerfControl(unittest.TestCase):
     17 
     18   def setUp(self):
     19     if not os.getenv('BUILDTYPE'):
     20       os.environ['BUILDTYPE'] = 'Debug'
     21 
     22     devices = device_utils.DeviceUtils.HealthyDevices(blacklist=None)
     23     self.assertGreater(len(devices), 0, 'No device attached!')
     24     self._device = devices[0]
     25 
     26   def testHighPerfMode(self):
     27     perf = perf_control.PerfControl(self._device)
     28     try:
     29       perf.SetPerfProfilingMode()
     30       cpu_info = perf.GetCpuInfo()
     31       self.assertEquals(len(perf._cpu_files), len(cpu_info))
     32       for _, online, governor in cpu_info:
     33         self.assertTrue(online)
     34         self.assertEquals('performance', governor)
     35     finally:
     36       perf.SetDefaultPerfMode()
     37 
     38 if __name__ == '__main__':
     39   unittest.main()
     40