@@ -46,20 +46,20 @@ def format_float(a, b=1):
46
46
os .makedirs (work_path )
47
47
48
48
lib .set_jobs ('-j' + str (args .j ))
49
- result_file = os . path . join ( work_path , args . o )
50
- ( f , ext ) = os . path . splitext ( result_file )
51
- timing_file = f + '_timing' + ext
52
- normal_results = f + '_normal ' + ext
53
- exhaustive_results = f + '_exhaustive' + ext
54
-
55
- if os . path . exists ( result_file ):
56
- os . remove ( result_file )
57
- if os . path . exists ( timing_file ):
58
- os . remove ( timing_file )
59
- if os . path . exists ( normal_results ):
60
- os . remove ( normal_results )
61
- if os .path .exists (exhaustive_results ):
62
- os .remove (exhaustive_results )
49
+
50
+ def results_file ( name ):
51
+ f , ext = os . path . splitext ( args . o )
52
+ return os . path . join ( work_path , f + '_ ' + name + ext )
53
+
54
+ opts = { '0' : '--check-level=exhaustive --suppress=valueFlow*' ,
55
+ 'it2' : '--check-level=exhaustive --performance-valueflow-max-iterations=2 --suppress=valueFlow*' ,
56
+ 'it1' : '--check-level=exhaustive --performance-valueflow-max-iterations=1 --suppress=valueFlow*' ,
57
+ 'if8' : '--check-level=exhaustive --performance-valueflow-max-if-count=8 --suppress=valueFlow*' }
58
+
59
+ for o in opts . keys ( ):
60
+ f = results_file ( o )
61
+ if os .path .exists (f ):
62
+ os .remove (f )
63
63
64
64
cppcheck_path = args .cppcheck_path
65
65
@@ -117,95 +117,52 @@ def format_float(a, b=1):
117
117
print ("No files to process" )
118
118
continue
119
119
120
- results_to_diff = []
120
+ results_to_diff = list ()
121
+ timings = list ()
121
122
122
- normal_crashed = False
123
- exhaustive_crashed = False
124
-
125
- normal_timeout = False
126
- exhaustive_timeout = False
123
+ crashed = []
124
+ timeout = []
127
125
128
126
enable = 'style'
129
127
debug_warnings = False
130
128
131
129
libraries = lib .library_includes .get_libraries (source_path )
132
- c , errout , info , time_normal , cppcheck_options , timing_info = lib .scan_package (cppcheck_path , source_path , libraries , enable = enable , debug_warnings = debug_warnings , check_level = 'normal' )
133
- if c < 0 :
134
- if c == - 101 and 'error: could not find or open any of the paths given.' in errout :
135
- # No sourcefile found (for example only headers present)
136
- print ('Error: 101' )
137
- elif c == lib .RETURN_CODE_TIMEOUT :
138
- print ('Normal check level timed out!' )
139
- normal_timeout = True
140
- continue # we don't want to compare timeouts
141
- else :
142
- print ('Normal check level crashed!' )
143
- normal_crashed = True
144
- results_to_diff .append (errout )
145
-
146
- c , errout , info , time_exhaustive , cppcheck_options , timing_info = lib .scan_package (cppcheck_path , source_path , libraries , enable = enable , debug_warnings = debug_warnings , check_level = 'exhaustive' )
147
- if c < 0 :
148
- if c == - 101 and 'error: could not find or open any of the paths given.' in errout :
149
- # No sourcefile found (for example only headers present)
150
- print ('Error: 101' )
151
- elif c == lib .RETURN_CODE_TIMEOUT :
152
- print ('Exhaustive check level timed out!' )
153
- exhaustive_timeout = True
154
- continue # we don't want to compare timeouts
155
- else :
156
- print ('Exhaustive check level crashed!' )
157
- exhaustive_crashed = True
158
- results_to_diff .append (errout )
159
-
160
- if normal_crashed or exhaustive_crashed :
161
- who = None
162
- if normal_crashed and exhaustive_crashed :
163
- who = 'Both'
164
- elif normal_crashed :
165
- who = 'Normal'
166
- else :
167
- who = 'Exhaustive'
168
- crashes .append (package + ' ' + who )
169
-
170
- if normal_timeout or exhaustive_timeout :
171
- who = None
172
- if normal_timeout and exhaustive_timeout :
173
- who = 'Both'
174
- elif normal_timeout :
175
- who = 'Normal'
176
- else :
177
- who = 'Exhaustive'
178
- timeouts .append (package + ' ' + who )
179
-
180
- with open (result_file , 'a' ) as myfile :
181
- myfile .write (package + '\n ' )
182
- diff = lib .diff_results ('normal' , results_to_diff [0 ], 'exhaustive' , results_to_diff [1 ])
183
- if not normal_crashed and not exhaustive_crashed and diff != '' :
130
+
131
+ for id , extra_args in opts .items ():
132
+ print ('scan:' + id )
133
+ c , errout , info , time , cppcheck_options , timing_info = lib .scan_package (cppcheck_path , source_path , libraries , enable = enable , extra_args = extra_args )
134
+ if c < 0 :
135
+ if c == - 101 and 'error: could not find or open any of the paths given.' in errout :
136
+ # No sourcefile found (for example only headers present)
137
+ print ('Error: 101' )
138
+ elif c == lib .RETURN_CODE_TIMEOUT :
139
+ print (id + ' timed out!' )
140
+ timeout .append (id )
141
+ continue # we don't want to compare timeouts
142
+ else :
143
+ print (f'{ id } crashed! code={ c } ' )
144
+ crashed .append (id )
145
+ results_to_diff .append (errout )
146
+ timings .append (time )
147
+
148
+ if len (results_to_diff ) <= 1 :
149
+ continue
150
+
151
+ r0 = results_to_diff [0 ]
152
+ with open (results_file (id ), 'a' ) as myfile :
153
+ myfile .write (package + '\n ' )
154
+ if id in crashed :
155
+ myfile .write ('Crash\n ' )
156
+ elif id in timeout :
157
+ myfile .write ('Timeout\n ' )
158
+ else :
159
+ diff = lib .diff_results ('0' , r0 , id , errout )
160
+ if diff != '' :
161
+ myfile .write ('diff:\n ' + diff + '\n ' )
162
+ myfile .write ('time: %.1f %.1f\n ' % (timings [0 ], time ))
184
163
myfile .write ('libraries:' + ',' .join (libraries ) + '\n ' )
185
- myfile .write ('diff:\n ' + diff + '\n ' )
186
-
187
- if not normal_crashed and not exhaustive_crashed :
188
- with open (timing_file , 'a' ) as myfile :
189
- package_width = '140'
190
- timing_width = '>7'
191
- myfile .write ('{:{package_width}} {:{timing_width}} {:{timing_width}} {:{timing_width}}\n ' .format (
192
- package , format_float (time_normal ),
193
- format_float (time_exhaustive ), format_float (time_normal , time_exhaustive ),
194
- package_width = package_width , timing_width = timing_width ))
195
- with open (normal_results , 'a' ) as myfile :
196
- myfile .write (results_to_diff [0 ])
197
- with open (exhaustive_results , 'a' ) as myfile :
198
- myfile .write (results_to_diff [1 ])
199
164
200
165
packages_processed += 1
201
166
print (str (packages_processed ) + ' of ' + str (args .p ) + ' packages processed\n ' )
202
167
203
- with open (result_file , 'a' ) as myfile :
204
- myfile .write ('\n \n crashes\n ' )
205
- myfile .write ('\n ' .join (crashes ))
206
-
207
- with open (result_file , 'a' ) as myfile :
208
- myfile .write ('\n \n timeouts\n ' )
209
- myfile .write ('\n ' .join (timeouts ) + '\n ' )
210
-
211
168
print ('Result saved to: ' + result_file )
0 commit comments