def test_merge_region_no_fit(self, mock_config, mock_intelhex_offset): """ Test that merge_region_list call fails when part size overflows region size. :param mock_config: config object that is mocked. :param mock_intelhex_offset: mocked intel_hex_offset call. :return: """ max_addr = 87444 # create a dummy hex file with above max_addr mock_intelhex_offset.return_value = IntelHex({0:2, max_addr:0}) # create application and post-application regions and merge. region_application = Region("application", 10000, 86000, True, "random.hex") region_post_application = Region("postapplication", 100000, 90000, False, None) notify = MockNotifier() region_list = [region_application, region_post_application] # path to store the result in, should not get used as we expect exception. res = "./" mock_config.target.restrict_size = 90000 toolexception = False try: merge_region_list(region_list, res, notify, mock_config) except ToolException: toolexception = True except Exception as e: print("%s %s" % (e.message, e.args)) self.assertTrue(toolexception, "Expected ToolException not raised")
def merge_apps(self, userprog_path, firmware_path): if self.toolchain.config.has_regions: region_list = list(self.toolchain.config.regions) region_list = [ r._replace(filename=userprog_path) if r.active else r for r in region_list ] merge_region_list( region_list, firmware_path, self.notify, restrict_size=self.toolchain.config.target.restrict_size ) update_regions = [ r for r in region_list if r.name in UPDATE_WHITELIST] if update_regions: update_res = join( self.build_path, generate_update_filename( firmware_path, self.toolchain.target)) merge_region_list( update_regions, update_res, self.notify, restrict_size=self.toolchain.config.target.restrict_size) firmware_path = (firmware_path, update_res) else: firmware_path = (firmware_path, None)
region_list = [Region(*r) for r in export_info_data.get("region_list", [])] for index, region in enumerate(copy(region_list)): if region.name == "application": region_data = region._asdict() region_data["filename"] = hex_file region_list[index] = Region(**region_data) break else: raise Exception("No application region found") notify = TerminalNotifier() restrict_size = export_info_data.get("target", {}).get("restrict_size") merge_region_list(region_list, combined_hex_file, notify, restrict_size=restrict_size) update_regions = [r for r in region_list if r.name in UPDATE_WHITELIST] if update_regions: update_res = normpath( join(output_directory, generate_update_filename(output_name, None))) merge_region_list(update_regions, update_res, notify, restrict_size=restrict_size) sys.exit(0)