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

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: Removed unused config. 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
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium_android/config.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3ca319e5613f6ad74d6e29fc6ef6df0038f81fbf..b1c9424b256c224bd18ba33d055f7f8d898f2aaa 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 = [
@@ -705,18 +696,31 @@ class AndroidApi(recipe_api.RecipeApi):
infra_step=True,
)
- def logcat_dump(self, gs_bucket=None):
+ def spawn_logcat_monitor(self, logcat_dir=None):
+ if not logcat_dir:
+ logcat_dir = self.c.default_logcat_dir
+
+ 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.c.default_logcat_dir
+
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']),
@@ -726,18 +730,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('logcat')
+ self.spawn_logcat_monitor(logcat_dir)
+ yield
+ self.logcat_dump(logcat_dir=logcat_dir,
+ 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
@@ -745,7 +761,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(
@@ -759,7 +775,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):
@@ -804,8 +820,10 @@ class AndroidApi(recipe_api.RecipeApi):
def common_tests_final_steps(self, logcat_gs_bucket=None):
if not self.c.gce_setup:
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)
if self.c.gce_setup:
self.shutdown_gce_instances()
self.test_report()
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium_android/config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698