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