• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2012 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.
4import logging
5
6from autotest_lib.client.bin import test, utils
7from autotest_lib.client.common_lib import error
8from autotest_lib.client.cros import service_stopper
9from autotest_lib.client.cros.graphics import graphics_utils
10
11class graphics_LibDRM(graphics_utils.GraphicsTest):
12    version = 1
13    _services = None
14
15    def initialize(self):
16        super(graphics_LibDRM, self).initialize()
17        self._services = service_stopper.ServiceStopper(['ui'])
18
19    def cleanup(self):
20        super(graphics_LibDRM, self).cleanup()
21        if self._services:
22            self._services.restore_services()
23
24    def run_once(self):
25        keyvals = {}
26
27        # These are tests to run for all platforms.
28        tests_common = ['modetest']
29
30        # Determine which tests to run based on the architecture type.
31        tests_exynos5 = ['kmstest']
32        tests_mediatek = ['kmstest']
33        tests_rockchip = ['kmstest']
34        arch_tests = {
35            'amd': [],
36            'arm': [],
37            'exynos5': tests_exynos5,
38            'i386': [],
39            'mediatek': tests_mediatek,
40            'rockchip': tests_rockchip,
41            'tegra': [],
42            'x86_64': []
43        }
44        soc = utils.get_cpu_soc_family()
45        if not soc in arch_tests:
46            raise error.TestFail('Error: Architecture "%s" not supported.',
47                                 soc)
48        elif soc == 'tegra':
49            logging.warning('Tegra does not support DRM.')
50            return
51        tests = tests_common + arch_tests[soc]
52
53        # If UI is running, we must stop it and restore later.
54        self._services.stop_services()
55
56        for test in tests:
57            self.add_failures(test)
58            # Make sure the test exists on this system.  Not all tests may be
59            # present on a given system.
60            if utils.system('which %s' % test):
61                logging.error('Could not find test %s.', test)
62                keyvals[test] = 'NOT FOUND'
63                continue
64
65            # Run the test and check for success based on return value.
66            return_value = utils.system(test)
67            if return_value:
68                logging.error('%s returned %d', test, return_value)
69                keyvals[test] = 'FAILED'
70            else:
71                keyvals[test] = 'PASSED'
72                self.remove_failures(test)
73
74        self.write_perf_keyval(keyvals)
75        if self.get_failures():
76            raise error.TestFail('Failed: %d libdrm tests failed.'
77                                 % len(self.get_failures()))
78