File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Test if --bug-hunting works using cve tests
22
33import glob
4+ import logging
45import os
56import re
67import shutil
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+
1722def 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+
5665for 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
You can’t perform that action at this time.
0 commit comments