annotate python/testzcc.py @ 262:ed14e077124c

Added conditional branch instructions
author Windel Bouwman
date Fri, 09 Aug 2013 11:30:11 +0200
parents f5fba5b554d7
children 56d37ed4b4d2
rev   line source
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
1 import unittest
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents: 235
diff changeset
2 import glob
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
3 import zcc
250
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
4 import outstream
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
5 import ppci
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
6
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
7 class ZccTestCase(unittest.TestCase):
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
8 """ Tests the compiler driver """
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
9
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents: 235
diff changeset
10 def do(self, fn):
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
11 """ Compile blink.c3 """
235
ff40407c0240 Fix ALabel to Label
Windel Bouwman
parents: 208
diff changeset
12 #args = zcc.parser.parse_args(['-d', 'stm32f4/blink.c3'])
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents: 235
diff changeset
13 args = zcc.parser.parse_args([fn])
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
14 zcc.main(args)
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
15
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents: 235
diff changeset
16 def testExamples(self):
81752b0f85a5 Added burn led test program
Windel Bouwman
parents: 235
diff changeset
17 """ Test all examples in the c3/examples directory """
81752b0f85a5 Added burn led test program
Windel Bouwman
parents: 235
diff changeset
18 example_filenames = glob.glob('./stm32f4/*.c3')
81752b0f85a5 Added burn led test program
Windel Bouwman
parents: 235
diff changeset
19 for filename in example_filenames:
81752b0f85a5 Added burn led test program
Windel Bouwman
parents: 235
diff changeset
20 self.do(filename)
81752b0f85a5 Added burn led test program
Windel Bouwman
parents: 235
diff changeset
21
250
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
22 def testSectionAddress(self):
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
23 src = "package tst; function void t2() {var int t3; t3 = 2;}"
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
24 diag = ppci.DiagnosticsManager()
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
25 outs = outstream.TextOutputStream()
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
26 self.assertTrue(zcc.zcc(src, outs, diag))
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
27 code = outs.getSection('code')
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
28 self.assertEqual(0x08000000, code.address)
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
29 data = outs.getSection('data')
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
30 self.assertEqual(0x20000000, data.address)
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
31
f5fba5b554d7 Removal of obsolete editor
Windel Bouwman
parents: 237
diff changeset
32
208
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
33 if __name__ == '__main__':
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
34 unittest.main()
4cb47d80fd1f Added zcc test
Windel Bouwman
parents:
diff changeset
35