Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(694)

Side by Side Diff: client/site_tests/graphics_GLBench/graphics_GLBench.py

Issue 2938010: Removed site_ui.xcommand and made md5_file ignore exceptions. (Closed) Base URL: ssh://git@chromiumos-git//autotest.git
Patch Set: better error reporting Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/deps/glbench/src/main.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import re 7 import re
8 8
9 from autotest_lib.client.bin import test 9 from autotest_lib.client.bin import test
10 from autotest_lib.client.common_lib import error, site_ui, utils 10 from autotest_lib.client.common_lib import error, utils
11 11
12 def md5_file(filename): 12 def md5_file(filename):
13 return utils.system_output('md5sum ' + filename).split()[0] 13 try:
14 return utils.system_output('md5sum ' + filename).split()[0]
15 except error.CmdError:
16 return None
14 17
15 18
16 class graphics_GLBench(test.test): 19 class graphics_GLBench(test.test):
17 version = 1 20 version = 1
18 preserve_srcdir = True 21 preserve_srcdir = True
19 22
20 def setup(self): 23 def setup(self):
21 self.job.setup_dep(['glbench']) 24 self.job.setup_dep(['glbench'])
22 25
23 26
24 def run_once(self, options=''): 27 def run_once(self, options=''):
25 dep = 'glbench' 28 dep = 'glbench'
26 dep_dir = os.path.join(self.autodir, 'deps', dep) 29 dep_dir = os.path.join(self.autodir, 'deps', dep)
27 self.job.install_pkg(dep, 'dep', dep_dir) 30 self.job.install_pkg(dep, 'dep', dep_dir)
28 31
29 checksum_table = {} 32 checksum_table = {}
30 checksums_filename = os.path.join(self.autodir, 33 checksums_filename = os.path.join(self.autodir,
31 'deps/glbench/src/checksums') 34 'deps/glbench/src/checksums')
32 checksums = eval(utils.read_file(checksums_filename)) 35 checksums = eval(utils.read_file(checksums_filename))
33 36
34 exefile = os.path.join(self.autodir, 'deps/glbench/glbench') 37 exefile = os.path.join(self.autodir, 'deps/glbench/glbench')
35 board_id = utils.system_output(site_ui.xcommand(exefile +
36 ' -get_board_id')).strip()
37 logging.info("Running on: %s", board_id)
38 checksum_table = checksums.get(board_id, {})
39 38
40 if checksum_table: 39 options += ' -save'
41 options += ' -save' 40 out_dir = os.path.join(self.autodir, 'deps/glbench/src/out')
42 out_dir = os.path.join(self.autodir, 'deps/glbench/src/out')
43 else:
44 raise error.TestFail("No checksums found for this board: %s" % board_id)
45 41
46 cmd = "X :1 & sleep 1; DISPLAY=:1 %s %s; kill $!" % (exefile, options) 42 cmd = "X :1 & sleep 1; DISPLAY=:1 %s %s; kill $!" % (exefile, options)
47 self.results = utils.system_output(cmd, retain_output=True) 43 results = utils.system_output(cmd, retain_output=True).splitlines()
44
45 if results[0].startswith('# board_id: '):
46 board_id = results[0].split('board_id:', 1)[1].strip()
47 del results[0]
48 logging.info("Running on: %s", board_id)
49 checksum_table = checksums.get(board_id, {})
50 else:
51 logging.info('Could not find board id.')
52 checksum_table = {}
48 53
49 keyvals = {} 54 keyvals = {}
50 failed_tests = [] 55 failed_tests = []
51 for keyval in self.results.splitlines(): 56 missing_checksum_tests = []
57 for keyval in results:
52 if keyval.strip().startswith('#'): 58 if keyval.strip().startswith('#'):
53 continue 59 continue
54 key, val = keyval.split(':') 60 key, val = keyval.split(':')
55 testname = key.strip() 61 testname = key.strip()
56 62
57 if testname in checksum_table: 63 if testname in checksum_table:
58 if checksum_table[testname] == md5_file( 64 if checksum_table[testname] == md5_file(
59 os.path.join(out_dir, testname)): 65 os.path.join(out_dir, testname)):
60 keyvals[testname] = float(val) 66 keyvals[testname] = float(val)
61 else: 67 else:
62 keyvals[testname] = float('nan') 68 keyvals[testname] = float('nan')
63 failed_tests.append(testname) 69 failed_tests.append(testname)
64 else: 70 else:
65 logging.info('No checksum found for test %s', testname) 71 logging.info('No checksum found for test %s', testname)
66 keyvals[testname] = float(val) 72 keyvals[testname] = float(val)
73 missing_checksum_tests.append(testname)
67 74
68 self.write_perf_keyval(keyvals) 75 self.write_perf_keyval(keyvals)
69 if failed_tests: 76 if failed_tests or missing_checksum_tests:
70 raise error.TestFail("Incorrect checksums for %s" % 77 messages = []
71 ', '.join(failed_tests)) 78 if failed_tests:
79 messages.append("Incorrect checksums for: %s" %
80 ', '.join(failed_tests))
81 if missing_checksum_tests:
82 messages.append("Missing checksums for: %s" %
83 ', '.join(missing_checksum_tests))
84 raise error.TestFail('; '.join(messages))
OLDNEW
« no previous file with comments | « client/deps/glbench/src/main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698