Mercurial > lcfOS
diff test/testsamples.py @ 355:c2ddc8a36f5e
Enabled optimization
author | Windel Bouwman |
---|---|
date | Fri, 14 Mar 2014 10:30:13 +0100 |
parents | |
children | 5ef1cb1bb54f |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/testsamples.py Fri Mar 14 10:30:13 2014 +0100 @@ -0,0 +1,56 @@ +import unittest +from testemulation import runQemu +from ppci.recipe import RecipeLoader +from ppci.tasks import TaskRunner + + +class TestSamples: + 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.print("A"); + } + } + """ + self.do(snippet, "AAAAAAAAAA") + + +class TestSamplesOnVexpress(unittest.TestCase, TestSamples): + def do(self, src, expected_output): + runner = TaskRunner() + recipe_loader = RecipeLoader(runner) + 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) +