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): 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)
def test_get_section(self): ef = SectionedElfSegment(sections=[]) self.assertEquals(ef.get_sections(), []) data = ByteArray("pants") ef = DataElfSegment(data=data) self.assertRaises(InvalidArgument, ef.get_sections) seg = HeaderElfSegment() self.assertRaises(InvalidArgument, seg.get_sections)
def test_get_section(self): ef = SectionedElfSegment(sections=[]) self.assertEquals(ef.get_sections(), []) data = ByteArray("pants") ef = DataElfSegment(data=data) self.assertRaises(InvalidArgument, ef.get_sections) seg = HeaderElfSegment() self.assertRaises(InvalidArgument, seg.get_sections)