blob: 95fbb51f2443a6faa77ebd0f5218666f037e2574 [file] [log] [blame]
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging, time
from autotest_lib.client.bin import test, utils
from autotest_lib.client.common_lib import error
from autotest_lib.client.cros import perf
from autotest_lib.client.cros import service_stopper
from import graphics_utils
class graphics_PerfControl(graphics_utils.GraphicsTest):
version = 1
# None-init vars used by cleanup() here, in case setup() fails
_services = None
def initialize(self):
super(graphics_PerfControl, self).initialize()
self._services = service_stopper.ServiceStopper(['ui'])
def cleanup(self):
if self._services:
super(graphics_PerfControl, self).cleanup()
def run_once(self):
# If UI is running, we must stop it and restore later.
# Wrap the test run inside of a PerfControl instance to make machine
# behavior more consistent.
with perf.PerfControl() as pc:
if not pc.verify_is_valid():
raise error.TestFail('Failed: %s' % pc.get_error_reason())
# Do nothing for a short while so the PerfControl thread is collecting
# real data.
if not pc.verify_is_valid():
raise error.TestFail('Failed: %s' % pc.get_error_reason())