diff --git a/test/bug-hunting/itc.py b/test/bug-hunting/itc.py index 1afb898da..1be09f691 100644 --- a/test/bug-hunting/itc.py +++ b/test/bug-hunting/itc.py @@ -1,4 +1,4 @@ -# Test if --verify works using the itc testsuite +# Test if --bug-hunting works using the itc testsuite # The itc test suite can be downloaded here: # https://github.com/regehr/itc-benchmarks @@ -6,22 +6,25 @@ import glob import os import re +import shutil import sys import subprocess -if sys.argv[0] in ('test/verify/itc.py', './test/verify/itc.py'): +if sys.argv[0] in ('test/bug-hunting/itc.py', './test/bug-hunting/itc.py'): CPPCHECK_PATH = './cppcheck' else: CPPCHECK_PATH = '../../cppcheck' -if len(sys.argv) == 2: - TESTFILE = sys.argv[1] +if len(sys.argv) >= 2 and sys.argv[-1] != '--clang': + TESTFILE = sys.argv[-1] if not os.path.isfile(TESTFILE): print(f'ERROR: {TESTFILE} is not a file') sys.exit(1) else: TESTFILE = os.path.expanduser('~/itc/01.w_Defects/zero_division.c') +RUN_CLANG = ('--clang' in sys.argv) + def get_error_lines(filename): ret = [] f = open(filename, 'rt') @@ -36,6 +39,9 @@ def check(filename): '--bug-hunting', '--platform=unix64', filename] + if RUN_CLANG: + cmd += ['--clang', '--cppcheck-build-dir=itc-build-dir'] + os.mkdir('itc-build-dir') print(' '.join(cmd)) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -43,6 +49,9 @@ def check(filename): stdout = comm[0].decode(encoding='utf-8', errors='ignore') stderr = comm[1].decode(encoding='utf-8', errors='ignore') + if RUN_CLANG: + shutil.rmtree('itc-build-dir') + w = r'.*zero_division.c:([0-9]+):[0-9]+: error: There is division.*' if TESTFILE.find('uninit_') > 0: w = r'.*c:([0-9]+):[0-9]+: error: .*verificationUninit.*'