Beispiel #1
0
    def test_copy(self):
        sect = BaseElfSection("test")
        self.assertRaises(NotImplementedError, sect.copy)

        sect = UnpreparedElfSection("test")
        new_sect = sect.copy()
        self.assertEquals(sect.name, new_sect.name)

        prep_sect = sect.prepare(0, 0, 0, 32, "<")
        new_sect = prep_sect.copy()
        self.assertEquals(prep_sect.name, new_sect.name)

        sect = UnpreparedElfSection("test", SHT_NOBITS)
        new_sect = sect.copy()
        self.assertEquals(sect.name, new_sect.name)

        prep_sect = sect.prepare(0, 0, 0, 32, "<")
        new_sect = prep_sect.copy()
        self.assertEquals(prep_sect.name, new_sect.name)

        sect = UnpreparedElfStringTable("string")
        strings = ["foo", "bar", "baz"]
        for string in strings:
            sect.add_string(string)
        new_sect = sect.copy()
        for i in range(len(strings)):
            self.assertEquals(sect.get_string_idx(i), new_sect.get_string_idx(i))
Beispiel #2
0
    def test_copy_into(self):
        elf_from = UnpreparedElfFile()
        elf_to = UnpreparedElfFile()

        sect = BaseElfSection(elf_from, "test")
        # FIXME
        #self.assertRaises(NotImplementedError, sect.copy_into, elf_to)

        sect = UnpreparedElfSection(elf_from, "test")
        new_sect = sect.copy_into(elf_to)
        self.assertEquals(sect.name, new_sect.name)
        
        prep_sect = sect.prepare(0, 0, 0)
        # FIXME
        #self.assertRaises(NotImplementedError, prep_sect.copy_into, elf_to)

        sect = UnpreparedElfSection(elf_from, "test", SHT_NOBITS)
        new_sect = sect.copy_into(elf_to)
        self.assertEquals(sect.name, new_sect.name)

        sect = UnpreparedElfStringTable(elf_from, "string")
        strings = ["foo", "bar", "baz"]
        for string in strings:
            sect.add_string(string)
        new_sect = sect.copy_into(elf_to)
        for i in range(len(strings)):
            self.assertEquals(sect.get_string_idx(i), new_sect.get_string_idx(i))
Beispiel #3
0
    def test_copy(self):
        sect = BaseElfSection("test")
        self.assertRaises(NotImplementedError, sect.copy)

        sect = UnpreparedElfSection("test")
        new_sect = sect.copy()
        self.assertEquals(sect.name, new_sect.name)

        prep_sect = sect.prepare(0, 0, 0, 32, '<')
        new_sect = prep_sect.copy()
        self.assertEquals(prep_sect.name, new_sect.name)

        sect = UnpreparedElfSection("test", SHT_NOBITS)
        new_sect = sect.copy()
        self.assertEquals(sect.name, new_sect.name)

        prep_sect = sect.prepare(0, 0, 0, 32, '<')
        new_sect = prep_sect.copy()
        self.assertEquals(prep_sect.name, new_sect.name)

        sect = UnpreparedElfStringTable("string")
        strings = ["foo", "bar", "baz"]
        for string in strings:
            sect.add_string(string)
        new_sect = sect.copy()
        for i in range(len(strings)):
            self.assertEquals(sect.get_string_idx(i),
                              new_sect.get_string_idx(i))