def createImage(self, record_type, s5record, start_address=None): image = Image() image.insert_section(range(10), 0x1000) image.join_sections() return dumps("srec", image, record_type=record_type, s5record=s5record, start_address=start_address)
def testEnsureSectionHasCopySemantics(self): data = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f ] self.b0.insert_section(data, 0x1000) data.extend([0x10, 0x20, 0x30, 0x40]) result = dumps('srec', self.b0) self.assertEqual(result, self.SREC)
def test_dump_shf1(): SREC1 = b"""S113B000576F77212044696420796F7520726561D8 S113B0106C6C7920676F207468726F756768206143 S113B0206C20746861742074726F75626C6520742E S10FB0306F207265616420746869733FCE S9030000FC""" sr = loads("srec", SREC1) img = Image([sr[0]]) shf = dumps("shf", img) assert shf == """<?xml version="1.0" encoding="UTF-8"?>
def testLoadsWorks(self): image = Image() image.insert_section( "Wow! Did you really go through al that trouble to read this?", 0xb000) image.join_sections() self.assertEqual( dumps("srec", image, record_type=1, s5record=False, start_address=0x0000), SREC1)
def testDumpsWorks(self): data = loads("srec", S19) self.assertEqual(dumps("mostec", data), MOSTEC)
def testLoadsWorks(self): data = loads("mostec", MOSTEC) #data.hexdump() #print(dumps("srec", data)) self.assertEqual(dumps("srec", data, s5record=True), S19)
def testEmptySectionProducesEmptiness(self): self.b0.insert_section([], 0x1000) result = dumps('srec', self.b0) self.assertEqual(result, b'')
def testLoadsWorks(self): data = loads("emon52", EMON52) self.assertEqual(dumps("srec", data, s5record=True), S19)
# print("{0:10} {1}".format(key, value.description)) SREC = b"""S123B000576F77212044696420796F75207265616C6C7920676F207468726F7567682061DF S120B0206C6C20746861742074726F75626C6520746F207265616420746869733F73 S5030002FA""" FPC = b"""$kL&@h%%,:,B.\?00EPuX0K3rO0JI)) $;UPR'%%,:<Hn&FCG:at<GVF(;G9wIw $7FD1p%%,:LHmy:>GTV%/KJ7@GE[kYz $B[6\;%%,:\KIn?GFWY/qKI1G5:;-_e $%%%%%""" fromSrec = loads('srec', SREC) dataFromSRec = dumps('fpc', fromSrec) # Fixme: Does _NOT_ return 'bytes'! fromFPC = loads('fpc', FPC) dataFromFPC = dumps('srec', fromFPC, row_length = 32, s5record = True) class TestRoundTrip(unittest.TestCase): def testFromSrec(self): self.assertEqual(dataFromSRec, FPC) #pass def testFromFPC(self): self.assertEqual(dataFromFPC, SREC)
def runSectionTestPass(self, data): self.b0.addSegment(data, 0x1000) result = dumps('srec', self.b0.image) self.assertEqual(result, self.SREC)
def testDumpsWorks(self): data = loads("srec", S19) self.assertEqual(dumps("tek", data), TEK)
def testRoundtripFromFileLike(self): #pass dataIn = load("ihex", io.BytesIO(TEST2)) dataOut = dumps("ihex", dataIn) self.assertEqual(dataOut, TEST2)
def testRoundtripFromString(self): dataIn = loads("ihex", TEST2) dataOut = dumps("ihex", dataIn) self.assertEqual(dataOut, TEST2)
def test32Bit(self): dataIn = loads("srec", S19_32) dataOut = dumps("ihex", dataIn) self.assertEqual(dataOut, IHEX_32)
def testDumpsWorks(self): data = loads("srec", S19) self.assertEqual(dumps("emon52", data), EMON52)
def _runTest(self, format): data = loads("ash", format) self.assertTrue(dumps("srec", data, s5record=True) == SREC)
#for key, value in sorted(registry.registry().items()): # print("{0:10} {1}".format(key, value.description)) SREC = """S123B000576F77212044696420796F75207265616C6C7920676F207468726F7567682061DF S120B0206C6C20746861742074726F75626C6520746F207265616420746869733F73 S5030002FA""" FPC = """$kL&@h%%,:,B.\?00EPuX0K3rO0JI)) $;UPR'%%,:<Hn&FCG:at<GVF(;G9wIw $7FD1p%%,:LHmy:>GTV%/KJ7@GE[kYz $B[6\;%%,:\KIn?GFWY/qKI1G5:;-_e $%%%%%""" fromSrec = loads('srec', SREC) dataFromSRec = dumps('fpc', fromSrec) fromFPC = loads('fpc', FPC) dataFromFPC = dumps('srec', fromFPC, rowLength=32, s5record=True) class TestRoundTrip(unittest.TestCase): def testFromSrec(self): self.assertEqual(dataFromSRec, FPC) def testFromFPC(self): self.assertEqual(dataFromFPC, SREC) class TestProbe(unittest.TestCase): def testProbeSrec(self):
def testLoadsWorks(self): builder = Builder() builder.addSegment("Wow! Did you really go through al that trouble to read this?", 0xb000) builder.joinSections() self.assertEqual(dumps("srec", builder.image, recordType = 1, s5record = False, startAddress = 0x0000), SREC1)
def testEmptySectionProducesEmptiness(self): self.b0.addSegment([], 0x1000) result = dumps('srec', self.b0.image) self.assertEqual(result, '')
def createImage(self, recordType, s5record, startAddress = None): builder = Builder() builder.addSegment(range(10), 0x1000) builder.joinSections() return dumps("srec", builder.image, recordType = recordType, s5record = s5record, startAddress = startAddress)
1C FD 86 16 30 8D 24 07 F3 8C 7C 5A 94 48 FD E2 q""" SREC = b"""S123DEAD99F2B9CB79D3EEF88FC6A940ABCD71A6F0525E0C139D0A2C261F622553F03DED78 S123DECDE2F6B85BCAA653596CFD9917CA0BBEBB5D1CC770B9D29CDFF1FF0545EF4232D19F S123DEED39EA2D0391805CFD7DF5154800D3035EEFCACEA89C6B888E6A8DD359CF052A08DC S123DF0DEF570B80D8677E555D939D5D66A0BB556B8AFD07F585955F1268B8E26DE2EA5DFC S123DF2D3AF6DD125D5B67BAEE051854A5D3A9105DA718522CADB13F166921834C0BE08631 S123DF4D01BE985F19FF190804315CAA0506BA62ADD2B5D980661896D039191C45FAA24659 S123DF6DB83AA5D139BFD93EF036E8F53CA258E9750DC2F573DB8B4314A45F599E01A0569D S123DF8D3B4528750401B3F5379BEA733D425CB24F1FA7C3FA32060ED76668756708CCA3DA S123DFAD4DF41852F5CB472D6631A0A374FD56C31CFD8616308D2407F38C7C5A9448FDE260 S5030009F3""" fromSrec = loads('srec', SREC) dataFromSRec = dumps('titxt', fromSrec) fromTiTxt = loads('titxt', TITEXT) dataFromTiTxt = dumps('srec', fromTiTxt, row_length=32, s5record=True) class TestRoundTrip(unittest.TestCase): def testFromSrec(self): self.assertEqual(dataFromSRec, TITEXT) def testFromTiTxt(self): self.assertEqual(dataFromTiTxt, SREC) if __name__ == '__main__': unittest.main()
def runSectionTestPass(self, data): self.b0.insert_section(data, 0x1000) result = dumps('srec', self.b0) self.assertEqual(result, self.SREC)