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