1# Copyright 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 os.path
6
7from autotest_lib.client.bin import utils
8from autotest_lib.client.common_lib import error
9from autotest_lib.client.cros import chrome_binary_test
10from autotest_lib.client.cros.graphics import graphics_utils
11
12class graphics_KhronosGLCTSChrome(chrome_binary_test.ChromeBinaryTest):
13    """
14    Run the Khronos GL-CTS test suite against the Chrome GPU command
15    buffer.
16    """
17    version = 1
18    GSC = None
19    BINARY = 'khronos_glcts_test'
20
21    def initialize(self):
22        super(graphics_KhronosGLCTSChrome, self).initialize()
23        self.GSC = graphics_utils.GraphicsStateChecker()
24
25    def cleanup(self):
26        super(graphics_KhronosGLCTSChrome, self).cleanup()
27        if self.GSC:
28            self.GSC.finalize()
29
30    def run_once(self):
31        # TODO(ihf): Remove this once KhronosGLCTSChrome works on freon.
32        if utils.is_freon():
33            raise error.TestNAError(
34                'Test needs work on Freon. See crbug.com/484467.')
35
36        if not os.path.exists(self.get_chrome_binary_path(self.BINARY)):
37            raise error.TestFail('%s not found. Use internal Chrome sources!' %
38                                 self.BINARY)
39
40        log_file = os.path.join(self.resultsdir, self.BINARY + ".xml")
41        bin_args = '--gtest_output=xml:%s %s' % (log_file, self.resultsdir)
42
43        self.run_chrome_test_binary(self.BINARY, bin_args)
44