OLD | NEW |
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 os | 6 import os |
| 7 import re |
6 | 8 |
7 from autotest_lib.client.bin import test | 9 from autotest_lib.client.bin import test |
8 from autotest_lib.client.common_lib import utils | 10 from autotest_lib.client.common_lib import error, site_ui, utils |
| 11 |
| 12 def md5_file(filename): |
| 13 return utils.system_output('md5sum ' + filename).split()[0] |
| 14 |
| 15 |
| 16 def get_board_id(): |
| 17 glxinfo_output = utils.system_output(site_ui.xcommand('glxinfo')) |
| 18 match = re.search('OpenGL vendor string: (.*)', glxinfo_output) |
| 19 vendor = match.group(1) if match else 'unknown vendor' |
| 20 match = re.search('OpenGL renderer string: (.*)', glxinfo_output) |
| 21 renderer = match.group(1) if match else 'unknown renderer' |
| 22 return (vendor + ' / ' + renderer).strip() |
| 23 |
9 | 24 |
10 class gl_Bench(test.test): | 25 class gl_Bench(test.test): |
11 version = 1 | 26 version = 1 |
12 preserve_srcdir = True | 27 preserve_srcdir = True |
13 | 28 |
14 def setup(self): | 29 def setup(self): |
15 self.job.setup_dep(['glbench']) | 30 self.job.setup_dep(['glbench']) |
16 | 31 |
17 | 32 |
18 def run_once(self, options=''): | 33 def run_once(self, options=''): |
19 dep = 'glbench' | 34 dep = 'glbench' |
20 dep_dir = os.path.join(self.autodir, 'deps', dep) | 35 dep_dir = os.path.join(self.autodir, 'deps', dep) |
21 self.job.install_pkg(dep, 'dep', dep_dir) | 36 self.job.install_pkg(dep, 'dep', dep_dir) |
22 | 37 |
| 38 checksum_table = {} |
| 39 checksums_filename = os.path.join(self.autodir, |
| 40 'deps/glbench/src/checksums') |
| 41 checksums = eval(utils.read_file(checksums_filename)) |
| 42 |
| 43 board_id = get_board_id() |
| 44 logging.info("Running on:", board_id) |
| 45 checksum_table = checksums.get(board_id, {}) |
| 46 |
| 47 if checksum_table: |
| 48 options += ' -save' |
| 49 out_dir = os.path.join(self.autodir, 'deps/glbench/src/out') |
| 50 else: |
| 51 error.TestFail("No checksums found for this board.") |
| 52 |
23 exefile = os.path.join(self.autodir, 'deps/glbench/glbench') | 53 exefile = os.path.join(self.autodir, 'deps/glbench/glbench') |
24 cmd = "X :1 & sleep 1; DISPLAY=:1 %s %s; kill $!" % (exefile, options) | 54 cmd = "X :1 & sleep 1; DISPLAY=:1 %s %s; kill $!" % (exefile, options) |
25 self.results = utils.system_output(cmd, retain_output=True) | 55 self.results = utils.system_output(cmd, retain_output=True) |
26 | 56 |
27 keyvals = {} | 57 keyvals = {} |
28 for keyval in self.results.splitlines(): | 58 for keyval in self.results.splitlines(): |
29 if keyval.strip().startswith('#'): | 59 if keyval.strip().startswith('#'): |
30 continue | 60 continue |
31 key, val = keyval.split(':') | 61 key, val = keyval.split(':') |
32 keyvals[key.strip()] = float(val) | 62 testname = key.strip() |
| 63 |
| 64 if testname in checksum_table: |
| 65 if checksum_table[testname] == md5_file( |
| 66 os.path.join(out_dir, testname)): |
| 67 keyvals[testname] = float(val) |
| 68 else: |
| 69 keyvals[testname] = float('nan') |
| 70 else: |
| 71 logging.info('No checksum found for test', testname) |
| 72 keyvals[testname] = float(val) |
33 | 73 |
34 self.write_perf_keyval(keyvals) | 74 self.write_perf_keyval(keyvals) |
OLD | NEW |