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