diff 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
line wrap: on
line diff
--- a/test/testzcc.py	Fri Dec 13 14:10:10 2013 +0100
+++ b/test/testzcc.py	Mon Dec 16 12:49:24 2013 +0100
@@ -1,14 +1,18 @@
 import unittest
+import os
+import sys
+
 import zcc
 import outstream
 import ppci
 import io
-import os
 import target
 
 
 class ZccTestCase(unittest.TestCase):
     """ Tests the compiler driver """
+    def setUp(self):
+        os.chdir(os.path.dirname(os.path.abspath(__file__)))
 
     def do(self, filenames, imps=[]):
         basedir = os.path.join('..', 'examples', 'c3')
@@ -21,6 +25,33 @@
         args = zcc.parser.parse_args(arg_list)
         self.assertEqual(0, zcc.main(args))
 
+    def testDumpIr(self):
+        basedir = os.path.join('..', 'examples', 'c3', 'comments.c3')
+        arg_list = [basedir]
+        arg_list.append('--target')
+        arg_list.append('arm')
+        arg_list.append('--dumpir')
+        args = zcc.parser.parse_args(arg_list)
+        self.assertEqual(0, zcc.main(args))
+
+    def testKernel(self):
+        # Build kernel using zcc:
+        kerneldir = os.path.normpath(os.path.join('..', 'kernel'))
+        sys.path.insert(0, kerneldir) 
+        from make import make_kernel
+        os.chdir(kerneldir)
+        make_kernel()
+        sys.path.pop(-1)
+        
+    def testUser(self):
+        # Build userspace using zcc:
+        userdir = os.path.normpath(os.path.join('..', 'user'))
+        sys.path.insert(0, userdir) 
+        from makeuser import make_user
+        os.chdir(userdir)
+        make_user()
+        sys.path.pop(-1)
+
     def testBurn2(self):
         self.do(['burn2.c3'], ['stm32f4xx.c3'])