summaryrefslogtreecommitdiff
path: root/tests/test_general.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_general.py')
-rw-r--r--tests/test_general.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/tests/test_general.py b/tests/test_general.py
index 18e388c..3d43cbf 100644
--- a/tests/test_general.py
+++ b/tests/test_general.py
@@ -5,9 +5,7 @@ import unittest
sys.path.insert(0, '..')
from pycparser import parse_file, c_ast
-
-CPPPATH = 'cpp'
-
+from tests.test_util import cpp_supported, cpp_path, cpp_args
# Test successful parsing
#
@@ -25,26 +23,22 @@ class TestParsing(unittest.TestCase):
ast = parse_file(self._find_file('example_c_file.c'))
self.assertIsInstance(ast, c_ast.FileAST)
- @unittest.skipUnless(platform.system() == 'Linux',
- 'cpp only works on Linux')
+ @unittest.skipUnless(cpp_supported(), 'cpp only works on Unix')
def test_with_cpp(self):
memmgr_path = self._find_file('memmgr.c')
c_files_path = os.path.dirname(memmgr_path)
ast = parse_file(memmgr_path, use_cpp=True,
- cpp_path=CPPPATH,
- cpp_args='-I%s' % c_files_path)
+ cpp_path=cpp_path(), cpp_args=cpp_args('-I%s' % c_files_path))
self.assertIsInstance(ast, c_ast.FileAST)
fake_libc = os.path.join(c_files_path, '..', '..',
'utils', 'fake_libc_include')
ast2 = parse_file(self._find_file('year.c'), use_cpp=True,
- cpp_path=CPPPATH,
- cpp_args=[r'-I%s' % fake_libc])
+ cpp_path=cpp_path(), cpp_args=cpp_args('-I%s' % fake_libc))
self.assertIsInstance(ast2, c_ast.FileAST)
- @unittest.skipUnless(platform.system() == 'Linux',
- 'cpp only works on Linux')
+ @unittest.skipUnless(cpp_supported(), 'cpp only works on Unix')
def test_cpp_funkydir(self):
# This test contains Windows specific path escapes
if sys.platform != 'win32':
@@ -52,16 +46,23 @@ class TestParsing(unittest.TestCase):
c_files_path = os.path.join('tests', 'c_files')
ast = parse_file(self._find_file('simplemain.c'), use_cpp=True,
- cpp_path=CPPPATH, cpp_args='-I%s' % c_files_path)
+ cpp_path=cpp_path(), cpp_args=cpp_args('-I%s' % c_files_path))
self.assertIsInstance(ast, c_ast.FileAST)
- @unittest.skipUnless(platform.system() == 'Linux',
- 'cpp only works on Linux')
+ @unittest.skipUnless(cpp_supported(), 'cpp only works on Unix')
def test_no_real_content_after_cpp(self):
ast = parse_file(self._find_file('empty.h'), use_cpp=True,
- cpp_path=CPPPATH)
+ cpp_path=cpp_path(), cpp_args=cpp_args())
self.assertIsInstance(ast, c_ast.FileAST)
+ @unittest.skipUnless(cpp_supported(), 'cpp only works on Unix')
+ def test_c11_with_cpp(self):
+ c_files_path = os.path.join('tests', 'c_files')
+ fake_libc = os.path.join(c_files_path, '..', '..',
+ 'utils', 'fake_libc_include')
+ ast = parse_file(self._find_file('c11.c'), use_cpp=True,
+ cpp_path=cpp_path(), cpp_args=cpp_args('-I%s' % fake_libc))
+ self.assertIsInstance(ast, c_ast.FileAST)
if __name__ == '__main__':
unittest.main()