Mercurial > hg > CbC > CbC_llvm
comparison utils/bisect-skip-count @ 121:803732b1fca8
LLVM 5.0
author | kono |
---|---|
date | Fri, 27 Oct 2017 17:07:41 +0900 |
parents | |
children | c2174574ed3a |
comparison
equal
deleted
inserted
replaced
120:1172e4bd9c6f | 121:803732b1fca8 |
---|---|
1 #!/usr/bin/env python | |
2 # This script is used to bisect skip and count arguments for --debug-counter. | |
3 # It is similar to bisect, except it understands how to increase skip and decrease count | |
4 import os | |
5 import sys | |
6 import argparse | |
7 # This is for timeout support. Use the recommended way of import. | |
8 # We do timeouts because when doing, execution testing, we have a habit | |
9 # of finding variants that infinite loop | |
10 if os.name == 'posix' and sys.version_info[0] < 3: | |
11 import subprocess32 as subprocess | |
12 else: | |
13 import subprocess | |
14 parser = argparse.ArgumentParser() | |
15 | |
16 parser.add_argument('--skipstart', type=int, default=0) | |
17 parser.add_argument('--skipend', type=int, default=(1 << 32)) | |
18 parser.add_argument('--countstart', type=int, default=0) | |
19 parser.add_argument('--countend', type=int, default=(1 << 32)) | |
20 parser.add_argument('--timeout', type=int, default=None) | |
21 # Use shell support if you need to use complex shell expressions in your command | |
22 parser.add_argument('--shell', type=bool, default=False) | |
23 parser.add_argument('command', nargs='+') | |
24 | |
25 args = parser.parse_args() | |
26 | |
27 start = args.skipstart | |
28 end = args.skipend | |
29 | |
30 print("Bisect of Skip starting!") | |
31 print("Start: %d" % start) | |
32 print("End: %d" % end) | |
33 | |
34 last = None | |
35 while start != end and start != end-1: | |
36 count = start + (end - start)/2 | |
37 print("Visiting Skip: %d with (Start, End) = (%d,%d)" % (count, start, end)) | |
38 cmd = [x % {'skip':count, 'count':-1} for x in args.command] | |
39 print cmd | |
40 try: | |
41 result = subprocess.call(cmd, shell=args.shell, timeout=args.timeout) | |
42 if result == 0: | |
43 print(" PASSES! Setting end to count") | |
44 end = count | |
45 else: | |
46 print(" FAILS! Setting start to count") | |
47 start = count | |
48 except: | |
49 print(" TIMEOUT, setting end to count") | |
50 end = count | |
51 firstcount = start | |
52 print("Last good skip: %d" % start) | |
53 start = args.countstart | |
54 end = args.countend | |
55 print("Bisect of Count starting!") | |
56 print("Start: %d" % start) | |
57 print("End: %d" % end) | |
58 while start != end and start != end-1: | |
59 count = start + (end - start)/2 | |
60 print("Visiting Count: %d with (Start, End) = (%d,%d)" % (count, start, end)) | |
61 cmd = [x % {'count':count, 'skip':firstcount } for x in args.command] | |
62 print cmd | |
63 try: | |
64 result = subprocess.call(cmd, shell=args.shell, timeout=args.timeout) | |
65 if result == 0: | |
66 print(" PASSES! Setting start to count") | |
67 start = count | |
68 else: | |
69 print(" FAILS! Setting end to count") | |
70 end = count | |
71 except: | |
72 print(" TIMEOUT, setting start to count") | |
73 start = count | |
74 | |
75 print("Last good count: %d" % start) |