Skip to content

Commit 87acf31

Browse files
committed
Parallel property checking script: support all CBMC options
The script now accepts arbitrary additional options, which will be passed on to CBMC.
1 parent b08632a commit 87acf31

File tree

1 file changed

+10
-44
lines changed

1 file changed

+10
-44
lines changed

scripts/parallel-properties.py

+10-44
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
2222
scripts/parallel-properties.py -J 32 binary.gb --timeout 600
2323
24-
See --help for the list of available command-line options.
24+
See --help for the list of available command-line options. Any additional
25+
options to be passed to CBMC can be added to the command line.
2526
"""
2627

2728
import argparse
@@ -213,23 +214,13 @@ def output_result(result_entry, stats, status, verbose):
213214
return (result, result_str)
214215

215216

216-
def verify_one(goto_binary, unwind, unwindset, unwinding_assertions, depth,
217-
object_bits, prop, verbose, timeout, stats):
217+
def verify_one(goto_binary, cbmc_args, prop, verbose, timeout, stats):
218218
# run CBMC with extended statistics
219219
cbmc_cmd = ['cbmc', '--verbosity', '8', goto_binary,
220220
'--property', prop['name'], '--reachability-slice',
221221
# '--full-slice',
222222
'--slice-formula']
223-
if unwind:
224-
cbmc_cmd.extend(['--unwind', unwind])
225-
if unwindset:
226-
cbmc_cmd.extend(['--unwindset', unwindset])
227-
if unwinding_assertions:
228-
cbmc_cmd.extend(['--unwinding-assertions'])
229-
if depth:
230-
cbmc_cmd.extend(['--depth', str(depth)])
231-
if object_bits:
232-
cbmc_cmd.extend(['--object-bits', str(object_bits)])
223+
cbmc_cmd.extend(cbmc_args)
233224
(cbmc_ret, stderr_output, t, cnf_vars, cnf_clauses) = run_cmd_with_timeout(
234225
cbmc_cmd, timeout, verbose)
235226
result_entry = {'time': t, 'property': prop, 'variables': cnf_vars,
@@ -244,8 +235,7 @@ def verify_one(goto_binary, unwind, unwindset, unwinding_assertions, depth,
244235
return output_result(result_entry, stats, C_ERROR, verbose)
245236

246237

247-
def verify(goto_binary, unwind, unwindset, unwinding_assertions, depth,
248-
object_bits, verbose, timeout, n_jobs, stats):
238+
def verify(goto_binary, cbmc_args, verbose, timeout, n_jobs, stats):
249239
# find names of desired properties
250240
show_prop_cmd = ['goto-instrument', '--verbosity', '4', '--json-ui',
251241
'--show-properties', goto_binary]
@@ -259,10 +249,8 @@ def verify(goto_binary, unwind, unwindset, unwinding_assertions, depth,
259249
lock = multiprocessing.Lock()
260250

261251
with concurrent.futures.ThreadPoolExecutor(max_workers=n_jobs) as e:
262-
future_to_result = {e.submit(verify_one, goto_binary, unwind,
263-
unwindset, unwinding_assertions, depth,
264-
object_bits, prop, verbose, timeout,
265-
stats): prop
252+
future_to_result = {e.submit(verify_one, goto_binary, cbmc_args,
253+
prop, verbose, timeout, stats): prop
266254
for prop in json_props[1]['properties']}
267255
for future in concurrent.futures.as_completed(future_to_result):
268256
prop = future_to_result[future]
@@ -295,40 +283,18 @@ def main():
295283
'-v', '--verbose',
296284
action='store_true',
297285
help='enable verbose output')
298-
parser.add_argument(
299-
'--unwind',
300-
type=str,
301-
help='loop unwinding, forwarded to CBMC'),
302-
parser.add_argument(
303-
'--unwindset',
304-
type=str,
305-
help='loop unwinding, forwarded to CBMC'),
306-
parser.add_argument(
307-
'--unwinding-assertions',
308-
action='store_true',
309-
help='enable unwinding assertions, forwarded to CBMC'),
310-
parser.add_argument(
311-
'--depth',
312-
type=int,
313-
help='symex depth, forwarded to CBMC'),
314-
parser.add_argument(
315-
'--object-bits',
316-
type=int,
317-
help='object bits, forwarded to CBMC'),
318286
parser.add_argument(
319287
'goto_binary',
320288
help='instrumented goto binary to verify')
321-
args = parser.parse_args()
289+
args, cbmc_args = parser.parse_known_args()
322290

323291
logger = get_logger(args.verbose)
324292

325293
stats = {}
326294
results = {}
327295
results['results'] = verify(
328-
args.goto_binary, args.unwind, args.unwindset,
329-
args.unwinding_assertions,
330-
args.depth, args.object_bits, args.verbose,
331-
args.timeout, args.parallel, stats)
296+
args.goto_binary, cbmc_args, args.verbose, args.timeout,
297+
args.parallel, stats)
332298

333299
if args.statistics:
334300
results['statistics'] = stats

0 commit comments

Comments
 (0)