| """Recipe for running a clang-based cast_shell build on the given patch.""" |
| import pathlib |
| |
| from cgi import test |
| from slave import base_recipe |
| from slave import base_step |
| from slave.step import cast_shell_step |
| from slave.step import code_coverage_step |
| from slave.step import landmine_step |
| from slave.step import make_clean_step |
| from slave.step import unittest_step |
| from slave.test import test_generator |
| |
| BUILD_CONFIGS = { |
| 'asan_x64_eng': { |
| 'build_args_product': 'asan_x64_eng', |
| 'build_args_official': False, |
| # TODO(b/148885147) Remove params below |
| 'sanitizer': 'asan', |
| }, |
| # Replacement of content_shell_grte_audio |
| 'audio_grte_eng': { |
| 'build_args_product': 'audio_grte_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| }, |
| # Replacement of content_shell_clang_audio_internal_gn |
| 'audio_x64_eng': { |
| 'build_args_product': 'audio_x64_eng', |
| 'build_args_official': False, |
| 'timeout_secs_run_gtest': 1 * 60 * 60, # Limit each test step by 1h |
| }, |
| # Replacement of content_shell_clang_audio_gn |
| 'audio_x64_user': { |
| 'build_args_product': 'audio_x64_user', |
| 'build_args_official': False, |
| 'timeout_secs_run_gtest': 1 * 60 * 60, # Limit each test step by 1h |
| }, |
| # Replacement of content_shell_grte_chirp |
| 'audioassistant_grte_eng': { |
| 'build_args_product': 'audioassistant_grte_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| }, |
| # Replacement of content_shell_x86_chirp, x86_clang_audio_chirp |
| 'audioassistant_x64_eng': { |
| 'build_args_product': 'audioassistant_x64_eng', |
| 'build_args_official': False, |
| 'timeout_secs_run_gtest': 1 * 60 * 60, # Limit each test step by 1h |
| # TODO(b/145840052): Remove once the build is fast enough. |
| 'timeout_secs_build_gtests': 5 * 60 * 60, |
| }, |
| # Replacement of content_shell_cube_arm_debug, arm_cube_debug |
| 'cube_arm_eng': { |
| 'build_args_product': 'cube_arm_eng', |
| 'build_args_official': False, |
| 'run_gtests': False, |
| }, |
| # Replacement of content_shell_cube_arm_internal, arm_cube_internal |
| 'cube_arm_user': { |
| 'build_args_product': 'cube_arm_user', |
| 'build_args_official': True, |
| 'run_gtests': False, |
| }, |
| # Replacement of content_shell_cube_x86_debug, x86_cube_debug |
| 'cube_x64_eng': { |
| 'build_args_product': 'cube_x64_eng', |
| 'build_args_official': False, |
| 'run_gtests': False, |
| }, |
| # Replacement of content_shell_cube_x86_internal, x86_cube_internal |
| 'cube_x64_user': { |
| 'build_args_product': 'cube_x64_user', |
| 'build_args_official': True, |
| 'run_gtests': False, |
| }, |
| # Replacement of grte_manhattan_camera |
| 'displayassistant_grte_camera_eng': { |
| 'build_args_product': 'displayassistant_grte_camera_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| }, |
| # Replacement of content_shell_grte_manhattan |
| 'displayassistant_grte_eng': { |
| 'build_args_product': 'displayassistant_grte_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| }, |
| # Replacement of grte_opal_camera |
| 'displayassistant_grte_opal_camera_eng': { |
| 'build_args_product': 'displayassistant_grte_opal_camera_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| }, |
| # Replacement of grte_opal |
| 'displayassistant_grte_opal_eng': { |
| 'build_args_product': 'displayassistant_grte_opal_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| }, |
| # Replacement of content_shell_x86_manhattan, x86_manhattan |
| 'displayassistant_x64_eng': { |
| 'build_args_product': 'displayassistant_x64_eng', |
| 'build_args_official': False, |
| 'timeout_secs_run_gtest': 1 * 60 * 60, # Limit each test step by 1h |
| # TODO(b/145840052): Remove once the build is fast enough. |
| 'timeout_secs_build_gtests': 5 * 60 * 60, |
| }, |
| 'gabbro_arm_eng': { |
| 'build_args_product': 'gabbro_arm_debug', |
| 'build_args_official': False, |
| 'run_gtests': False, |
| }, |
| 'gabbro_arm_user': { |
| 'build_args_product': 'gabbro_arm_internal', |
| 'build_args_official': True, |
| 'run_gtests': False, |
| }, |
| 'gabbro_x64_eng': { |
| 'build_args_product': 'gabbro_x86_debug', |
| 'build_args_official': False, |
| 'run_gtests': False, |
| }, |
| 'gabbro_x64_user': { |
| 'build_args_product': 'gabbro_x86_internal', |
| 'build_args_official': True, |
| 'run_gtests': False, |
| }, |
| 'grte_opal_selina': { |
| 'build_args_product': 'grte_opal_selina', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| }, |
| # Replacement of content_shell_desktop_msan, memory_sanitizer |
| 'msan_x64_eng': { |
| 'build_args_product': 'msan_x64_eng', |
| 'build_args_official': False, |
| 'timeout_secs_run_gtest': 1 * 60 * 60, # Limit each test step by 1h |
| # TODO(b/148885147) Remove params below |
| 'sanitizer': 'msan', |
| }, |
| # Replacement of content_shell_soba_arm_debug_gn, arm_soba_debug |
| 'soba_arm_eng': { |
| 'build_args_product': 'soba_arm_eng', |
| 'build_args_official': False, |
| 'run_gtests': False, |
| 'check_android_license': True, |
| }, |
| # Replacement of content_shell_soba_arm_noassist_debug_gn |
| 'soba_arm_noassist_eng': { |
| 'build_args_product': 'soba_arm_noassist_eng', |
| 'build_args_official': False, |
| 'run_gtests': False, |
| 'check_android_license': True, |
| }, |
| # Replacement of content_shell_soba_arm_noassist_internal_gn |
| 'soba_arm_noassist_user': { |
| 'build_args_product': 'soba_arm_noassist_user', |
| 'build_args_official': True, |
| 'run_gtests': False, |
| 'check_android_license': True, |
| }, |
| # Replacement of content_shell_soba_arm_internal_gn |
| 'soba_arm_user': { |
| 'build_args_product': 'soba_arm_user', |
| 'build_args_official': True, |
| 'run_gtests': False, |
| 'check_android_license': True, |
| }, |
| # Replacement of content_shell_soba_x86_debug_gn, x86_soba_debug |
| 'soba_x64_eng': { |
| 'build_args_product': 'soba_x64_eng', |
| 'build_args_official': False, |
| 'run_gtests': False, |
| 'check_android_license': True, |
| }, |
| # Replacement of thread_sanitizer |
| 'tsan_x64_eng': { |
| 'build_args_product': 'tsan_x64_eng', |
| 'build_args_official': False, |
| }, |
| # Replacement of content_shell_udon_arm_debug_gn, arm_udon_debug |
| 'udon_arm_eng': { |
| 'build_args_product': 'udon_arm_eng', |
| 'build_args_official': False, |
| 'run_gtests': False, |
| }, |
| # Replacement of content_shell_udon_arm_internal_gn |
| 'udon_arm_user': { |
| 'build_args_product': 'udon_arm_user', |
| 'build_args_official': True, |
| 'run_gtests': False, |
| }, |
| # Replacement of content_shell_udon_x86_debug_gn, x86_udon_debug |
| 'udon_x64_eng': { |
| 'build_args_product': 'udon_x64_eng', |
| 'build_args_official': False, |
| 'run_gtests': False, |
| }, |
| # Replacement of content_shell_udon_x86_internal_gn |
| 'udon_x64_user': { |
| 'build_args_product': 'udon_x64_user', |
| 'build_args_official': True, |
| 'run_gtests': False, |
| }, |
| # Replacement of x86_udon_assistant_debug |
| 'udonassistant_x64_eng': { |
| 'build_args_product': 'udonassistant_x64_eng', |
| 'build_args_official': False, |
| 'run_gtests': False, |
| }, |
| # Replacement of content_shell_grte_video |
| 'video_grte_eng': { |
| 'build_args_product': 'video_grte_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| }, |
| # CWR, x64, release |
| 'cwr_x64-user': { |
| 'build_args_product': 'video_cwr_x64_user', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| }, |
| # CWR, x64, debug |
| 'cwr_x64-eng': { |
| 'build_args_product': 'video_cwr_x64_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| }, |
| # CWR for RaspberryPi, ARMv7a, release |
| 'cwr_rpix_armv7a-user': { |
| 'build_args_product': 'video_cwr_rpix_armv7a_user', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| 'enable_build_accelerator': False, |
| }, |
| # CWR for RaspberryPi, ARMv7a, debug |
| 'cwr_rpix_armv7a-eng': { |
| 'build_args_product': 'video_cwr_rpix_armv7a_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| 'enable_build_accelerator': False, |
| }, |
| # CWR for WebOS, ARMv7a softfp, release |
| 'cwr_webos_arm-user': { |
| 'build_args_product': 'video_cwr_webos_arm_user', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| 'enable_build_accelerator': False, |
| }, |
| # CWR for WebOS, ARMv7a softfp, debug |
| 'cwr_webos_arm-eng': { |
| 'build_args_product': 'video_cwr_webos_arm_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| 'enable_build_accelerator': False, |
| }, |
| # CWR for WebOS24, ARMv7a softfp, release |
| 'cwr_webos24_arm-user': { |
| 'build_args_product': 'video_cwr_webos24_arm_user', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| 'enable_build_accelerator': False, |
| }, |
| # CWR for WebOS24, ARMv7a softfp, debug |
| 'cwr_webos24_arm-eng': { |
| 'build_args_product': 'video_cwr_webos24_arm_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| 'enable_build_accelerator': False, |
| }, |
| # CWR for CrOS, ARMv7a hard, release |
| 'cwr_cros_arm-user': { |
| 'build_args_product': 'video_cwr_cros_arm_user', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| 'enable_build_accelerator': False, |
| }, |
| # CWR for CrOS, ARMv7a hard, debug |
| 'cwr_cros_arm-eng': { |
| 'build_args_product': 'video_cwr_cros_arm_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| 'enable_build_accelerator': False, |
| }, |
| # CWR for RDK Dunfell, ARMv7a hard, release |
| 'cwr_rdk_dunfell_arm-user': { |
| 'build_args_product': 'video_cwr_rdk_dunfell_armv7a_user', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| 'enable_build_accelerator': False, |
| }, |
| # CWR for RDK Dunfell, ARMv7a hard, debug |
| 'cwr_rdk_dunfell_arm-eng': { |
| 'build_args_product': 'video_cwr_rdk_dunfell_armv7a_eng', |
| 'build_args_official': False, |
| 'build_gtests': False, |
| 'build_target': 'chromecast/internal/build/packaging:cwr_package_cksum', |
| 'enable_build_accelerator': False, |
| }, |
| # Replacement of x86_clang_internal_absolute_code_coverage |
| 'video_x64_absolute_code_coverage_eng': { |
| 'build_args_product': 'video_x64_eng', |
| 'build_args_official': False, |
| 'code_coverage': True, |
| 'report_to_zoss': True, |
| 'absolute_coverage': True, |
| 'timeout_secs_build_gtests': 5 * 60 * 60, |
| }, |
| # Replacement of content_shell_clang_internal_gn, x86_clang_internal |
| 'video_x64_eng': { |
| 'build_args_product': 'video_x64_eng', |
| 'build_args_official': False, |
| 'timeout_secs_run_gtest': 1 * 60 * 60, # Limit each test step by 1h |
| # TODO(b/148885147) Remove params below |
| 'code_coverage': False, # TODO(b/33835295): Temporarily disable since |
| # code coverage is often causing builds to take |
| # an extra hour to complete and not actually |
| # producing useful coverage results. |
| }, |
| # Replacement of content_shell_unfork_clang_gn |
| 'video_x64_user': { |
| 'build_args_product': 'video_x64_user', |
| 'build_args_official': False, |
| 'timeout_secs_run_gtest': 1 * 60 * 60, # Limit each test step by 1h |
| # TODO(b/148885147) Remove params below |
| 'code_coverage': False, # TODO(b/33835295): Temporarily disable since |
| # code coverage is often causing builds to take |
| # an extra hour to complete and not actually |
| # producing useful coverage results. |
| }, |
| # This build is only for libassistant code coverage experiment. |
| # TODO(mengdi): make sure this build only build and run libassistant |
| # unittests with --whitelisted_tests. |
| 'x86_clang_audio_chirp_libassistant_code_coverage': { |
| 'build_args_product': 'audioassistant_x64_eng', |
| 'build_args_official': False, |
| 'absolute_coverage': True, |
| 'code_coverage': True, |
| |
| # TODO(b/145840052): Remove once the build is fast enough. |
| 'timeout_secs_build_gtests': 5 * 60 * 60, |
| }, |
| # TODO(b/73288720) remove after migration to |
| # video_x64_absolute_code_coverage_eng |
| 'x86_clang_internal_absolute_code_coverage': { |
| 'build_args_product': 'displayassistant_x64_eng', |
| 'build_args_official': False, |
| 'code_coverage': True, |
| 'absolute_coverage': True, |
| |
| # TODO(b/145840052): Remove once the build is fast enough. |
| 'timeout_secs_build_gtests': 5 * 60 * 60, |
| }, |
| # TODO(b/73231972) Not used in CQ, to be removed |
| 'x86_clang_internal_incremental_code_coverage': { |
| 'build_args_product': 'video_x64_eng', |
| 'build_args_official': False, |
| 'code_coverage': True, |
| |
| # TODO(b/145840052): Remove once the build is fast enough. |
| 'timeout_secs_build_gtests': 5 * 60 * 60, |
| }, |
| } |
| |
| |
| def GetValidBuildNames(): |
| return list(BUILD_CONFIGS.keys()) |
| |
| |
| def CreateRecipe(build_name: str, **kwargs): |
| """Builds a recipe object.""" |
| config = BUILD_CONFIGS[build_name] |
| # Extracts default_properties from build config and adds it to the overall |
| # properties in kwargs. |
| default_properties = config.get('default_properties', {}) |
| kwargs['properties'] = dict( |
| list(default_properties.items()) + |
| list(kwargs.get('properties', {}).items())) |
| return ClangRecipe(config, **kwargs) |
| |
| |
| class ClangRecipe(base_recipe.BaseRecipe): |
| """Recipe to run a clang-based cast-shell build.""" |
| |
| def __init__(self, config, **kwargs): |
| base_recipe.BaseRecipe.__init__( |
| self, |
| check_android_license=config.get('check_android_license', False), |
| enable_build_accelerator=config.get('enable_build_accelerator', True), |
| **kwargs) |
| self._config = config |
| self._properties = kwargs.get('properties', {}) |
| |
| def get_steps(self): |
| build_args_product = self._config['build_args_product'] |
| build_args_official = self._config.get('build_args_official', None) |
| build_gtests = self._config.get('build_gtests', True) |
| run_gtests = self._config.get('run_gtests', True) |
| code_coverage = self._config.get('code_coverage', False) |
| report_to_zoss = self._config.get('report_to_zoss', False) |
| absolute_coverage = self._config.get('absolute_coverage', False) |
| grte_compatible = self._config.get('grte_compatible', False) |
| sanitizer = self._config.get('sanitizer', None) |
| build_target = self._config.get('build_target', None) |
| |
| steps = [] |
| |
| if self.build_system == 'catabuilder': |
| steps.append(make_clean_step.MakeCleanStep(**self._step_kwargs)) |
| else: |
| steps += [ |
| landmine_step.LandmineStep(**self._step_kwargs), |
| ] |
| |
| # Sanitizers work by running the unittests. No need to waste time |
| # building cast shell by itself. |
| # Always build on CB to have an option of manual debug |
| # out_dir generated by CastShellStep also used by RunCoverageCommandStep. |
| if sanitizer is None or self.build_system == 'catabuilder': |
| steps += [ |
| cast_shell_step.CastShellStep( |
| build_args_official=build_args_official, |
| code_coverage=code_coverage, |
| grte_compatible=grte_compatible, |
| build_args_product=build_args_product, |
| halt_on_failure=True, |
| sanitizer=sanitizer, |
| build_target=build_target, |
| **self._step_kwargs), |
| ] |
| |
| if build_gtests: |
| steps += [ |
| unittest_step.BuildAffectedUnitTestsStep( |
| build_args_official=build_args_official, |
| sanitizer=sanitizer, |
| code_coverage=code_coverage, |
| absolute_coverage=absolute_coverage, |
| build_args_product=build_args_product, |
| halt_on_failure=True, |
| timeout_secs=self._config.get('timeout_secs_build_gtests', |
| base_step.STEP_MAX_TIME_SECONDS), |
| **self._step_kwargs), |
| ] |
| |
| # TODO(maasen): Move issue & patchset to properties on the base_step |
| # and generate this URL there. |
| if build_gtests and run_gtests and not code_coverage: |
| if 'issue' in self._properties and 'patchset' in self._properties: |
| report_url = 'http://go/cast-cq/coverage/{0}/{1}'.format( |
| self._properties['issue'], self._properties['patchset']) |
| else: |
| report_url = '' |
| |
| steps += [ |
| unittest_step.RunAffectedUnitTestsStep( |
| report_url, |
| steps, |
| sanitizer=sanitizer, |
| build_args_product=build_args_product, |
| build_args_official=build_args_official, |
| enable_network_service=True, |
| timeout_secs=self._config.get('timeout_secs_run_gtest', |
| base_step.STEP_MAX_TIME_SECONDS), |
| **self._step_kwargs), |
| ] |
| |
| elif code_coverage: |
| |
| if report_to_zoss: |
| report_format = 'lcov' |
| ignore_filename_regex = '.*/gen/.*|.*/third_party/.*' |
| else: |
| report_format = None |
| ignore_filename_regex = None |
| |
| coverage_step = code_coverage_step.RunCoverageCommandStep( |
| sanitizer=sanitizer, |
| build_args_product=build_args_product, |
| build_args_official=build_args_official, |
| ignore_filename_regex=ignore_filename_regex, |
| report_format=report_format, |
| **self._step_kwargs, |
| ) |
| steps.append(coverage_step) |
| if report_to_zoss: |
| steps.append( |
| code_coverage_step.CollectLcovCoverageStep( |
| lcov_files=coverage_step.get_lcov_output_file_paths(), |
| **self._step_kwargs, |
| ) |
| ) |
| |
| return steps |