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

Side by Side Diff: scripts/slave/recipe_modules/skia/coverage_flavor.py

Issue 1862713002: Convert Coverage flavor and bot to Swarming (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build@master
Patch Set: Rename Created 4 years, 8 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium 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 5
6 import datetime 6 import datetime
7 import default_flavor 7 import default_flavor
8 import posixpath 8 import posixpath
9 import ssh_devices 9 import ssh_devices
10 10
11 11
12 """Utils for running coverage tests.""" 12 """Utils for running coverage tests."""
13 13
14 14
15 class CoverageFlavorUtils(default_flavor.DefaultFlavorUtils): 15 class CoverageFlavorUtils(default_flavor.DefaultFlavorUtils):
16 def compile(self, target):
17 """Build the given target."""
18 cmd = [self._skia_api.m.path['slave_build'].join('skia', 'tools',
19 'llvm_coverage_build'),
20 target]
21 self._skia_api.run(self._skia_api.m.step, 'build %s' % target, cmd=cmd,
22 cwd=self._skia_api.m.path['checkout'])
23 16
24 def step(self, name, cmd, **kwargs): 17 def step(self, name, cmd, **kwargs):
25 """Run the given step through coverage.""" 18 """Run the given step through coverage."""
19 compile_target = 'dm'
20 build_cmd = [self._skia_api.m.path['slave_build'].join(
21 'skia', 'tools', 'llvm_coverage_build'),
22 compile_target]
23 self._skia_api.run(self._skia_api.m.step,
24 'build %s' % compile_target,
25 cmd=build_cmd,
26 cwd=self._skia_api.m.path['checkout'])
27
26 # Slice out the 'key' and 'properties' arguments to be reused. 28 # Slice out the 'key' and 'properties' arguments to be reused.
27 key = [] 29 key = []
28 properties = [] 30 properties = []
29 current = None 31 current = None
30 for i in xrange(0, len(cmd)): 32 for i in xrange(0, len(cmd)):
31 if isinstance(cmd[i], basestring) and cmd[i] == '--key': 33 if isinstance(cmd[i], basestring) and cmd[i] == '--key':
32 current = key 34 current = key
33 elif isinstance(cmd[i], basestring) and cmd[i] == '--properties': 35 elif isinstance(cmd[i], basestring) and cmd[i] == '--properties':
34 current = properties 36 current = properties
35 elif isinstance(cmd[i], basestring) and cmd[i].startswith('--'): 37 elif isinstance(cmd[i], basestring) and cmd[i].startswith('--'):
36 current = None 38 current = None
37 if current is not None: 39 if current is not None:
38 current.append(cmd[i]) 40 current.append(cmd[i])
39 41
40 results_dir = self._skia_api.out_dir.join('coverage_results') 42 results_dir = self._skia_api.out_dir.join('coverage_results')
41 self.create_clean_host_dir(results_dir) 43 self.create_clean_host_dir(results_dir)
42 44
43 # Run DM under coverage. 45 # Run DM under coverage.
44 report_file_basename = '%s.cov' % self._skia_api.got_revision 46 report_file_basename = '%s.cov' % self._skia_api.got_revision
45 report_file = results_dir.join(report_file_basename) 47 report_file = results_dir.join(report_file_basename)
46 args = [ 48 args = [
47 'python', 49 'python',
48 self._skia_api.m.path['slave_build'].join('skia', 'tools', 50 self._skia_api.m.path['slave_build'].join('skia', 'tools',
49 'llvm_coverage_run.py'), 51 'llvm_coverage_run.py'),
50 ] + cmd + ['--outResultsFile', report_file] 52 ] + cmd + ['--outResultsFile', report_file]
51 self._skia_api.run(self._skia_api.m.step, name=name, cmd=args, 53 self._skia_api.run(self._skia_api.m.step, name=name, cmd=args,
52 cwd=self._skia_api.m.path['checkout'], **kwargs) 54 cwd=self._skia_api.m.path['checkout'], **kwargs)
53 55
54 # Generate nanobench-style JSON output from the coverage report. 56 # Generate nanobench-style JSON output from the coverage report.
55 git_timestamp = self._skia_api.m.git.get_timestamp(test_data='1408633190', 57 nanobench_json = results_dir.join('nanobench_%s.json' % (
56 infra_step=True) 58 self._skia_api.got_revision))
57 nanobench_json = results_dir.join('nanobench_%s_%s.json' % ( 59 line_by_line_basename = ('coverage_by_line_%s.json' % (
58 self._skia_api.got_revision, git_timestamp)) 60 self._skia_api.got_revision))
59 line_by_line_basename = ('coverage_by_line_%s_%s.json' % (
60 self._skia_api.got_revision, git_timestamp))
61 line_by_line = results_dir.join(line_by_line_basename) 61 line_by_line = results_dir.join(line_by_line_basename)
62 args = [ 62 args = [
63 'python', 63 'python',
64 self._skia_api.m.path['slave_build'].join('skia', 'tools', 64 self._skia_api.m.path['slave_build'].join('skia', 'tools',
65 'parse_llvm_coverage.py'), 65 'parse_llvm_coverage.py'),
66 '--report', report_file, '--nanobench', nanobench_json, 66 '--report', report_file, '--nanobench', nanobench_json,
67 '--linebyline', line_by_line] 67 '--linebyline', line_by_line]
68 args.extend(key) 68 args.extend(key)
69 args.extend(properties) 69 args.extend(properties)
70 self._skia_api.run( 70 self._skia_api.run(
71 self._skia_api.m.step, 71 self._skia_api.m.step,
72 'Generate Coverage Data', 72 'Generate Coverage Data',
73 cmd=args, cwd=self._skia_api.m.path['checkout']) 73 cmd=args, cwd=self._skia_api.m.path['checkout'])
74 74
75 # Upload raw coverage data. 75 # Copy files from results_dir into swarming_out_dir.
76 now = self._skia_api.m.time.utcnow() 76 for r in self._skia_api.m.file.listdir('results_dir', results_dir):
77 gs_json_path = '/'.join(( 77 self._skia_api.m.file.copy(
78 str(now.year).zfill(4), str(now.month).zfill(2), 78 'Copy to swarming out', results_dir.join(r),
79 str(now.day).zfill(2), str(now.hour).zfill(2), 79 self._skia_api.swarming_out_dir)
80 self._skia_api.builder_name,
81 str(self._skia_api.m.properties['buildnumber'])))
82 if self._skia_api.is_trybot:
83 gs_json_path = '/'.join(('trybot', gs_json_path,
84 str(self._skia_api.m.properties['issue'])))
85
86 self._skia_api.gsutil_upload(
87 'upload raw coverage data',
88 source=report_file,
89 bucket='skia-infra',
90 dest='/'.join(('coverage-raw-v1', gs_json_path, report_file_basename)))
91
92 # Upload nanobench JSON data.
93 gsutil_path = self._skia_api.m.path['depot_tools'].join(
94 'third_party', 'gsutil', 'gsutil')
95 upload_args = [self._skia_api.builder_name,
96 self._skia_api.m.properties['buildnumber'],
97 results_dir,
98 self._skia_api.got_revision, gsutil_path]
99 if self._skia_api.is_trybot:
100 upload_args.append(self._skia_api.m.properties['issue'])
101 self._skia_api.run(
102 self._skia_api.m.python,
103 'upload nanobench coverage results',
104 script=self._skia_api.resource('upload_bench_results.py'),
105 args=upload_args,
106 cwd=self._skia_api.m.path['checkout'],
107 abort_on_failure=False,
108 infra_step=True)
109
110 # Upload line-by-line coverage data.
111 self._skia_api.gsutil_upload(
112 'upload line-by-line coverage data',
113 source=line_by_line,
114 bucket='skia-infra',
115 dest='/'.join(('coverage-json-v1', gs_json_path,
116 line_by_line_basename)))
117
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/skia/api.py ('k') | scripts/slave/recipe_modules/skia/fake_specs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698