1# Copyright 2018 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"""An interface to access the local graphics facade.""" 6 7from autotest_lib.client.common_lib import error 8from autotest_lib.client.cros.graphics import graphics_utils 9 10 11class GraphicsFacadeNative(object): 12 """Facade to access graphics utilities for catching GPU hangs.""" 13 14 15 def __init__(self): 16 """Initializes the graphics facade. 17 18 Graphics state checker is initialized with a dedicated function to 19 control timing for the initial set of errors extracted from logs. 20 21 """ 22 self._graphics_state_checker = None 23 24 25 def graphics_state_checker_initialize(self): 26 """Create and initialize the graphics state checker object. 27 28 This will establish existing errors and take a snapshot of graphics 29 kernel memory. 30 31 """ 32 self._graphics_state_checker = graphics_utils.GraphicsStateChecker() 33 34 35 def graphics_state_checker_finalize(self): 36 """Throw an error on new GPU hang messages in system logs. 37 38 @raises TestError: Finalize was called before initialize. 39 """ 40 if self._graphics_state_checker is None: 41 raise error.TestError('Graphics state checker initialize not called.') 42 self._graphics_state_checker.finalize() 43