Ejemplo n.º 1
0
    def encode_section(self, elf):
        """
        Generate the contents of the notes section.
        """
        note = section.UnpreparedElfNote(elffile=elf,
                                         name='elfweaver.notes')
        note.note_name = "Memstats Details"
        note.note_type = 1
        encoded = self.encode()
        note._desc_data = ByteArray.ByteArray(encoded)

        return note
Ejemplo n.º 2
0
 def test_get_data(self):
     a = ByteArray("12345678qwerty")
     # Note: There should be more extensive testing of the return
     # value.
     a.get_data(0, 8, '<')
Ejemplo n.º 3
0
 def test_array_set_data(self):
     b = ByteArray()
     for bytes, fmt in [(1, "B"), (2, "H"), (4, "L"), (8, "Q")]:
         b.set_data(0, 10, bytes, '<')
         self.assertEqual(len(b), bytes)
         self.assertEqual(struct.unpack("<" + fmt, b)[0], 10)
Ejemplo n.º 4
0
 def test_copy(self):
     a = ByteArray("12345678qwerty")
     b = a.copy()
     self.assertEqual(a, b)
     b[0] = 7
     self.assertNotEqual(a, b)
Ejemplo n.º 5
0
 def test_init_data(self):
     ByteArray("foo")
Ejemplo n.º 6
0
 def test_init(self):
     ByteArray()
Ejemplo n.º 7
0
 def test_get_data(self):
     a = ByteArray("12345678qwerty")
     # Note: There should be more extensive testing of the return
     # value.
     a.get_data(0, 8, '<')
Ejemplo n.º 8
0
 def test_copy(self):
     a = ByteArray("12345678qwerty")
     b = a.copy()
     self.assertEqual(a, b)
     b[0] = 7
     self.assertNotEqual(a, b)
Ejemplo n.º 9
0
 def test_array_set_data(self):
     b = ByteArray()
     for bytes, fmt in [(1, "B"), (2, "H"), (4, "L"), (8, "Q")]:
         b.set_data(0, 10, bytes, '<')
         self.assertEqual(len(b), bytes)
         self.assertEqual(struct.unpack("<" + fmt, b)[0], 10)