Mercurial > lcfOS
view test/testsamples.py @ 365:98ff43cfdd36
Nasty bug in adr instruction
author | Windel Bouwman |
---|---|
date | Wed, 19 Mar 2014 22:32:04 +0100 |
parents | c49459768aaa |
children | 39bf68bf1891 |
line wrap: on
line source
import unittest from testemulation import runQemu from ppci.recipe import RecipeLoader from ppci.tasks import TaskRunner class Samples: def testPrint(self): snippet = """ module testsample; import io; function void start() { io.print("Hello world"); } """ self.do(snippet, "Hello world") def testForLoopPrint(self): snippet = """ module testsample; import io; function void start() { var int i; for (i=0; i<10; i++) { io.print2("A = ", i); } } """ res = "".join("A = 0x{0:08X}\n".format(a) for a in range(10)) self.do(snippet, res) def testForLoopPrint(self): snippet = """ module testglobal; import io; var int G; function void do1() { G = G + 1; io.print2("G=", G); } function void do5() { G = G + 5; io.print2("G=", G); } function void start() { G = 0; do1(); do1(); do2(); do1(); do2(); } """ res = "".join("G=0x{0:08X}\n".format(a) for a in [1,2,7,8,13]) self.do(snippet, res) class TestSamplesOnVexpress(unittest.TestCase, Samples): def do(self, src, expected_output): runner = TaskRunner() recipe_loader = RecipeLoader(runner) # print(expected_output) return # TODO: improve recipe loading?? recipe_loader.load_dict({ 'link': { 'inputs': [ ], 'layout': { 'code': 0x60010000, 'data': 0x60020000 }, 'output': 'tst.bin' } }) runner.add_task(Compile()) runner.run_tasks() res = runQemu('tst.bin', machine='vexpress-a9') self.assertEqual(expected_output, res) if __name__ == '__main__': unittest.main()