329 parser = argparse.ArgumentParser(
330 description='Minimize a generated Dart program ' +
331 ' while maintaining an identified crash or divergence. ' +
332 'A second Dart program can be specified for divergence testing.')
333 parser.add_argument(
334 '--dartfuzz',
335 required=True,
336 help="dartfuzz command string "
337 "e.g. dart dartfuzz.dart --no-ffi --no-fp --seed 243123600")
338 parser.add_argument(
339 '--dart',
340 help="Dart command string "
341 "e.g. ./sdk/out/ReleaseX64/dart",
342 required=True)
343 parser.add_argument(
344 '--dart-ref',
345 dest="dart_ref",
346 help="Dart command string for reference build " +
347 "(in case of divergence testing) " + "e.g. ./sdk/out/ReleaseX64/dart",
348 default=None)
349 parser.add_argument(
350 '--testfile',
351 required=True,
352 help="output filename for program generated by "
353 "dartfuzz command and passed to Dart command "
354 "e.g fuzz.dart")
355 parser.add_argument(
356 '--err',
357 help="string indicating an error for Dart cmd (no multiline matches)",
358 required=True)
359 parser.add_argument(
360 '--err-ref',
361 dest="err_ref",
362 help="string matching the diverging output for the Dart " +
363 "reference command (no multiline matches)",
364 default=None)
365 parser.add_argument(
366 '--smask', help="hexadecimal statements mask", default="0")
367 parser.add_argument(
368 '--emask', help="hexadecimal expressions mask", default="0")
369 parser.add_argument(
370 '--typ',
371 choices=["s", "e", "se"],
372 required=True,
373 help="minimize statements (s) or expressions (e) or both (se)")
374 parser.add_argument(
375 '--tries',
376 type=int,
377 default=1,
378 help='number of retries per run for Dart cmd')
379 parser.add_argument(
380 '--tries-ref',
381 type=int,
382 dest='tries_ref',
383 default=1,
384 help='number of retries per run for Dart reference cmd')
385 parser.add_argument(
386 '--threads',
387 type=int,
388 default=4,
389 help='number of threads to use for retries')
390 parser.add_argument(
391 '--timeout', type=int, default=60, help='timeout for Dart command')
392 parser.add_argument(
393 '--verbose', help="print intermediate results", action="store_true")
394 args = parser.parse_args()
395 timeout = args.timeout
396 do_stmt = "s" in args.typ
397 do_expr = "e" in args.typ
398 smask =
int(args.smask, 16)
399 if do_stmt:
400 print(
"Minimizing Statements")
401 smask =
minimize(args.dartfuzz, args.dart, args.dart_ref,
402 args.testfile, args.err, args.err_ref, smask,
403 int(args.emask, 16),
False, args.verbose, args.tries,
404 args.tries_ref, args.threads, timeout)
405 if do_expr:
406 print(
"Minimizing Expressions")
407 minimize(args.dartfuzz, args.dart, args.dart_ref,
408 args.testfile, args.err, args.err_ref, smask,
409 int(args.emask, 16),
True, args.verbose, args.tries,
410 args.tries_ref, args.threads, timeout)
411
412
def print(*args, **kwargs)