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_test_case
     13 from devil.android import device_utils
     14 from devil.android.perf import perf_control
     15 
     16 
     17 class TestPerfControl(device_test_case.DeviceTestCase):
     18 
     19   def setUp(self):
     20     super(TestPerfControl, self).setUp()
     21     if not os.getenv('BUILDTYPE'):
     22       os.environ['BUILDTYPE'] = 'Debug'
     23     self._device = device_utils.DeviceUtils(self.serial)
     24 
     25   def testHighPerfMode(self):
     26     perf = perf_control.PerfControl(self._device)
     27     try:
     28       perf.SetPerfProfilingMode()
     29       cpu_info = perf.GetCpuInfo()
     30       self.assertEquals(len(perf._cpu_files), len(cpu_info))
     31       for _, online, governor in cpu_info:
     32         self.assertTrue(online)
     33         self.assertEquals('performance', governor)
     34     finally:
     35       perf.SetDefaultPerfMode()
     36 
     37 if __name__ == '__main__':
     38   unittest.main()
     39