Lines Matching refs:self

53     def __init__(self, bs):  argument
54 self.length = len(bs)
64 … (self.magicStart0, self.magicStart1, self.flags, self.targetAddr, self.payloadSize, self.blockNo,
65 self.numBlocks, self.familyID) = struct.unpack(first_part, bs[:first_part_len])
67 self.data = bs[first_part_len:-last_part_len]
69 (self.magicEnd, ) = struct.unpack(last_part, bs[-last_part_len:])
71 def __len__(self): argument
72 return self.length
76 def __init__(self, f_name): argument
77 self.f_name = f_name
79 def get(self): argument
80 with open(self.f_name, 'rb') as f:
86 def __init__(self, f_name): argument
87 self.f_name = f_name
89 def append(self, data): argument
91 with open(self.f_name, 'ab') as f:
97 def generate_binary(self, size): argument
99 self.addCleanup(os.unlink, f.name)
108 def generate_uf2(self, chip_id, iter_addr_offset_tuples, chunk_size=None): argument
109 of_name = self.generate_binary(0)
118 self.addCleanup(p.terminate, force=True)
134 def process_blocks(self, uf2block, expected_chip_id): argument
146 binary_writer = BinaryWriter(self.generate_binary(0))
148 self.assertEqual(len(block), mkuf2.UF2Writer.UF2_BLOCK_SIZE)
149 self.assertEqual(block.magicStart0, mkuf2.UF2Writer.UF2_FIRST_MAGIC)
150 self.assertEqual(block.magicStart1, mkuf2.UF2Writer.UF2_SECOND_MAGIC)
151 self.assertEqual(block.flags & flags, flags)
153 self.assertEqual(len(block.data), mkuf2.UF2Writer.UF2_DATA_SIZE)
159 self.assertEqual(address, block.targetAddr)
160 self.assertEqual(length, block.payloadSize)
161 self.assertEqual(md5sum, md5_obj.digest())
163 self.assertEqual(block.familyID, expected_chip_id)
164 self.assertEqual(block.magicEnd, mkuf2.UF2Writer.UF2_FINAL_MAGIC)
166 self.assertEqual(current_addr, block.targetAddr)
172 self.assertEqual(block_list, list(range(block.numBlocks)))
174self.assertEqual(total_blocks, {block.numBlocks}) # numBlocks are the same in all the blocks
183 def common(self, t, chunk_size=None): argument
184 chip_id = self.generate_chipID()
185 parsed_t = self.process_blocks(self.generate_uf2(chip_id, t, chunk_size), chip_id)
187 self.assertEqual(len(t), len(parsed_t))
189 self.assertEqual(orig_addr, addr)
190 self.assertTrue(filecmp.cmp(orig_fname, fname))
192 def test_simple(self): argument
193 self.common([(0, self.generate_binary(1))])
195 def test_more_files(self): argument
196 self.common([(100, self.generate_binary(1)), (200, self.generate_binary(1))])
198 def test_larger_files(self): argument
199 self.common([(0x10, self.generate_binary(6)), (0x20, self.generate_binary(8))])
201 def test_boundaries(self): argument
202 self.common([(0x100, self.generate_binary(mkuf2.UF2Writer.UF2_DATA_SIZE)),
203 (0x200, self.generate_binary(mkuf2.UF2Writer.UF2_DATA_SIZE + 1)),
204 (0x300, self.generate_binary(mkuf2.UF2Writer.UF2_DATA_SIZE - 1))])
206 def test_files_with_more_blocks(self): argument
207 self.common([(0x100, self.generate_binary(3 * mkuf2.UF2Writer.UF2_DATA_SIZE)),
208 (0x200, self.generate_binary(2 * mkuf2.UF2Writer.UF2_DATA_SIZE + 1)),
209 (0x300, self.generate_binary(2 * mkuf2.UF2Writer.UF2_DATA_SIZE - 1))])
211 def test_very_large_files(self): argument
212 self.common([(0x100, self.generate_binary(20 * mkuf2.UF2Writer.UF2_DATA_SIZE + 5)),
213 (0x10000, self.generate_binary(50 * mkuf2.UF2Writer.UF2_DATA_SIZE + 100)),
214 (0x100000, self.generate_binary(100 * mkuf2.UF2Writer.UF2_DATA_SIZE))])
216 def test_chunk_size(self): argument
218 self.common([(0x100, self.generate_binary(chunk_size)),
219 (0x200, self.generate_binary(chunk_size + 1)),
220 (0x300, self.generate_binary(chunk_size - 1))],