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

Side by Side Diff: infra/bots/recipe_modules/flavor/gn_android_flavor.py

Issue 2339713003: merge run and check-rc steps (Closed)
Patch Set: always logcat -d Created 4 years, 3 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
« no previous file with comments | « no previous file | infra/bots/recipes/swarm_test.expected/Test-Android-Clang-AndroidOne-CPU-MT6582-arm-Release-GN_Android.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 import default_flavor 5 import default_flavor
6 import subprocess 6 import subprocess
7 7
8 # Data should go under in _data_dir, which may be preserved across runs. 8 # Data should go under in _data_dir, which may be preserved across runs.
9 _data_dir = '/sdcard/revenge_of_the_skiabot/' 9 _data_dir = '/sdcard/revenge_of_the_skiabot/'
10 # Executables go under _bin_dir, which, well, allows executable files. 10 # Executables go under _bin_dir, which, well, allows executable files.
(...skipping 19 matching lines...) Expand all
30 30
31 def _run(self, title, *cmd, **kwargs): 31 def _run(self, title, *cmd, **kwargs):
32 self.m.vars.default_env = {k: v for (k,v) 32 self.m.vars.default_env = {k: v for (k,v)
33 in self.m.vars.default_env.iteritems() 33 in self.m.vars.default_env.iteritems()
34 if k in ['PATH']} 34 if k in ['PATH']}
35 return self.m.run(self.m.step, title, cmd=list(cmd), 35 return self.m.run(self.m.step, title, cmd=list(cmd),
36 cwd=self.m.vars.skia_dir, env={}, **kwargs) 36 cwd=self.m.vars.skia_dir, env={}, **kwargs)
37 37
38 def _adb(self, title, *cmd, **kwargs): 38 def _adb(self, title, *cmd, **kwargs):
39 self._ever_ran_adb = True 39 self._ever_ran_adb = True
40 # The only non-infra adb call (check rc) happens to not use _adb(). 40 # The only non-infra adb steps (dm / nanobench) happen to not use _adb().
41 if 'infra_step' not in kwargs: 41 if 'infra_step' not in kwargs:
42 kwargs['infra_step'] = True 42 kwargs['infra_step'] = True
43 return self._run(title, 'adb', *cmd, **kwargs) 43 return self._run(title, 'adb', *cmd, **kwargs)
44 44
45 def compile(self, unused_target, **kwargs): 45 def compile(self, unused_target, **kwargs):
46 compiler = self.m.vars.builder_cfg.get('compiler') 46 compiler = self.m.vars.builder_cfg.get('compiler')
47 configuration = self.m.vars.builder_cfg.get('configuration') 47 configuration = self.m.vars.builder_cfg.get('configuration')
48 extra_config = self.m.vars.builder_cfg.get('extra_config', '') 48 extra_config = self.m.vars.builder_cfg.get('extra_config', '')
49 os = self.m.vars.builder_cfg.get('os') 49 os = self.m.vars.builder_cfg.get('os')
50 target_arch = self.m.vars.builder_cfg.get('target_arch') 50 target_arch = self.m.vars.builder_cfg.get('target_arch')
(...skipping 20 matching lines...) Expand all
71 infra_step=True) 71 infra_step=True)
72 self._run('gn gen', 'gn', 'gen', self.out_dir, '--args=' + gn_args) 72 self._run('gn gen', 'gn', 'gen', self.out_dir, '--args=' + gn_args)
73 self._run('ninja', 'ninja', '-C', self.out_dir) 73 self._run('ninja', 'ninja', '-C', self.out_dir)
74 74
75 def install(self): 75 def install(self):
76 self._adb('mkdir ' + self.device_dirs.resource_dir, 76 self._adb('mkdir ' + self.device_dirs.resource_dir,
77 'shell', 'mkdir', '-p', self.device_dirs.resource_dir) 77 'shell', 'mkdir', '-p', self.device_dirs.resource_dir)
78 78
79 def cleanup_steps(self): 79 def cleanup_steps(self):
80 if self._ever_ran_adb: 80 if self._ever_ran_adb:
81 self._adb('dump log ', 'logcat', '-d')
borenet 2016/09/14 16:52:24 Nit: trailing space?
mtklein_C 2016/09/14 17:30:31 Done.
81 self._adb('reboot', 'reboot') 82 self._adb('reboot', 'reboot')
82 self._adb('kill adb server', 'kill-server') 83 self._adb('kill adb server', 'kill-server')
83 84
84 def step(self, name, cmd, env=None, **kwargs): 85 def step(self, name, cmd, env=None, **kwargs):
85 app = self.m.vars.skia_out.join(self.m.vars.configuration, cmd[0]) 86 app = self.m.vars.skia_out.join(self.m.vars.configuration, cmd[0])
86 self._adb('push %s' % cmd[0], 87 self._adb('push %s' % cmd[0],
87 'push', app, _bin_dir) 88 'push', app, _bin_dir)
88 89
89 sh = '%s.sh' % cmd[0] 90 sh = '%s.sh' % cmd[0]
90 self.m.run.writefile(self.m.vars.tmp_dir.join(sh), 91 self.m.run.writefile(self.m.vars.tmp_dir.join(sh),
91 'set -x; %s%s; echo $? >%src' % 92 'set -x; %s%s; echo $? >%src' %
92 (_bin_dir, subprocess.list2cmdline(map(str, cmd)), _bin_dir)) 93 (_bin_dir, subprocess.list2cmdline(map(str, cmd)), _bin_dir))
93 self._adb('push %s' % sh, 94 self._adb('push %s' % sh,
94 'push', self.m.vars.tmp_dir.join(sh), _bin_dir) 95 'push', self.m.vars.tmp_dir.join(sh), _bin_dir)
95 96
96 self._adb('clear log', 'logcat', '-c') 97 self._adb('clear log', 'logcat', '-c')
97 self._adb(cmd[0], 'shell', 'sh', _bin_dir + sh) 98 self.m.python.inline('%s' % cmd[0], """
98 self._adb('dump log ', 'logcat', '-d')
99
100 self.m.python.inline('check %s rc' % cmd[0], """
101 import subprocess 99 import subprocess
102 import sys 100 import sys
101 bin_dir = sys.argv[1]
102 sh = sys.argv[2]
103 subprocess.check_call(['adb', 'shell', 'sh', bin_dir + sh])
103 sys.exit(int(subprocess.check_output(['adb', 'shell', 'cat', 104 sys.exit(int(subprocess.check_output(['adb', 'shell', 'cat',
104 '%src']))) 105 bin_dir + 'rc'])))
borenet 2016/09/14 16:52:24 Please break this into a few lines and add a helpf
mtklein_C 2016/09/14 17:30:31 Done, mostly. We don't expect this 'adb shell ...
borenet 2016/09/14 17:44:35 Thanks. Mainly just want to distinguish between "t
105 """ % _bin_dir) 106 """, args=[_bin_dir, sh])
106 107
107 def copy_file_to_device(self, host, device): 108 def copy_file_to_device(self, host, device):
108 self._adb('push %s %s' % (host, device), 'push', host, device) 109 self._adb('push %s %s' % (host, device), 'push', host, device)
109 110
110 def copy_directory_contents_to_device(self, host, device): 111 def copy_directory_contents_to_device(self, host, device):
111 # Copy the tree, avoiding hidden directories and resolving symlinks. 112 # Copy the tree, avoiding hidden directories and resolving symlinks.
112 self.m.python.inline('push %s/* %s' % (host, device), """ 113 self.m.python.inline('push %s/* %s' % (host, device), """
113 import os 114 import os
114 import subprocess 115 import subprocess
115 import sys 116 import sys
(...skipping 16 matching lines...) Expand all
132 def read_file_on_device(self, path): 133 def read_file_on_device(self, path):
133 return self._adb('read %s' % path, 134 return self._adb('read %s' % path,
134 'shell', 'cat', path, stdout=self.m.raw_io.output()).stdout 135 'shell', 'cat', path, stdout=self.m.raw_io.output()).stdout
135 136
136 def remove_file_on_device(self, path): 137 def remove_file_on_device(self, path):
137 self._adb('rm %s' % path, 'shell', 'rm', '-f', path) 138 self._adb('rm %s' % path, 'shell', 'rm', '-f', path)
138 139
139 def create_clean_device_dir(self, path): 140 def create_clean_device_dir(self, path):
140 self._adb('rm %s' % path, 'shell', 'rm', '-rf', path) 141 self._adb('rm %s' % path, 'shell', 'rm', '-rf', path)
141 self._adb('mkdir %s' % path, 'shell', 'mkdir', '-p', path) 142 self._adb('mkdir %s' % path, 'shell', 'mkdir', '-p', path)
OLDNEW
« no previous file with comments | « no previous file | infra/bots/recipes/swarm_test.expected/Test-Android-Clang-AndroidOne-CPU-MT6582-arm-Release-GN_Android.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698