Mercurial > lcfOS
comparison test/testzcc.py @ 311:ff665880a6b0
Added testcase for kernel and userspace
author | Windel Bouwman |
---|---|
date | Mon, 16 Dec 2013 12:49:24 +0100 |
parents | 6753763d3bec |
children | 2c9768114877 |
comparison
equal
deleted
inserted
replaced
310:e95e5572cd6d | 311:ff665880a6b0 |
---|---|
1 import unittest | 1 import unittest |
2 import os | |
3 import sys | |
4 | |
2 import zcc | 5 import zcc |
3 import outstream | 6 import outstream |
4 import ppci | 7 import ppci |
5 import io | 8 import io |
6 import os | |
7 import target | 9 import target |
8 | 10 |
9 | 11 |
10 class ZccTestCase(unittest.TestCase): | 12 class ZccTestCase(unittest.TestCase): |
11 """ Tests the compiler driver """ | 13 """ Tests the compiler driver """ |
14 def setUp(self): | |
15 os.chdir(os.path.dirname(os.path.abspath(__file__))) | |
12 | 16 |
13 def do(self, filenames, imps=[]): | 17 def do(self, filenames, imps=[]): |
14 basedir = os.path.join('..', 'examples', 'c3') | 18 basedir = os.path.join('..', 'examples', 'c3') |
15 arg_list = [os.path.join(basedir, fn) for fn in filenames] | 19 arg_list = [os.path.join(basedir, fn) for fn in filenames] |
16 for fn in imps: | 20 for fn in imps: |
18 arg_list.append(os.path.join(basedir, fn)) | 22 arg_list.append(os.path.join(basedir, fn)) |
19 arg_list.append('--target') | 23 arg_list.append('--target') |
20 arg_list.append('arm') | 24 arg_list.append('arm') |
21 args = zcc.parser.parse_args(arg_list) | 25 args = zcc.parser.parse_args(arg_list) |
22 self.assertEqual(0, zcc.main(args)) | 26 self.assertEqual(0, zcc.main(args)) |
27 | |
28 def testDumpIr(self): | |
29 basedir = os.path.join('..', 'examples', 'c3', 'comments.c3') | |
30 arg_list = [basedir] | |
31 arg_list.append('--target') | |
32 arg_list.append('arm') | |
33 arg_list.append('--dumpir') | |
34 args = zcc.parser.parse_args(arg_list) | |
35 self.assertEqual(0, zcc.main(args)) | |
36 | |
37 def testKernel(self): | |
38 # Build kernel using zcc: | |
39 kerneldir = os.path.normpath(os.path.join('..', 'kernel')) | |
40 sys.path.insert(0, kerneldir) | |
41 from make import make_kernel | |
42 os.chdir(kerneldir) | |
43 make_kernel() | |
44 sys.path.pop(-1) | |
45 | |
46 def testUser(self): | |
47 # Build userspace using zcc: | |
48 userdir = os.path.normpath(os.path.join('..', 'user')) | |
49 sys.path.insert(0, userdir) | |
50 from makeuser import make_user | |
51 os.chdir(userdir) | |
52 make_user() | |
53 sys.path.pop(-1) | |
23 | 54 |
24 def testBurn2(self): | 55 def testBurn2(self): |
25 self.do(['burn2.c3'], ['stm32f4xx.c3']) | 56 self.do(['burn2.c3'], ['stm32f4xx.c3']) |
26 | 57 |
27 def testComments(self): | 58 def testComments(self): |