Ejemplo n.º 1
0
 def createImage(self, autoSort=False, autoJoin=False):
     builder = Builder(autoSort=autoSort, autoJoin=autoJoin)
     builder.addSegment(range(16), 0x90)
     builder.addSegment(range(16), 0x80)
     builder.addSegment(range(16), 0x70)
     builder.addSegment(range(16), 0x60)
     builder.addSegment(range(16), 0x50)
     return [s.address for s in builder.image]
Ejemplo n.º 2
0
 def setUp(self):
     if PYTHON_VERSION.major == 3:
         self.buf = io.TextIOWrapper(createStringBuffer())
     else:
         self.buf = createStringBuffer()
     #self.stdout = sys.stdout
     #sys.stdout = self.buf
     self.builder = Builder()
Ejemplo n.º 3
0
class TestHexfile(unittest.TestCase):
    def setUp(self):
        self.builder = Builder()

    def tearDown(self):
        del self.builder

    def testAddSectionAliasWorks(self):
        self.builder.addSection(range(64), 0x1000)
        # Ok, if no exception gets raised.

    def testRaisesInvalidChecksumError(self):
        self.assertRaises(hexfile.InvalidRecordChecksumError, loads, "srec",
                          b'S110000048656C6C6F2C20776F726C6421AA')

    def testRaisesError(self):
        #        self.assertRaises(hexfile.InvalidRecordChecksumError, loads, "srec", b'S110000048656C6C6F20776F726C642166')
        pass
Ejemplo n.º 4
0
 def testBasic(self):
     if PYTHON_VERSION.major == 3:
         buf = io.TextIOWrapper(createStringBuffer())
     else:
         buf = createStringBuffer()
     b0 = Builder()
     b0.addSegment("hello world!")
     b0.joinSections()
     b0.hexdump(buf)
     buf.seek(0, os.SEEK_SET)
     self.assertEqual(buf.read(), TEST1)
Ejemplo n.º 5
0
 def setUp(self):
     self.b0 = Builder()
     self.b1 = Builder()
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 def testImageRepresentation(self):
     builder = Builder()
     builder.addSegment([x % 256 for x in range(10000)])
     builder.joinSections()
     self.assertEqual(repr(builder.image), RESULT)
Ejemplo n.º 9
0
 def testFailIfSectionsAreNotIterateble2(self):
     builder = Builder([])
     print(builder.image)
Ejemplo n.º 10
0
 def testValidSections(self):
     builder = Builder([Section(0x1000, range(128))])
Ejemplo n.º 11
0
 def setUp(self):
     self.builder = Builder()