MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / test_misra_c_builtin_style_checks

Function test_misra_c_builtin_style_checks

test/cli/premium_test.py:40–71  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

38
39
40def test_misra_c_builtin_style_checks(tmpdir):
41 test_file = os.path.join(tmpdir, 'test.cpp')
42 with open(test_file, 'wt') as f:
43 f.write('void foo() { int x; y = 0; }')
44
45 exe = __copy_cppcheck_premium(tmpdir)
46
47 exitcode, _, stderr = cppcheck(['--premium=autosar', '--xml', test_file], cppcheck_exe=exe)
48 assert exitcode == 0
49 assert 'id="unusedVariable"' in stderr
50 assert 'id="checkersReport"' in stderr
51
52 exitcode, _, stderr = cppcheck(['--premium=autosar', '--premium=safety-off', '--xml', test_file], cppcheck_exe=exe)
53 assert exitcode == 0
54 assert 'id="unusedVariable"' in stderr
55 assert 'id="checkersReport"' not in stderr
56
57 exitcode, _, stderr = cppcheck(['--xml-version=3', test_file], cppcheck_exe=exe)
58 assert exitcode == 0
59 assert '<safety/>' in stderr
60
61 exitcode, _, stderr = cppcheck(['--xml-version=3', '--premium=safety-off', test_file], cppcheck_exe=exe)
62 assert exitcode == 0
63 assert '<safety/>' not in stderr
64
65 exitcode, _, stderr = cppcheck(['--xml-version=3', '--inline-suppr', test_file], cppcheck_exe=exe)
66 assert exitcode == 0
67 assert '<inline-suppr/>' in stderr
68
69 exitcode, _, stderr = cppcheck(['--xml-version=3', '--suppress=foo', test_file], cppcheck_exe=exe)
70 assert exitcode == 0
71 assert '<suppression errorId="foo" inline="false" />' in stderr
72
73
74def test_build_dir_hash_cppcheck_product(tmpdir):

Callers

nothing calls this directly

Calls 4

cppcheckFunction · 0.90
__copy_cppcheck_premiumFunction · 0.85
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected