Chromium Code Reviews| Index: server/bin/unit_test_server.py |
| diff --git a/server/bin/unit_test_server.py b/server/bin/unit_test_server.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0853c6a41861ef77b681b249f7952a15e4907b14 |
| --- /dev/null |
| +++ b/server/bin/unit_test_server.py |
| @@ -0,0 +1,57 @@ |
| +# Copyright (c) 2009 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 shutil |
| +from autotest_lib.client.common_lib import utils |
| +from autotest_lib.server import autotest, test |
| + |
| +def gen_gcov_report(report, files): |
| + results = {} |
| + |
| + for f in files: |
| + escf = re.escape(f) |
| + match = re.search("File '.*%s'\nLines executed:([0-9.]+)%%" % escf, |
| + report) |
| + if match: |
| + 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
|
| + |
| + return results |
| + |
| +class unit_test_server(test.test): |
| + version = 1 |
| + |
| + def run_once(self, host=None): |
| + self.client = host |
| + |
| + # Collect the gcov by running a client side test |
| + client_at = autotest.Autotest(self.client) |
| + client_at.run_test(self.client_test) |
| + |
| + def postprocess(self): |
| + logging.info('UnitTestServer: postprocess %s' % |
| + self.client.hostname) |
| + |
| + # Get the result director of the client |
| + results_dir = os.path.join(self.outputdir, self.client_test, 'results/') |
| + |
| + # Execute gcov on the result |
| + os.chdir(results_dir) |
| + report = utils.system_output('gcov ' + ''.join(self.test_files)) |
| + |
| + # Filter report for the files of interest |
| + filtered = gen_gcov_report(report, self.test_files) |
| + |
| + # Promote the client test keyval as our own |
| + src = os.path.join(self.outputdir, self.client_test, 'results/keyval') |
| + dst = os.path.join(self.resultsdir, 'keyval') |
| + if os.path.exists(src): |
| + shutil.copy(src, dst) |
| + else: |
| + logging.warn('Unable to locate %s' % src) |
| + |
| + # Append the coverage report |
| + self.write_perf_keyval(filtered) |