comparison test/testasm.py @ 383:173e20a47fda

Added linker description loader
author Windel Bouwman
date Sun, 27 Apr 2014 17:40:39 +0200
parents 0c44e494ef58
children d056b552d3f4
comparison
equal deleted inserted replaced
382:0c44e494ef58 383:173e20a47fda
5 from ppci.assembler import AsmLexer 5 from ppci.assembler import AsmLexer
6 from ppci.objectfile import ObjectFile 6 from ppci.objectfile import ObjectFile
7 from ppci.outstream import BinaryOutputStream 7 from ppci.outstream import BinaryOutputStream
8 from ppci.target.basetarget import Label 8 from ppci.target.basetarget import Label
9 from ppci.buildfunctions import link 9 from ppci.buildfunctions import link
10 from ppci.layout import Layout
10 11
11 12
12 class AssemblerLexingCase(unittest.TestCase): 13 class AssemblerLexingCase(unittest.TestCase):
13 """ Tests the assemblers lexer """ 14 """ Tests the assemblers lexer """
14 15
58 class AsmTestCaseBase(unittest.TestCase): 59 class AsmTestCaseBase(unittest.TestCase):
59 """ Base testcase for assembly """ 60 """ Base testcase for assembly """
60 def feed(self, line): 61 def feed(self, line):
61 self.assembler.assemble(line, self.ostream) 62 self.assembler.assemble(line, self.ostream)
62 63
63 def check(self, hexstr, layout={}): 64 def check(self, hexstr, layout=Layout()):
64 self.assembler.flush() 65 self.assembler.flush()
65 self.obj = link([self.obj], layout) 66 self.obj = link([self.obj], layout)
66 data = bytes(self.obj.get_section('.text').data) 67 data = bytes(self.obj.get_section('code').data)
67 self.assertSequenceEqual(bytes.fromhex(hexstr), data) 68 self.assertSequenceEqual(bytes.fromhex(hexstr), data)
68 69
69 70
70 if __name__ == '__main__': 71 if __name__ == '__main__':
71 unittest.main() 72 unittest.main()