def test_replace_section(self): seg = SectionedElfSegment(sections=[UnpreparedElfSection("test")]) old_section = seg.get_sections()[0] new_section = UnpreparedElfSection("new") seg.replace_section(old_section, new_section) self.assertEqual(seg.get_sections(), [new_section]) new_seg = seg.copy() self.assertRaises(InvalidArgument, seg.replace_section, None, new_section)
def test_replace_section(self): elf_from = UnpreparedElfFile() elf_to = UnpreparedElfFile() seg = SectionedElfSegment(elf_from, sections=[UnpreparedElfSection(elf_from, "test")]) old_section = seg.get_sections()[0] new_section = UnpreparedElfSection(elf_to, "new") seg.replace_section(old_section, new_section) self.assertEqual(seg.get_sections(), [new_section]) new_seg = seg.copy_into(elf_to) self.assertRaises(InvalidArgument, seg.replace_section, None, new_section)