OLD | NEW |
---|---|
(Empty) | |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 import logging | |
6 import os | |
7 import re | |
8 import shutil | |
9 from autotest_lib.client.common_lib import utils | |
10 from autotest_lib.server import autotest, test | |
11 | |
12 def gen_gcov_report(report, files): | |
13 results = {} | |
14 | |
15 for f in files: | |
16 escf = re.escape(f) | |
17 match = re.search("File '.*%s'\nLines executed:([0-9.]+)%%" % escf, | |
18 report) | |
19 if match: | |
20 results[f] = float(match.group(1)) | |
kmixter1
2010/04/09 22:07:23
I was under the impression that the autotest frame
Sean Parent
2010/04/10 02:46:07
I replaced all "." and "/" characters with "_". Th
| |
21 | |
22 return results | |
23 | |
24 class unit_test_server(test.test): | |
25 version = 1 | |
26 | |
27 def run_once(self, host=None): | |
28 self.client = host | |
29 | |
30 # Collect the gcov by running a client side test | |
31 client_at = autotest.Autotest(self.client) | |
32 client_at.run_test(self.client_test) | |
33 | |
34 def postprocess(self): | |
35 logging.info('UnitTestServer: postprocess %s' % | |
36 self.client.hostname) | |
37 | |
38 # Get the result director of the client | |
39 results_dir = os.path.join(self.outputdir, self.client_test, 'results/') | |
40 | |
41 # Execute gcov on the result | |
42 os.chdir(results_dir) | |
43 report = utils.system_output('gcov ' + ''.join(self.test_files)) | |
44 | |
45 # Filter report for the files of interest | |
46 filtered = gen_gcov_report(report, self.test_files) | |
47 | |
48 # Promote the client test keyval as our own | |
49 src = os.path.join(self.outputdir, self.client_test, 'results/keyval') | |
50 dst = os.path.join(self.resultsdir, 'keyval') | |
51 if os.path.exists(src): | |
52 shutil.copy(src, dst) | |
53 else: | |
54 logging.warn('Unable to locate %s' % src) | |
55 | |
56 # Append the coverage report | |
57 self.write_perf_keyval(filtered) | |
OLD | NEW |