Exemple #1
0
 def test_get_data(self):
     data = ByteArray("pants")
     sect = UnpreparedElfSection("test", data=data)
     self.assertEquals(sect.get_data(), data)
     sect = UnpreparedElfSection("test", section_type=SHT_NOBITS)
     sect.set_size(10)
     self.assertEquals(sect.get_data(), ByteArray("\0" * 10))
Exemple #2
0
 def test_get_data(self):
     data = ByteArray("pants")
     sect = UnpreparedElfSection("test", data=data)
     self.assertEquals(sect.get_data(), data)
     sect = UnpreparedElfSection("test", section_type=SHT_NOBITS)
     sect.set_size(10)
     self.assertEquals(sect.get_data(), ByteArray('\0' * 10))
Exemple #3
0
    def test_get_size(self):
        sect = UnpreparedElfSection("test")
        self.assertEqual(sect.get_size(), 0)

        sect = UnpreparedElfSection("test", data=ByteArray("pants"))
        self.assertEqual(sect.get_size(), 5)

        sect = UnpreparedElfSection("test", SHT_NOBITS)
        sect.set_size(40)
        self.assertEqual(sect.get_size(), 40)
Exemple #4
0
    def test_get_size(self):
        sect = UnpreparedElfSection("test")
        self.assertEqual(sect.get_size(), 0)

        sect = UnpreparedElfSection("test", data=ByteArray("pants"))
        self.assertEqual(sect.get_size(), 5)

        sect = UnpreparedElfSection("test", SHT_NOBITS)
        sect.set_size(40)
        self.assertEqual(sect.get_size(), 40)
Exemple #5
0
    def test_set_size(self):
        sect = UnpreparedElfSection("test")
        sect.set_size(37)
        self.assertEqual(sect.get_size(), 37)

        sect = UnpreparedElfSection("test", SHT_NOBITS)
        sect.set_size(37)
        self.assertEqual(sect.get_size(), 37)

        sect = UnpreparedElfSection("test", data=ByteArray("pants"))
        sect.set_size(3)
        self.assertEqual(sect.get_size(), 3)

        sect = UnpreparedElfSection("test", data=ByteArray("pants"))
        sect.set_size(10)
        self.assertEqual(sect.get_size(), 10)

        sect = UnpreparedElfSection("test", data=ByteArray("pants"))
        sect = sect.prepare(0, 0, 0, 32, "<")
        sect.set_size(4)
        self.assertEqual(sect.get_size(), 4)

        sect = UnpreparedElfSection("test", data=ByteArray("pants"))
        sect = sect.prepare(0, 0, 0, 32, "<")
        self.assertRaises(InvalidArgument, sect.set_size, 14)

        sect = UnpreparedElfSection("test", SHT_NOBITS)
        sect.set_size(37)
        sect = sect.prepare(0, 0, 0, 32, "<")
        self.assertRaises(InvalidArgument, sect.set_size, 69)

        sect = UnpreparedElfSection("test", SHT_NOBITS)
        sect.set_size(37)
        sect = sect.prepare(0, 0, 0, 32, "<")
        sect.set_size(12)
        self.assertEqual(sect.get_size(), 12)
Exemple #6
0
    def test_set_size(self):
        sect = UnpreparedElfSection("test")
        sect.set_size(37)
        self.assertEqual(sect.get_size(), 37)

        sect = UnpreparedElfSection("test", SHT_NOBITS)
        sect.set_size(37)
        self.assertEqual(sect.get_size(), 37)

        sect = UnpreparedElfSection("test", data=ByteArray("pants"))
        sect.set_size(3)
        self.assertEqual(sect.get_size(), 3)

        sect = UnpreparedElfSection("test", data=ByteArray("pants"))
        sect.set_size(10)
        self.assertEqual(sect.get_size(), 10)

        sect = UnpreparedElfSection("test", data=ByteArray("pants"))
        sect = sect.prepare(0, 0, 0, 32, '<')
        sect.set_size(4)
        self.assertEqual(sect.get_size(), 4)

        sect = UnpreparedElfSection("test", data=ByteArray("pants"))
        sect = sect.prepare(0, 0, 0, 32, '<')
        self.assertRaises(InvalidArgument, sect.set_size, 14)

        sect = UnpreparedElfSection("test", SHT_NOBITS)
        sect.set_size(37)
        sect = sect.prepare(0, 0, 0, 32, '<')
        self.assertRaises(InvalidArgument, sect.set_size, 69)

        sect = UnpreparedElfSection("test", SHT_NOBITS)
        sect.set_size(37)
        sect = sect.prepare(0, 0, 0, 32, '<')
        sect.set_size(12)
        self.assertEqual(sect.get_size(), 12)