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

Side by Side Diff: scripts/slave/recipe_modules/chromium_android/api.py

Issue 1511403002: Revert "[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 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium_android/config.py » ('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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 contextlib 5 import contextlib
6 import datetime 6 import datetime
7 import json 7 import json
8 import os 8 import os
9 import re 9 import re
10 import urllib 10 import urllib
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 # (or at least make the difference clear). 242 # (or at least make the difference clear).
243 self.m.archive.zip_and_upload_build( 243 self.m.archive.zip_and_upload_build(
244 'zip_build', 244 'zip_build',
245 target=self.m.chromium.c.BUILD_CONFIG, 245 target=self.m.chromium.c.BUILD_CONFIG,
246 # We send None as the path so that zip_build.py gets it from factory 246 # We send None as the path so that zip_build.py gets it from factory
247 # properties. 247 # properties.
248 build_url=None, 248 build_url=None,
249 src_dir=self.m.path['slave_build'].join('src'), 249 src_dir=self.m.path['slave_build'].join('src'),
250 exclude_files='lib.target,gen,android_webview,jingle_unittests') 250 exclude_files='lib.target,gen,android_webview,jingle_unittests')
251 251
252 def spawn_logcat_monitor(self):
253 self.m.step(
254 'spawn_logcat_monitor',
255 [self.m.path['build'].join('scripts', 'slave', 'daemonizer.py'),
256 '--', self.c.cr_build_android.join('adb_logcat_monitor.py'),
257 self.m.chromium.c.build_dir.join('logcat')],
258 env=self.m.chromium.get_env(),
259 infra_step=True)
260
252 def spawn_device_monitor(self): 261 def spawn_device_monitor(self):
253 script = self.m.path['build'].join('scripts', 'slave', 'daemonizer.py') 262 script = self.m.path['build'].join('scripts', 'slave', 'daemonizer.py')
254 args = [ 263 args = [
255 '--action', 'restart', 264 '--action', 'restart',
256 '--pid-file-path', '/tmp/device_monitor.pid', 265 '--pid-file-path', '/tmp/device_monitor.pid',
257 '--', self.resource('spawn_device_monitor.py'), 266 '--', self.resource('spawn_device_monitor.py'),
258 self.m.adb.adb_path(), 267 self.m.adb.adb_path(),
259 json.dumps(self._devices), 268 json.dumps(self._devices),
260 self.m.properties['mastername'], 269 self.m.properties['mastername'],
261 self.m.properties['buildername'], 270 self.m.properties['buildername'],
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 '--n', count, 701 '--n', count,
693 'shutdown', 702 'shutdown',
694 ] 703 ]
695 self.m.python( 704 self.m.python(
696 'shutdown_instances', 705 'shutdown_instances',
697 self.resource('gce_manager.py'), 706 self.resource('gce_manager.py'),
698 args, 707 args,
699 infra_step=True, 708 infra_step=True,
700 ) 709 )
701 710
702 def spawn_logcat_monitor(self, logcat_dir=None): 711 def logcat_dump(self, gs_bucket=None):
703 if not logcat_dir:
704 logcat_dir = self.c.default_logcat_dir
705
706 self.m.step(
707 'spawn_logcat_monitor',
708 [self.m.path['build'].join('scripts', 'slave', 'daemonizer.py'),
709 '--', self.c.cr_build_android.join('adb_logcat_monitor.py'),
710 logcat_dir],
711 env=self.m.chromium.get_env(),
712 infra_step=True)
713
714 def logcat_dump(self, output_logcat_file, logcat_dir=None, gs_bucket=None):
715 if not logcat_dir:
716 logcat_dir = self.c.default_logcat_dir
717
718 if gs_bucket: 712 if gs_bucket:
713 log_path = self.m.chromium.output_dir.join('full_log')
719 self.m.python( 714 self.m.python(
720 'logcat_dump', 715 'logcat_dump',
721 self.m.path['checkout'].join('build', 'android', 716 self.m.path['checkout'].join('build', 'android',
722 'adb_logcat_printer.py'), 717 'adb_logcat_printer.py'),
723 ['--output-path', output_logcat_file, logcat_dir], 718 [ '--output-path', log_path,
719 self.m.path['checkout'].join('out', 'logcat') ],
724 infra_step=True) 720 infra_step=True)
725
726 try: 721 try:
727 self.m.gsutil.upload( 722 self.m.gsutil.upload(
728 output_logcat_file, 723 log_path,
729 gs_bucket, 724 gs_bucket,
730 'logcat_dumps/%s/%s' % (self.m.properties['buildername'], 725 'logcat_dumps/%s/%s' % (self.m.properties['buildername'],
731 self.m.properties['buildnumber']), 726 self.m.properties['buildnumber']),
732 link_name='logcat dump', 727 link_name='logcat dump',
733 version='4.7', 728 version='4.7',
734 parallel_upload=True, 729 parallel_upload=True,
735 timeout=300) 730 timeout=300)
736 except self.m.step.StepFailure: 731 except self.m.step.StepFailure:
737 # TODO(bpastene): Remove the following if the blab gs issue is resolved 732 # TODO(bpastene): Remove the following if the blab gs issue is resolved
738 # If the upload fails, change it to a warning and continue on with 733 # If the upload fails, change it to a warning and continue on with
739 # the build. We don't want a failed logcat upload crashing a tryjob 734 # the build. We don't want a failed logcat upload crashing a tryjob
740 step_result = self.m.step.active_result 735 step_result = self.m.step.active_result
741 step_result.presentation.status = self.m.step.WARNING 736 step_result.presentation.status = self.m.step.WARNING
737
742 else: 738 else:
743 self.m.python( 739 self.m.python(
744 'logcat_dump', 740 'logcat_dump',
745 self.m.path['build'].join('scripts', 'slave', 'tee.py'), 741 self.m.path['build'].join('scripts', 'slave', 'tee.py'),
746 [output_logcat_file, 742 [self.m.chromium.output_dir.join('full_log'),
747 '--', 743 '--',
748 self.m.path['checkout'].join('build', 'android', 744 self.m.path['checkout'].join('build', 'android',
749 'adb_logcat_printer.py'), 745 'adb_logcat_printer.py'),
750 logcat_dir], 746 self.m.path['checkout'].join('out', 'logcat')],
751 infra_step=True) 747 infra_step=True,
748 )
752 749
753 @contextlib.contextmanager 750 def stack_tool_steps(self):
754 def logcat(self, step_name): 751 log_file = self.m.path['checkout'].join('out',
755 """Context manager for recording logcat. 752 self.m.chromium.c.BUILD_CONFIG,
756 753 'full_log')
757 Args:
758 step_name: Name of the outer step. Any steps ran inside this context
759 manager will be nested inside.
760 """
761 with self.m.step.nest(step_name):
762 logcat_dir = self.m.path.mkdtemp('logcat')
763 self.spawn_logcat_monitor(logcat_dir)
764 yield
765 self.logcat_dump(logcat_dir=logcat_dir,
766 output_logcat_file=self.m.raw_io.output('logcat'),
767 gs_bucket=None)
768
769 def stack_tool_steps(self, logcat_file):
770 target_arch = self.m.chromium.c.gyp_env.GYP_DEFINES['target_arch'] 754 target_arch = self.m.chromium.c.gyp_env.GYP_DEFINES['target_arch']
771 # gyp converts ia32 to x86, bot needs to do the same 755 # gyp converts ia32 to x86, bot needs to do the same
772 target_arch = {'ia32': 'x86'}.get(target_arch) or target_arch 756 target_arch = {'ia32': 'x86'}.get(target_arch) or target_arch
773 self.m.step( 757 self.m.step(
774 'stack_tool_with_logcat_dump', 758 'stack_tool_with_logcat_dump',
775 [self.m.path['checkout'].join('third_party', 'android_platform', 759 [self.m.path['checkout'].join('third_party', 'android_platform',
776 'development', 'scripts', 'stack'), 760 'development', 'scripts', 'stack'),
777 '--arch', target_arch, '--more-info', logcat_file], 761 '--arch', target_arch, '--more-info', log_file],
778 env=self.m.chromium.get_env(), 762 env=self.m.chromium.get_env(),
779 infra_step=True) 763 infra_step=True)
780 self.m.step( 764 self.m.step(
781 'stack_tool_for_tombstones', 765 'stack_tool_for_tombstones',
782 [self.m.path['checkout'].join('build', 'android', 'tombstones.py'), 766 [self.m.path['checkout'].join('build', 'android', 'tombstones.py'),
783 '-a', '-s', '-w'], env=self.get_env(), 767 '-a', '-s', '-w'], env=self.get_env(),
784 infra_step=True) 768 infra_step=True)
785 if self.c.asan_symbolize: 769 if self.c.asan_symbolize:
786 self.m.step( 770 self.m.step(
787 'stack_tool_for_asan', 771 'stack_tool_for_asan',
788 [self.m.path['checkout'].join('build', 772 [self.m.path['checkout'].join('build',
789 'android', 773 'android',
790 'asan_symbolize.py'), 774 'asan_symbolize.py'),
791 '-l', logcat_file], env=self.m.chromium.get_env(), 775 '-l', log_file], env=self.m.chromium.get_env(),
792 infra_step=True) 776 infra_step=True)
793 777
794 def test_report(self): 778 def test_report(self):
795 self.m.python.inline( 779 self.m.python.inline(
796 'test_report', 780 'test_report',
797 """ 781 """
798 import glob, os, sys 782 import glob, os, sys
799 for report in glob.glob(sys.argv[1]): 783 for report in glob.glob(sys.argv[1]):
800 with open(report, 'r') as f: 784 with open(report, 'r') as f:
801 for l in f.readlines(): 785 for l in f.readlines():
(...skipping 25 matching lines...) Expand all
827 kwargs = {} 811 kwargs = {}
828 self.provision_devices(**kwargs) 812 self.provision_devices(**kwargs)
829 if self.m.chromium.c.gyp_env.GYP_DEFINES.get('asan', 0) == 1: 813 if self.m.chromium.c.gyp_env.GYP_DEFINES.get('asan', 0) == 1:
830 self.asan_device_setup() 814 self.asan_device_setup()
831 815
832 self.spawn_device_monitor() 816 self.spawn_device_monitor()
833 817
834 def common_tests_final_steps(self, logcat_gs_bucket=None): 818 def common_tests_final_steps(self, logcat_gs_bucket=None):
835 if not self.c.gce_setup: 819 if not self.c.gce_setup:
836 self.shutdown_device_monitor() 820 self.shutdown_device_monitor()
837 logcat_file = self.m.chromium.output_dir.join('full_log') 821 self.logcat_dump(gs_bucket=logcat_gs_bucket)
838 self.logcat_dump(output_logcat_file=logcat_file, 822 self.stack_tool_steps()
839 gs_bucket=logcat_gs_bucket)
840 self.stack_tool_steps(logcat_file=logcat_file)
841 if self.c.gce_setup: 823 if self.c.gce_setup:
842 self.shutdown_gce_instances() 824 self.shutdown_gce_instances()
843 self.test_report() 825 self.test_report()
844 826
845 def run_bisect_script(self, extra_src='', path_to_config='', **kwargs): 827 def run_bisect_script(self, extra_src='', path_to_config='', **kwargs):
846 self.m.step('prepare bisect perf regression', 828 self.m.step('prepare bisect perf regression',
847 [self.m.path['checkout'].join('tools', 829 [self.m.path['checkout'].join('tools',
848 'prepare-bisect-perf-regression.py'), 830 'prepare-bisect-perf-regression.py'),
849 '-w', self.m.path['slave_build']]) 831 '-w', self.m.path['slave_build']])
850 832
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 def test_runner(self, step_name, args=None, **kwargs): 1091 def test_runner(self, step_name, args=None, **kwargs):
1110 """Wrapper for the python testrunner script. 1092 """Wrapper for the python testrunner script.
1111 1093
1112 Args: 1094 Args:
1113 step_name: Name of the step. 1095 step_name: Name of the step.
1114 args: Testrunner arguments. 1096 args: Testrunner arguments.
1115 """ 1097 """
1116 with self.handle_exit_codes(): 1098 with self.handle_exit_codes():
1117 return self.m.python( 1099 return self.m.python(
1118 step_name, self.c.test_runner, args, **kwargs) 1100 step_name, self.c.test_runner, args, **kwargs)
OLDNEW
« 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