bug hunting; modified itc test script so you can pass --clang to it

This commit is contained in:
Daniel Marjamäki 2020-01-20 10:43:42 +01:00
parent 9bc43fca1d
commit 8d6891ac81
1 changed files with 13 additions and 4 deletions

View File

@ -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.*'