186 ['build', 'count=', 'seed=']) |
186 ['build', 'count=', 'seed=']) |
187 for o, a in opts: |
187 for o, a in opts: |
188 if o in ('-c', '--count'): |
188 if o in ('-c', '--count'): |
189 count = int(a) |
189 count = int(a) |
190 elif o in ('-s', '--seed'): |
190 elif o in ('-s', '--seed'): |
191 seed = long(a, base=0) # accepts base 10 or 16 strings |
191 seed = int(a, base=0) # accepts base 10 or 16 strings |
192 elif o == '--build': |
192 elif o == '--build': |
193 buildprobtable(sys.stdout, |
193 buildprobtable(sys.stdout, |
194 'find .hg/store/data -type f && ' |
194 'find .hg/store/data -type f && ' |
195 'cat .hg/store/fncache 2>/dev/null') |
195 'cat .hg/store/fncache 2>/dev/null') |
196 sys.exit(0) |
196 sys.exit(0) |
197 |
197 |
198 if seed is None: |
198 if seed is None: |
199 try: |
199 try: |
200 seed = long(binascii.hexlify(os.urandom(16)), 16) |
200 seed = int(binascii.hexlify(os.urandom(16)), 16) |
201 except AttributeError: |
201 except AttributeError: |
202 seed = long(time.time() * 1000) |
202 seed = int(time.time() * 1000) |
203 |
203 |
204 rng = random.Random(seed) |
204 rng = random.Random(seed) |
205 if runtests(rng, seed, count): |
205 if runtests(rng, seed, count): |
206 sys.exit(1) |
206 sys.exit(1) |
207 |
207 |