forked from cppcheck-opensource/cppcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinline-suppress-polyspace_test.py
More file actions
63 lines (40 loc) · 2.22 KB
/
inline-suppress-polyspace_test.py
File metadata and controls
63 lines (40 loc) · 2.22 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
# python -m pytest inline-suppress-polyspace_test.py
import os
from testutils import assert_cppcheck
__script_dir = os.path.dirname(os.path.abspath(__file__))
def test_unmatched_polyspace_suppression(tmp_path):
test_file = tmp_path / 'test.c'
with open(test_file, 'wt') as f:
f.write('int f(void); /* polyspace MISRA2012:8.2 */\n')
args = ['--addon=misra', '--template=simple', '--enable=style,information', '--inline-suppr', 'test.c']
out_exp = ['Checking test.c ...']
err_exp = ['test.c:1:14: information: Unmatched suppression: misra-c2012-8.2 [unmatchedPolyspaceSuppression]']
assert_cppcheck(args, ec_exp=0, err_exp=err_exp, out_exp=out_exp, cwd=str(tmp_path))
def test_1(tmp_path):
test_file = tmp_path / 'test.c'
with open(test_file, 'wt') as f:
f.write('int f(); /* polyspace MISRA2012:8.2 */\n')
args = ['--addon=misra', '--template=simple', '--enable=style,information', '--inline-suppr', 'test.c']
out_exp = ['Checking test.c ...']
err_exp = []
assert_cppcheck(args, ec_exp=0, err_exp=err_exp, out_exp=out_exp, cwd=str(tmp_path))
def test_block(tmp_path):
test_file = tmp_path / 'test.c'
with open(test_file, 'wt') as f:
f.write('/* polyspace +1 MISRA2012:8.2 */\n'
'int f();\n' # <- suppression applies to this line
'int g();\n') # <- suppression does not apply to this line
args = ['--addon=misra', '--template=simple', '--enable=style,information', '--inline-suppr', 'test.c']
out_exp = ['Checking test.c ...']
err_exp = ['test.c:3:6: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-8.2]']
assert_cppcheck(args, ec_exp=0, err_exp=err_exp, out_exp=out_exp, cwd=str(tmp_path))
def test_begin_end(tmp_path):
test_file = tmp_path / 'test.c'
with open(test_file, 'wt') as f:
f.write('/* polyspace-begin MISRA2012:8.2 */\n'
'int f();\n'
'/* polyspace-end MISRA2012:8.2 */\n')
args = ['--addon=misra', '--template=simple', '--enable=style,information', '--inline-suppr', 'test.c']
out_exp = ['Checking test.c ...']
err_exp = []
assert_cppcheck(args, ec_exp=0, err_exp=err_exp, out_exp=out_exp, cwd=str(tmp_path))