208
|
1 import unittest
|
237
|
2 import glob
|
208
|
3 import zcc
|
250
|
4 import outstream
|
|
5 import ppci
|
287
|
6 import io
|
|
7 import os
|
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))
|
|
19 args = zcc.parser.parse_args(arg_list)
|
286
|
20 self.assertEqual(0, zcc.main(args))
|
208
|
21
|
288
|
22 @unittest.skip('Not working yet')
|
|
23 def testBurn(self):
|
|
24 self.do(['burn.c3'], ['stm32f4xx.c3'])
|
237
|
25
|
288
|
26 @unittest.skip('Not working yet')
|
287
|
27 def testBurn2(self):
|
288
|
28 self.do(['burn2.c3'], ['stm32f4xx.c3'])
|
287
|
29
|
|
30 def testComments(self):
|
|
31 self.do(['comments.c3'])
|
|
32
|
|
33 def testCast(self):
|
|
34 self.do(['cast.c3'])
|
|
35
|
250
|
36 def testSectionAddress(self):
|
287
|
37 src = """module tst;
|
|
38 function void t2() {var int t3; t3 = 2;}
|
|
39 """
|
|
40 f = io.StringIO(src)
|
250
|
41 diag = ppci.DiagnosticsManager()
|
|
42 outs = outstream.TextOutputStream()
|
288
|
43 self.assertTrue(zcc.zcc([f], [], outs, diag))
|
250
|
44 code = outs.getSection('code')
|
|
45 self.assertEqual(0x08000000, code.address)
|
|
46 data = outs.getSection('data')
|
|
47 self.assertEqual(0x20000000, data.address)
|
|
48
|
|
49
|
208
|
50 if __name__ == '__main__':
|
|
51 unittest.main()
|
|
52
|