forked from cppcheck-opensource/simplecpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.py
More file actions
122 lines (104 loc) · 3.45 KB
/
run-tests.py
File metadata and controls
122 lines (104 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import glob
import os
import subprocess
def cleanup(out):
ret = ''
for s in out.split('\n'):
if len(s) > 1 and s[0] == '#':
continue
s = "".join(s.split())
ret = ret + s
return ret
commands = []
for f in sorted(glob.glob(os.path.expanduser('testsuite/clang-preprocessor-tests/*.c*'))):
for line in open(f, 'rt'):
if line.startswith('// RUN: %clang_cc1 '):
cmd = ''
for arg in line[19:].split():
if arg == '-E' or (len(arg) >= 3 and arg[:2] == '-D'):
cmd = cmd + ' ' + arg
if len(cmd) > 1:
newcmd = cmd[1:] + ' ' + f
if not newcmd in commands:
commands.append(cmd[1:] + ' ' + f)
for f in sorted(glob.glob(os.path.expanduser('testsuite/gcc-preprocessor-tests/*.c*'))):
commands.append('-E ' + f)
# skipping tests..
skip = ['assembler-with-cpp.c',
'builtin_line.c',
'comment_save.c', # _Pragma
'has_attribute.c',
'header_lookup1.c', # missing include <stddef.h>
'line-directive-output.c',
'microsoft-ext.c',
'_Pragma-location.c',
'_Pragma-dependency.c',
'_Pragma-dependency2.c',
'_Pragma-physloc.c',
'pragma-pushpop-macro.c', # pragma push/pop
'x86_target_features.c',
'warn-disabled-macro-expansion.c',
'c99-6_10_3_3_p4.c',
'macro_paste_hashhash.c'
]
todo = [
# todo, low priority: wrong number of macro arguments, pragma, etc
'macro_backslash.c',
'macro_fn_comma_swallow.c',
'macro_fn_comma_swallow2.c',
'macro_fn_lparen_scan.c',
'macro_expand.c',
'macro_fn_disable_expand.c',
'macro_paste_commaext.c',
'macro_paste_hard.c',
'macro_rescan_varargs.c',
# todo, high priority
'c99-6_10_3_4_p5.c',
'c99-6_10_3_4_p6.c',
'cxx_compl.cpp', # if A compl B
'cxx_oper_keyword_ms_compat.cpp',
'expr_usual_conversions.c', # condition is true: 4U - 30 >= 0
'stdint.c',
'stringize_misc.c',
# GCC..
'diagnostic-pragma-1.c',
'pr45457.c',
'pr57580.c',
]
numberOfSkipped = 0
numberOfFailed = 0
usedTodos = []
for cmd in commands:
if cmd[cmd.rfind('/')+1:] in skip:
numberOfSkipped = numberOfSkipped + 1
continue
clang_cmd = ['clang']
clang_cmd.extend(cmd.split(' '))
p = subprocess.Popen(clang_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
comm = p.communicate()
clang_output = cleanup(comm[0])
gcc_cmd = ['gcc']
gcc_cmd.extend(cmd.split(' '))
p = subprocess.Popen(gcc_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
comm = p.communicate()
gcc_output = cleanup(comm[0])
simplecpp_cmd = ['./simplecpp']
simplecpp_cmd.extend(cmd.split(' '))
p = subprocess.Popen(simplecpp_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
comm = p.communicate()
simplecpp_output = cleanup(comm[0])
if simplecpp_output != clang_output and simplecpp_output != gcc_output:
filename = cmd[cmd.rfind('/')+1:]
if filename in todo:
print('TODO ' + cmd)
usedTodos.append(filename)
else:
print('FAILED ' + cmd)
numberOfFailed = numberOfFailed + 1
for filename in todo:
if not filename in usedTodos:
print('FIXED ' + filename)
print('Number of tests: ' + str(len(commands)))
print('Number of skipped: ' + str(numberOfSkipped))
print('Number of todos: ' + str(len(usedTodos)))
print('Number of failed: ' + str(numberOfFailed))