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 logging, os 6 7from autotest_lib.client.bin import test, utils 8from autotest_lib.client.common_lib import error 9from autotest_lib.client.cros.graphics import graphics_utils 10 11class graphics_PiglitBVT(test.test): 12 """ 13 Runs a slice of the passing Piglit test sets. 14 """ 15 version = 1 16 17 test_scripts = 'test_scripts/' 18 GSC = None 19 20 def initialize(self): 21 self.GSC = graphics_utils.GraphicsStateChecker() 22 23 def cleanup(self): 24 if self.GSC: 25 keyvals = self.GSC.get_memory_keyvals() 26 for key, val in keyvals.iteritems(): 27 self.output_perf_value(description=key, value=val, 28 units='bytes', higher_is_better=False) 29 self.GSC.finalize() 30 self.write_perf_keyval(keyvals) 31 32 def run_once(self, test_slice): 33 # TODO(ihf): Remove this once Piglit works on freon. 34 if utils.is_freon(): 35 return 36 37 gpu_family = utils.get_gpu_family() 38 family = gpu_family 39 logging.info('Detected gpu family %s.', gpu_family) 40 41 # TODO(ihf): Delete this once we have a piglit that runs on ARM. 42 if gpu_family in ['mali', 'tegra']: 43 logging.info('Not running any tests, passing by default.') 44 return 45 46 scripts_dir = os.path.join(self.bindir, self.test_scripts) 47 family_dir = os.path.join(scripts_dir, family) 48 # We don't want to introduce too many combinations, so fall back. 49 if not os.path.isdir(family_dir): 50 family = 'other' 51 family_dir = os.path.join(scripts_dir, family) 52 logging.info('Using scripts for gpu family %s.', family) 53 scripts_dir = os.path.join(self.bindir, self.test_scripts) 54 # Mark scripts executable if they are not. 55 utils.system('chmod +x ' + scripts_dir + '*/graphics_PiglitBVT_*.sh') 56 57 # Kick off test script. 58 cmd = ('source ' + os.path.join(family_dir, 'graphics_PiglitBVT_%d.sh' % 59 test_slice)) 60 logging.info('Executing cmd = %s', cmd) 61 result = utils.run(cmd, 62 stdout_tee=utils.TEE_TO_LOGS, 63 stderr_tee=utils.TEE_TO_LOGS, 64 ignore_status = True) 65 tests_failed = result.exit_status 66 if tests_failed: 67 reason = '%d tests failed on "%s" in slice %d' % (tests_failed, 68 gpu_family, 69 test_slice) 70 raise error.TestError(reason) 71