Skip to content

Commit 0009b4c

Browse files
committed
test/bug-hunting/cve.py: Add --slow argument to check slow packages
1 parent 27841d6 commit 0009b4c

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

test/bug-hunting/cve.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Test if --bug-hunting works using cve tests
22

33
import glob
4+
import logging
45
import os
56
import re
67
import shutil
@@ -14,26 +15,32 @@
1415
CPPCHECK_PATH = '../../cppcheck'
1516
TEST_SUITE = 'cve'
1617

18+
slow = '--slow' in sys.argv
19+
20+
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s', datefmt='%H:%M:%S')
21+
1722
def test(test_folder):
18-
print(test_folder)
23+
logging.info(test_folder)
1924

2025
cmd_file = os.path.join(test_folder, 'cmd.txt')
2126
expected_file = os.path.join(test_folder, 'expected.txt')
2227

23-
cmd = [CPPCHECK_PATH,
28+
cmd = ['nice',
29+
CPPCHECK_PATH,
2430
'-D__GNUC__',
2531
'--bug-hunting',
2632
'--inconclusive',
2733
'--platform=unix64',
2834
'--template={file}:{line}:{id}',
29-
'-rp=' + test_folder,
30-
test_folder]
35+
'-rp=' + test_folder]
3136

3237
if os.path.isfile(cmd_file):
3338
for line in open(cmd_file, 'rt'):
3439
if len(line) > 1:
3540
cmd.append(line.strip())
3641

42+
cmd.append(test_folder)
43+
3744
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
3845
comm = p.communicate()
3946
stdout = comm[0].decode(encoding='utf-8', errors='ignore')
@@ -49,10 +56,20 @@ def test(test_folder):
4956
print(stderr)
5057
sys.exit(1)
5158

52-
if len(sys.argv) > 1:
59+
if (slow is False) and len(sys.argv) > 1:
5360
test(sys.argv[1])
5461
sys.exit(0)
5562

63+
SLOW = []
64+
5665
for test_folder in sorted(glob.glob(TEST_SUITE + '/CVE*')):
66+
if slow is False:
67+
check = False
68+
for s in SLOW:
69+
if s in test_folder:
70+
check = True
71+
if check is True:
72+
logging.info('skipping %s', test_folder)
73+
continue
5774
test(test_folder)
5875

0 commit comments

Comments
 (0)