208
|
1 import unittest
|
237
|
2 import glob
|
208
|
3 import zcc
|
250
|
4 import outstream
|
|
5 import ppci
|
208
|
6
|
|
7 class ZccTestCase(unittest.TestCase):
|
|
8 """ Tests the compiler driver """
|
|
9
|
237
|
10 def do(self, fn):
|
208
|
11 """ Compile blink.c3 """
|
235
|
12 #args = zcc.parser.parse_args(['-d', 'stm32f4/blink.c3'])
|
237
|
13 args = zcc.parser.parse_args([fn])
|
208
|
14 zcc.main(args)
|
|
15
|
237
|
16 def testExamples(self):
|
|
17 """ Test all examples in the c3/examples directory """
|
|
18 example_filenames = glob.glob('./stm32f4/*.c3')
|
|
19 for filename in example_filenames:
|
|
20 self.do(filename)
|
|
21
|
250
|
22 def testSectionAddress(self):
|
|
23 src = "package tst; function void t2() {var int t3; t3 = 2;}"
|
|
24 diag = ppci.DiagnosticsManager()
|
|
25 outs = outstream.TextOutputStream()
|
|
26 self.assertTrue(zcc.zcc(src, outs, diag))
|
|
27 code = outs.getSection('code')
|
|
28 self.assertEqual(0x08000000, code.address)
|
|
29 data = outs.getSection('data')
|
|
30 self.assertEqual(0x20000000, data.address)
|
|
31
|
|
32
|
208
|
33 if __name__ == '__main__':
|
|
34 unittest.main()
|
|
35
|