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

Unified Diff: scripts/slave/recipe_modules/chromium_android/api.py

Issue 1465343002: [Android] Add context manager to record logcat during step(s). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: scripts/slave/recipe_modules/chromium_android/api.py
diff --git a/scripts/slave/recipe_modules/chromium_android/api.py b/scripts/slave/recipe_modules/chromium_android/api.py
index e316adf60c69c8f90f3e2238593ed8a610c22042..47bbfd865cf63e9e8e640c320462799f024bd870 100644
--- a/scripts/slave/recipe_modules/chromium_android/api.py
+++ b/scripts/slave/recipe_modules/chromium_android/api.py
@@ -249,15 +249,6 @@ class AndroidApi(recipe_api.RecipeApi):
src_dir=self.m.path['slave_build'].join('src'),
exclude_files='lib.target,gen,android_webview,jingle_unittests')
- def spawn_logcat_monitor(self):
- self.m.step(
- 'spawn_logcat_monitor',
- [self.m.path['build'].join('scripts', 'slave', 'daemonizer.py'),
- '--', self.c.cr_build_android.join('adb_logcat_monitor.py'),
- self.m.chromium.c.build_dir.join('logcat')],
- env=self.m.chromium.get_env(),
- infra_step=True)
-
def spawn_device_monitor(self):
script = self.m.path['build'].join('scripts', 'slave', 'daemonizer.py')
args = [
@@ -675,18 +666,31 @@ class AndroidApi(recipe_api.RecipeApi):
args=['instrumentation'] + args,
**kwargs)
- def logcat_dump(self, gs_bucket=None):
+ def spawn_logcat_monitor(self, logcat_dir=None):
+ if not logcat_dir:
+ logcat_dir = self.m.chromium.c.build_dir.join('logcat')
luqui 2015/11/23 22:59:40 Sure you don't want this to be a config item?
mikecase (-- gone --) 2015/11/24 20:50:59 Added default_logcat_dir to config.
+
+ self.m.step(
+ 'spawn_logcat_monitor',
+ [self.m.path['build'].join('scripts', 'slave', 'daemonizer.py'),
+ '--', self.c.cr_build_android.join('adb_logcat_monitor.py'),
+ logcat_dir],
+ env=self.m.chromium.get_env(),
+ infra_step=True)
+
+ def logcat_dump(self, output_logcat_file, logcat_dir=None, gs_bucket=None):
+ if not logcat_dir:
+ logcat_dir = self.m.chromium.c.build_dir.join('logcat')
+
if gs_bucket:
- log_path = self.m.chromium.output_dir.join('full_log')
self.m.python(
'logcat_dump',
self.m.path['checkout'].join('build', 'android',
'adb_logcat_printer.py'),
- [ '--output-path', log_path,
- self.m.path['checkout'].join('out', 'logcat') ],
+ ['--output-path', output_logcat_file, logcat_dir],
infra_step=True)
self.m.gsutil.upload(
- log_path,
+ output_logcat_file,
gs_bucket,
'logcat_dumps/%s/%s' % (self.m.properties['buildername'],
self.m.properties['buildnumber']),
@@ -696,18 +700,30 @@ class AndroidApi(recipe_api.RecipeApi):
self.m.python(
'logcat_dump',
self.m.path['build'].join('scripts', 'slave', 'tee.py'),
- [self.m.chromium.output_dir.join('full_log'),
+ [output_logcat_file,
'--',
self.m.path['checkout'].join('build', 'android',
'adb_logcat_printer.py'),
- self.m.path['checkout'].join('out', 'logcat')],
- infra_step=True,
- )
+ logcat_dir],
+ infra_step=True)
- def stack_tool_steps(self):
- log_file = self.m.path['checkout'].join('out',
- self.m.chromium.c.BUILD_CONFIG,
- 'full_log')
+ @contextlib.contextmanager
+ def logcat(self, step_name):
+ """Context manager for recording logcat.
+
+ Args:
+ step_name: Name of the outer step. Any steps ran inside this context
+ manager will be nested inside.
+ """
+ with self.m.step.nest(step_name):
+ logcat_dir = self.m.path.mkdtemp('test_logcat')
+ self.spawn_logcat_monitor(logcat_dir)
+ yield
+ self.logcat_dump(logcat_dir=logcat_dir,
luqui 2015/11/23 22:59:40 Will this kill the logcat monitor.. or will the n
mikecase (-- gone --) 2015/11/24 20:50:59 So, I looked through the scripts, spawn_logcat_mon
+ output_logcat_file=self.m.raw_io.output('logcat'),
+ gs_bucket=None)
+
+ def stack_tool_steps(self, logcat_file):
target_arch = self.m.chromium.c.gyp_env.GYP_DEFINES['target_arch']
# gyp converts ia32 to x86, bot needs to do the same
target_arch = {'ia32': 'x86'}.get(target_arch) or target_arch
@@ -715,7 +731,7 @@ class AndroidApi(recipe_api.RecipeApi):
'stack_tool_with_logcat_dump',
[self.m.path['checkout'].join('third_party', 'android_platform',
'development', 'scripts', 'stack'),
- '--arch', target_arch, '--more-info', log_file],
+ '--arch', target_arch, '--more-info', logcat_file],
env=self.m.chromium.get_env(),
infra_step=True)
self.m.step(
@@ -729,7 +745,7 @@ class AndroidApi(recipe_api.RecipeApi):
[self.m.path['checkout'].join('build',
'android',
'asan_symbolize.py'),
- '-l', log_file], env=self.m.chromium.get_env(),
+ '-l', logcat_file], env=self.m.chromium.get_env(),
infra_step=True)
def test_report(self):
@@ -769,8 +785,10 @@ class AndroidApi(recipe_api.RecipeApi):
def common_tests_final_steps(self, logcat_gs_bucket=None):
self.shutdown_device_monitor()
- self.logcat_dump(gs_bucket=logcat_gs_bucket)
- self.stack_tool_steps()
+ logcat_file = self.m.chromium.output_dir.join('full_log')
+ self.logcat_dump(output_logcat_file=logcat_file,
+ gs_bucket=logcat_gs_bucket)
+ self.stack_tool_steps(logcat_file=logcat_file)
self.test_report()
def run_bisect_script(self, extra_src='', path_to_config='', **kwargs):

Powered by Google App Engine
This is Rietveld 408576698