Home | History | Annotate | Download | only in graphics_PerfControl
      1 # Copyright (c) 2014 The Chromium OS 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 
      5 import logging, time
      6 
      7 from autotest_lib.client.bin import test, utils
      8 from autotest_lib.client.common_lib import error
      9 from autotest_lib.client.cros import perf
     10 from autotest_lib.client.cros import service_stopper
     11 
     12 class graphics_PerfControl(test.test):
     13   version = 1
     14 
     15   # None-init vars used by cleanup() here, in case setup() fails
     16   _services = None
     17 
     18   def initialize(self):
     19     self._services = service_stopper.ServiceStopper(['ui'])
     20 
     21   def cleanup(self):
     22     if self._services:
     23       self._services.restore_services()
     24 
     25   def run_once(self):
     26     logging.info(utils.get_board_with_frequency_and_memory())
     27 
     28     # If UI is running, we must stop it and restore later.
     29     self._services.stop_services()
     30 
     31     # Wrap the test run inside of a PerfControl instance to make machine
     32     # behavior more consistent.
     33     with perf.PerfControl() as pc:
     34       if not pc.verify_is_valid():
     35         raise error.TestError(pc.get_error_reason())
     36       # Do nothing for a short while so the PerfControl thread is collecting
     37       # real data.
     38       time.sleep(10)
     39 
     40       if not pc.verify_is_valid():
     41         raise error.TestError(pc.get_error_reason())
     42