annotate test/testzcc.py @ 292:534b94b40aa8

Fixup reorganize
author Windel Bouwman
date Wed, 27 Nov 2013 08:06:42 +0100
parents bd2593de3ff8
children 158068af716c
rev   line source
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
1 import unittest
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
2 import zcc
250
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
3 import outstream
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
4 import ppci
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
5 import io
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
6 import os
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 289
diff changeset
7 import target
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
8
286
d9df72971cbf Changed package to module
Windel Bouwman
parents: 284
diff changeset
9
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
10 class ZccTestCase(unittest.TestCase):
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
11 """ Tests the compiler driver """
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
12
288
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
13 def do(self, filenames, imps=[]):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
14 basedir = 'c3examples'
288
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
15 arg_list = [os.path.join(basedir, fn) for fn in filenames]
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
16 for fn in imps:
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
17 arg_list.append('-i')
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
18 arg_list.append(os.path.join(basedir, fn))
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 289
diff changeset
19 arg_list.append('--target')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 289
diff changeset
20 arg_list.append('arm')
288
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
21 args = zcc.parser.parse_args(arg_list)
286
d9df72971cbf Changed package to module
Windel Bouwman
parents: 284
diff changeset
22 self.assertEqual(0, zcc.main(args))
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
23
288
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
24 @unittest.skip('Not working yet')
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
25 def testBurn(self):
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
26 self.do(['burn.c3'], ['stm32f4xx.c3'])
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents: 235
diff changeset
27
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
28 def testBurn2(self):
288
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
29 self.do(['burn2.c3'], ['stm32f4xx.c3'])
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
30
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
31 def testComments(self):
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
32 self.do(['comments.c3'])
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
33
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
34 def testCast(self):
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
35 self.do(['cast.c3'])
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
36
250
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
37 def testSectionAddress(self):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
38 src = """module tst;
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
39 function void t2() {var int t3; t3 = 2;}
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
40 """
1c7c1e619be8 File movage
Windel Bouwman
parents: 286
diff changeset
41 f = io.StringIO(src)
250
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
42 diag = ppci.DiagnosticsManager()
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
43 outs = outstream.TextOutputStream()
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 289
diff changeset
44 tg = target.armtarget
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 289
diff changeset
45 self.assertTrue(zcc.zcc([f], [], tg, outs, diag))
250
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
46 code = outs.getSection('code')
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
47 self.assertEqual(0x08000000, code.address)
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
48 data = outs.getSection('data')
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
49 self.assertEqual(0x20000000, data.address)
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
50
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
51
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
52 if __name__ == '__main__':
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
53 unittest.main()
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
54