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, re
6
7from autotest_lib.client.bin import test
8from autotest_lib.client.common_lib import error, utils
9from autotest_lib.client.cros.graphics import graphics_utils
10
11class graphics_Gbm(test.test):
12    """
13    Test the gbm implementation.
14    """
15    version = 1
16    preserve_srcdir = True
17    GSC = None
18
19    def setup(self):
20        os.chdir(self.srcdir)
21        utils.make('clean')
22        utils.make('all')
23
24    def initialize(self):
25        self.GSC = graphics_utils.GraphicsStateChecker()
26
27    def cleanup(self):
28        if self.GSC:
29            self.GSC.finalize()
30
31    def run_once(self):
32        cmd = os.path.join(self.srcdir, 'gbmtest')
33        cmd = graphics_utils.xcommand(cmd)
34        result = utils.run(cmd,
35                           stderr_is_expected = False,
36                           stdout_tee = utils.TEE_TO_LOGS,
37                           stderr_tee = utils.TEE_TO_LOGS,
38                           ignore_status = True)
39        report = re.findall(r'\[  PASSED  \]', result.stdout)
40        if not report:
41            raise error.TestFail('Gbm test failed (' + result.stdout + ')')
42
43