Mercurial > lcfOS
view test/testsamples.py @ 362:c05ab629976a
Added CPUID for arm
author | Windel Bouwman |
---|---|
date | Sat, 15 Mar 2014 10:56:34 +0100 |
parents | 5ef1cb1bb54f |
children | 396e5cefba13 |
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) 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() self.assertEqual(expected_output, res) if __name__ == '__main__': unittest.main()