208
|
1 import unittest
|
|
2 import zcc
|
250
|
3 import outstream
|
|
4 import ppci
|
287
|
5 import io
|
|
6 import os
|
292
|
7 import target
|
208
|
8
|
286
|
9
|
208
|
10 class ZccTestCase(unittest.TestCase):
|
|
11 """ Tests the compiler driver """
|
|
12
|
288
|
13 def do(self, filenames, imps=[]):
|
287
|
14 basedir = 'c3examples'
|
288
|
15 arg_list = [os.path.join(basedir, fn) for fn in filenames]
|
|
16 for fn in imps:
|
|
17 arg_list.append('-i')
|
|
18 arg_list.append(os.path.join(basedir, fn))
|
292
|
19 arg_list.append('--target')
|
|
20 arg_list.append('arm')
|
288
|
21 args = zcc.parser.parse_args(arg_list)
|
286
|
22 self.assertEqual(0, zcc.main(args))
|
208
|
23
|
288
|
24 @unittest.skip('Not working yet')
|
|
25 def testBurn(self):
|
|
26 self.do(['burn.c3'], ['stm32f4xx.c3'])
|
237
|
27
|
287
|
28 def testBurn2(self):
|
288
|
29 self.do(['burn2.c3'], ['stm32f4xx.c3'])
|
287
|
30
|
|
31 def testComments(self):
|
|
32 self.do(['comments.c3'])
|
|
33
|
|
34 def testCast(self):
|
|
35 self.do(['cast.c3'])
|
|
36
|
250
|
37 def testSectionAddress(self):
|
287
|
38 src = """module tst;
|
|
39 function void t2() {var int t3; t3 = 2;}
|
|
40 """
|
|
41 f = io.StringIO(src)
|
250
|
42 diag = ppci.DiagnosticsManager()
|
|
43 outs = outstream.TextOutputStream()
|
292
|
44 tg = target.armtarget
|
|
45 self.assertTrue(zcc.zcc([f], [], tg, outs, diag))
|
250
|
46 code = outs.getSection('code')
|
|
47 self.assertEqual(0x08000000, code.address)
|
|
48 data = outs.getSection('data')
|
|
49 self.assertEqual(0x20000000, data.address)
|
|
50
|
|
51
|
208
|
52 if __name__ == '__main__':
|
|
53 unittest.main()
|
|
54
|