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