Chromium Code Reviews| Index: pydir/bisection-test.py |
| diff --git a/pydir/bisection-test.py b/pydir/bisection-test.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..3e971d3c0d87edf17162ed6439e50301761adb1c |
| --- /dev/null |
| +++ b/pydir/bisection-test.py |
| @@ -0,0 +1,55 @@ |
| +#!/usr/bin/env python2 |
| +import sys |
| +import argparse |
| + |
| +def main(): |
| + desc = 'Crash simulator script, useful for testing the bisection tool.\ |
| + bisection-tool.py --cmd \'./pydir/bisection-test.py -c 2x3\' \ |
|
Jim Stichnoth
2016/07/24 14:30:44
I would change the escaped single-quotes into doub
|
| + --end 1000 --timeout 60' |
| + argparser = argparse.ArgumentParser(description=desc) |
| + argparser.add_argument('--include', '-i', default=[], dest='include', |
| + action='append', |
| + help='Include list, single values or ranges') |
| + argparser.add_argument('--exclude', '-e', default=[], dest='exclude', |
| + action='append', |
| + help='Exclude list, single values or ranges') |
| + argparser.add_argument('--crash', '-c', default=[], dest='crash', |
| + action='append', |
| + help='Crash list, single values or x-separated combinations like 2x4') |
| + |
| + args = argparser.parse_args() |
| + |
| + included = {-1} |
| + for string in args.include : |
|
Jim Stichnoth
2016/07/24 14:30:44
No space before the colon.
manasijm
2016/07/25 18:03:00
Done.
|
| + include_range = string.split(':') |
| + if len(include_range) == 1: |
| + included.add(int(include_range[0])) |
| + else : |
| + for num in range(int(include_range[0]), int(include_range[1])): |
| + included.add(num) |
| + |
| + for string in args.exclude : |
| + exclude_range = string.split(':') |
| + if len(exclude_range) == 1: |
| + try: |
| + included.remove(int(exclude_range[0])) |
| + except KeyError: |
| + pass # Exclude works without a matching include |
| + else : |
| + for num in range(int(exclude_range[0]), int(exclude_range[1])): |
| + included.remove(num) |
| + |
| + for string in args.crash: |
| + crash_combination = string.split('x') |
| + fail = True |
| + for crash in crash_combination: |
| + if not int(crash) in included: |
| + fail = False |
| + if fail: |
| + print 'Fail' |
| + exit(1) |
| + print 'Success' |
| + exit(0) |
| + |
| +if __name__ == '__main__': |
| + main() |
|
Jim Stichnoth
2016/07/24 14:30:44
Make sure this last line ends with a newline.
Als
manasijm
2016/07/25 18:03:00
Done.
|