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_qualcomm = ['kmstest'] 34 tests_rockchip = ['kmstest'] 35 arch_tests = { 36 'amd': [], 37 'arm': [], 38 'exynos5': tests_exynos5, 39 'i386': [], 40 'mediatek': tests_mediatek, 41 'qualcomm': tests_qualcomm, 42 'rockchip': tests_rockchip, 43 'tegra': [], 44 'x86_64': [] 45 } 46 soc = utils.get_cpu_soc_family() 47 if not soc in arch_tests: 48 raise error.TestFail('Error: Architecture "%s" not supported.', 49 soc) 50 elif soc == 'tegra': 51 logging.warning('Tegra does not support DRM.') 52 return 53 tests = tests_common + arch_tests[soc] 54 55 # If UI is running, we must stop it and restore later. 56 self._services.stop_services() 57 58 for test in tests: 59 self.add_failures(test) 60 # Make sure the test exists on this system. Not all tests may be 61 # present on a given system. 62 if utils.system('which %s' % test): 63 logging.error('Could not find test %s.', test) 64 keyvals[test] = 'NOT FOUND' 65 continue 66 67 # Run the test and check for success based on return value. 68 return_value = utils.system(test) 69 if return_value: 70 logging.error('%s returned %d', test, return_value) 71 keyvals[test] = 'FAILED' 72 else: 73 keyvals[test] = 'PASSED' 74 self.remove_failures(test) 75 76 self.write_perf_keyval(keyvals) 77 if self.get_failures(): 78 raise error.TestFail('Failed: %d libdrm tests failed.' 79 % len(self.get_failures())) 80