Mercurial > lcfOS
comparison test/testsamples.py @ 355:c2ddc8a36f5e
Enabled optimization
author | Windel Bouwman |
---|---|
date | Fri, 14 Mar 2014 10:30:13 +0100 |
parents | |
children | 5ef1cb1bb54f |
comparison
equal
deleted
inserted
replaced
354:5477e499b039 | 355:c2ddc8a36f5e |
---|---|
1 import unittest | |
2 from testemulation import runQemu | |
3 from ppci.recipe import RecipeLoader | |
4 from ppci.tasks import TaskRunner | |
5 | |
6 | |
7 class TestSamples: | |
8 def testPrint(self): | |
9 snippet = """ | |
10 module testsample; | |
11 import io; | |
12 function void start() | |
13 { | |
14 io.print("Hello world"); | |
15 } | |
16 """ | |
17 self.do(snippet, "Hello world") | |
18 | |
19 def testForLoopPrint(self): | |
20 snippet = """ | |
21 module testsample; | |
22 import io; | |
23 function void start() | |
24 { | |
25 var int i; | |
26 for (i=0;i<10;i++) | |
27 { | |
28 io.print("A"); | |
29 } | |
30 } | |
31 """ | |
32 self.do(snippet, "AAAAAAAAAA") | |
33 | |
34 | |
35 class TestSamplesOnVexpress(unittest.TestCase, TestSamples): | |
36 def do(self, src, expected_output): | |
37 runner = TaskRunner() | |
38 recipe_loader = RecipeLoader(runner) | |
39 return | |
40 # TODO: improve recipe loading?? | |
41 recipe_loader.load_dict({ | |
42 'link': { | |
43 'inputs': [ | |
44 ], | |
45 'layout': { | |
46 'code': 0x60010000, | |
47 'data': 0x60020000 | |
48 }, | |
49 'output': 'tst.bin' | |
50 } | |
51 }) | |
52 runner.add_task(Compile()) | |
53 runner.run_tasks() | |
54 res = runQemu() | |
55 self.assertEqual(expected_output, res) | |
56 |