OLD | NEW |
1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2009 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 re | 5 import re |
6 import os | 6 import os |
7 import logging | 7 import logging |
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, utils | 10 from autotest_lib.client.common_lib import error, utils |
11 | 11 |
12 class hardware_MemoryThroughput(test.test): | 12 class hardware_MemoryThroughput(test.test): |
13 version = 1 | 13 version = 1 |
14 preserve_srcdir = True | 14 preserve_srcdir = True |
15 | 15 |
16 def setup(self): | 16 def setup(self): |
17 os.chdir(self.srcdir) | 17 os.chdir(self.srcdir) |
18 utils.system('make clean') | 18 utils.make('clean') |
19 utils.system('make') | 19 utils.make() |
20 | 20 |
21 def run_once(self, num_iteration = -1, test_list = ''): | 21 def run_once(self, num_iteration = -1, test_list = ''): |
22 exefile = os.path.join(self.srcdir, 'hardware_MemoryThroughput') | 22 exefile = os.path.join(self.srcdir, 'hardware_MemoryThroughput') |
23 cmd = '%s %d %s' % (exefile, num_iteration, test_list) | 23 cmd = '%s %d %s' % (exefile, num_iteration, test_list) |
24 self.results = utils.system_output(cmd, retain_output = True) | 24 self.results = utils.system_output(cmd, retain_output = True) |
25 | 25 |
26 # Resulting time in MicroSec / MegaBytes. | 26 # Resulting time in MicroSec / MegaBytes. |
27 # Write out memory operation performance in MegaBytes / Second. | 27 # Write out memory operation performance in MegaBytes / Second. |
28 performance_pattern = re.compile( | 28 performance_pattern = re.compile( |
29 r"Action = ([a-z0-9.]+), BlockSize = (\w+), " + | 29 r"Action = ([a-z0-9.]+), BlockSize = (\w+), " + |
30 r"Method = (\w+), Time = ([0-9.]+)") | 30 r"Method = (\w+), Time = ([0-9.]+)") |
31 keyval_list = performance_pattern.findall(self.results) | 31 keyval_list = performance_pattern.findall(self.results) |
32 keyvals = {} | 32 keyvals = {} |
33 for keyval in keyval_list: | 33 for keyval in keyval_list: |
34 key = ('mb_per_sec_memory_' + | 34 key = ('mb_per_sec_memory_' + |
35 keyval[0] + '_' + keyval[1] + '_' + keyval[2]) | 35 keyval[0] + '_' + keyval[1] + '_' + keyval[2]) |
36 keyvals[key] = 1000000.0 / float(keyval[3]) | 36 keyvals[key] = 1000000.0 / float(keyval[3]) |
37 self.write_perf_keyval(keyvals) | 37 self.write_perf_keyval(keyvals) |
38 | 38 |
39 # Detect if an error has occured during the tests. | 39 # Detect if an error has occured during the tests. |
40 # Do this after writing out the test results so even an error occurred, | 40 # Do this after writing out the test results so even an error occurred, |
41 # we still get the performance evaluation. | 41 # we still get the performance evaluation. |
42 error_pattern = re.compile(r"ERROR: \[(.+)\]") | 42 error_pattern = re.compile(r"ERROR: \[(.+)\]") |
43 errors = error_pattern.findall(self.results) | 43 errors = error_pattern.findall(self.results) |
44 if len(errors) > 0: | 44 if len(errors) > 0: |
45 logging.debug(self.results) | 45 logging.debug(self.results) |
46 raise error.TestFail('malfunctioning memory detected'); | 46 raise error.TestFail('malfunctioning memory detected'); |
OLD | NEW |