示例#1
0
文件: notes.py 项目: openbox00/oktest
    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
示例#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, '<')
示例#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)
示例#4
0
 def test_copy(self):
     a = ByteArray("12345678qwerty")
     b = a.copy()
     self.assertEqual(a, b)
     b[0] = 7
     self.assertNotEqual(a, b)
示例#5
0
 def test_init_data(self):
     ByteArray("foo")
示例#6
0
 def test_init(self):
     ByteArray()
示例#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, '<')
示例#8
0
 def test_copy(self):
     a = ByteArray("12345678qwerty")
     b = a.copy()
     self.assertEqual(a, b)
     b[0] = 7
     self.assertNotEqual(a, b)
示例#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)