[llvm-exegesis] [NFC] Fixing typo.
[llvm-complete.git] / utils / bisect
blobd1b12575e9c321582228eda3a9fe3fbefcc62587
1 #!/usr/bin/env python
3 import os
4 import sys
5 import argparse
6 import subprocess
8 parser = argparse.ArgumentParser()
10 parser.add_argument('--start', type=int, default=0)
11 parser.add_argument('--end', type=int, default=(1 << 32))
12 parser.add_argument('command', nargs='+')
14 args = parser.parse_args()
16 start = args.start
17 end = args.end
19 print("Bisect Starting!")
20 print("Start: %d" % start)
21 print("End: %d" % end)
23 last = None
24 while start != end and start != end-1:
25 count = start + (end - start)/2
26 print("Visiting Count: %d with (Start, End) = (%d,%d)" % (count, start, end))
27 cmd = [x % {'count':count} for x in args.command]
28 print cmd
29 result = subprocess.call(cmd)
30 if result == 0:
31 print(" PASSES! Setting start to count")
32 start = count
33 else:
34 print(" FAILS! Setting end to count")
35 end = count
37 print("Last good count: %d" % start)