blob: 943e71d8ccb07be9c9ec1e233f35f2dac2b8100a [file] [log] [blame]
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
import os
import re
import pprint
from autotest_lib.client.bin import test
from autotest_lib.client.common_lib import error, utils
def md5_file(filename):
return utils.system_output('md5sum ' + filename).split()[0]
except error.CmdError:
return None
class graphics_GLBench(test.test):
version = 1
preserve_srcdir = True
def setup(self):
def run_once(self, options=''):
dep = 'glbench'
dep_dir = os.path.join(self.autodir, 'deps', dep)
self.job.install_pkg(dep, 'dep', dep_dir)
# These tests do not draw anything, they can only be used to check
# performance.
no_checksum_tests = set(['1280x768_fps_no_fill_compositing',
checksum_table = {}
checksums_filename = os.path.join(self.autodir,
# checksums file is a comma separate list of tuples:
# (board_1, {test1:checksum1, test2:checksum2}),
# (board_2, {test1:checksum1, test2:checksum2}),
# etc.
checksums = eval('dict([' + utils.read_file(checksums_filename) + '])')
exefile = os.path.join(self.autodir, 'deps/glbench/glbench')
options += ' -save'
out_dir = os.path.join(self.autodir, 'deps/glbench/src/out')
cmd = '%s %s' % (exefile, options)
# If UI is running, we must stop it and restore later.
need_restart_ui = False
status_output = utils.system_output('initctl status ui')
# If chrome is running, result will be similar to:
# ui start/running, process 11895'initctl status ui returns: %s', status_output)
need_restart_ui = status_output.startswith('ui start')
# If UI is just stopped or if there's no known X session, we have to start
# a new one. For factory test, it provides X (DISPLAY) so we can reuse it.
if need_restart_ui or (not os.getenv('DISPLAY')):
cmd = 'X :1 & sleep 1; DISPLAY=:1 %s; kill $!' % cmd
if need_restart_ui:
utils.system('initctl stop ui', ignore_status=True)
results = utils.system_output(cmd, retain_output=True).splitlines()
if need_restart_ui:
utils.system("start ui")
if results[0].startswith('# board_id: '):
board_id = results[0].split('board_id:', 1)[1].strip()
del results[0]"Running on: %s", board_id)
checksum_table = checksums.get(board_id, {})
checksum_table = {}
keyvals = {}
failed_tests = {}
missing_checksum_tests = {}
for keyval in results:
if keyval.strip().startswith('#'):
key, val = keyval.split(':')
testname = key.strip()
test_checksum = md5_file(os.path.join(out_dir, testname))
if testname in checksum_table:
if checksum_table[testname] == test_checksum:
keyvals[testname] = float(val)
keyvals[testname] = float('nan')
failed_tests[testname] = test_checksum
keyvals[testname] = float(val)
if testname not in no_checksum_tests:'No checksum found for test %s', testname)
missing_checksum_tests[testname] = test_checksum
if checksum_table:
if failed_tests or missing_checksum_tests:
messages = []
if failed_tests:
messages.append("Incorrect checksums for: %s" %
', '.join(failed_tests))
if missing_checksum_tests:
messages.append("Missing checksums for: %s" %
', '.join(missing_checksum_tests))
raise error.TestFail('; '.join(messages))
else:"Checksums are missing for: %s.", board_id)"Please verify that the output images are correct " +
"and append the following to the checksums file:\n" +
pprint.pformat((board_id, missing_checksum_tests)) + ',')
raise error.TestFail("Checksums are missing for: %s." % board_id)