def _CloneSizeInfo(self, use_output_directory=True, use_elf=True, use_pak=False): assert not use_elf or use_output_directory cache_key = (use_output_directory, use_elf, use_pak) if cache_key not in IntegrationTest.cached_size_info: elf_path = _TEST_ELF_PATH if use_elf else None output_directory = _TEST_OUTPUT_DIR if use_output_directory else None if use_pak: section_sizes, raw_symbols = archive.CreateSectionSizesAndSymbols( map_path=_TEST_MAP_PATH, tool_prefix=_TEST_TOOL_PREFIX, elf_path=elf_path, output_directory=output_directory, pak_files=[_TEST_PAK_PATH], pak_info_file=_TEST_PAK_INFO_PATH) else: section_sizes, raw_symbols = archive.CreateSectionSizesAndSymbols( map_path=_TEST_MAP_PATH, tool_prefix=_TEST_TOOL_PREFIX, elf_path=elf_path, output_directory=output_directory) metadata = None if use_elf: with _AddMocksToPath(): metadata = archive.CreateMetadata( _TEST_MAP_PATH, elf_path, None, _TEST_TOOL_PREFIX, output_directory) IntegrationTest.cached_size_info[cache_key] = archive.CreateSizeInfo( section_sizes, raw_symbols, metadata=metadata) return copy.deepcopy(IntegrationTest.cached_size_info[cache_key])
def _CloneSizeInfo(self, use_output_directory=True, use_elf=True, use_apk=False, use_minimal_apks=False, use_pak=False): assert not use_elf or use_output_directory assert not (use_apk and use_pak) cache_key = ( use_output_directory, use_elf, use_apk, use_minimal_apks, use_pak) if cache_key not in IntegrationTest.cached_size_info: elf_path = _TEST_ELF_PATH if use_elf else None output_directory = _TEST_OUTPUT_DIR if use_output_directory else None knobs = archive.SectionSizeKnobs() opts = archive.ContainerArchiveOptions(self._CreateTestArgs()) # Override for testing. Lower the bar for compacting symbols, to allow # smaller test cases to be created. knobs.max_same_name_alias_count = 3 apk_path = None minimal_apks_path = None apk_so_path = None size_info_prefix = None extracted_minimal_apk_path = None if use_apk: apk_path = _TEST_APK_PATH elif use_minimal_apks: minimal_apks_path = _TEST_MINIMAL_APKS_PATH extracted_minimal_apk_path = _TEST_APK_PATH if use_apk or use_minimal_apks: apk_so_path = _TEST_APK_SO_PATH if output_directory: if use_apk: orig_path = _TEST_APK_PATH else: orig_path = _TEST_MINIMAL_APKS_PATH.replace('.minimal.apks', '.aab') size_info_prefix = os.path.join( output_directory, 'size-info', os.path.basename(orig_path)) pak_files = None pak_info_file = None if use_pak: pak_files = [_TEST_APK_LOCALE_PAK_PATH, _TEST_APK_PAK_PATH] pak_info_file = _TEST_PAK_INFO_PATH linker_name = 'gold' with _AddMocksToPath(): metadata = archive.CreateMetadata(_TEST_MAP_PATH, elf_path, apk_path, minimal_apks_path, _TEST_TOOL_PREFIX, output_directory, linker_name) section_sizes, raw_symbols = archive.CreateSectionSizesAndSymbols( knobs=knobs, opts=opts, map_path=_TEST_MAP_PATH, tool_prefix=_TEST_TOOL_PREFIX, elf_path=elf_path, output_directory=output_directory, apk_path=apk_path or extracted_minimal_apk_path, apk_so_path=apk_so_path, metadata=metadata, pak_files=pak_files, pak_info_file=pak_info_file, linker_name=linker_name, size_info_prefix=size_info_prefix) IntegrationTest.cached_size_info[cache_key] = archive.CreateSizeInfo( [section_sizes], [raw_symbols], [metadata]) return copy.deepcopy(IntegrationTest.cached_size_info[cache_key])
def _CloneSizeInfo(self, use_output_directory=True, use_elf=True, use_pak=False): assert not use_elf or use_output_directory cache_key = (use_output_directory, use_elf, use_pak) if cache_key not in IntegrationTest.cached_size_info: elf_path = _TEST_ELF_PATH if use_elf else None output_directory = _TEST_OUTPUT_DIR if use_output_directory else None knobs = archive.SectionSizeKnobs() # Override for testing. Lower the bar for compacting symbols, to allow # smaller test cases to be created. knobs.max_same_name_alias_count = 3 if use_pak: section_sizes, raw_symbols = archive.CreateSectionSizesAndSymbols( map_path=_TEST_MAP_PATH, tool_prefix=_TEST_TOOL_PREFIX, elf_path=elf_path, output_directory=output_directory, pak_files=[_TEST_PAK_PATH], pak_info_file=_TEST_PAK_INFO_PATH, knobs=knobs) else: section_sizes, raw_symbols = archive.CreateSectionSizesAndSymbols( map_path=_TEST_MAP_PATH, tool_prefix=_TEST_TOOL_PREFIX, elf_path=elf_path, output_directory=output_directory, knobs=knobs) metadata = None if use_elf: with _AddMocksToPath(): metadata = archive.CreateMetadata(_TEST_MAP_PATH, elf_path, None, _TEST_TOOL_PREFIX, output_directory) IntegrationTest.cached_size_info[ cache_key] = archive.CreateSizeInfo(section_sizes, raw_symbols, metadata=metadata) return copy.deepcopy(IntegrationTest.cached_size_info[cache_key])
def _CloneSizeInfo(self, use_output_directory=True, use_elf=True, use_apk=False, use_pak=False): assert not use_elf or use_output_directory assert not (use_apk and use_pak) cache_key = (use_output_directory, use_elf, use_apk, use_pak) if cache_key not in IntegrationTest.cached_size_info: elf_path = _TEST_ELF_PATH if use_elf else None output_directory = _TEST_OUTPUT_DIR if use_output_directory else None knobs = archive.SectionSizeKnobs() # Override for testing. Lower the bar for compacting symbols, to allow # smaller test cases to be created. knobs.max_same_name_alias_count = 3 knobs.src_root = _TEST_SOURCE_DIR apk_path = None apk_so_path = None if use_apk: apk_path = _TEST_APK_PATH apk_so_path = _TEST_APK_SO_PATH pak_files = None pak_info_file = None if use_pak: pak_files = [_TEST_APK_PAK_PATH] pak_info_file = _TEST_PAK_INFO_PATH metadata = None linker_name = 'gold' if use_elf: with _AddMocksToPath(): metadata = archive.CreateMetadata(_TEST_MAP_PATH, elf_path, apk_path, _TEST_TOOL_PREFIX, output_directory, linker_name) section_sizes, raw_symbols = archive.CreateSectionSizesAndSymbols( map_path=_TEST_MAP_PATH, tool_prefix=_TEST_TOOL_PREFIX, elf_path=elf_path, output_directory=output_directory, apk_path=apk_path, apk_so_path=apk_so_path, metadata=metadata, pak_files=pak_files, pak_info_file=pak_info_file, linker_name=linker_name, knobs=knobs) IntegrationTest.cached_size_info[ cache_key] = archive.CreateSizeInfo(section_sizes, raw_symbols, metadata=metadata) return copy.deepcopy(IntegrationTest.cached_size_info[cache_key])