class Options (object):
def __init__(me):
op = OP.OptionParser\
- (usage = "%prog [-y] [-c STEPS] [-f FILE] [-l LIMIT] "
- "[-n STEPS] PROG [ARGS ...]")
+ (usage = "%prog [-c STEPS] [-f FILE] [-l LIMIT] "
+ "[-n STEPS] [-y STEP] PROG [ARGS ...]")
op.disable_interspersed_args()
for short, long, kw in \
[("-c", "--ckpt-steps",
dest = "nsteps", default = None,
help = "number of steps to run before stopping")),
("-y", "--sync",
- dict(action = "store_true", dest = "sync",
- help = "check and print state after every step"))]:
+ dict(type = "int", metavar = "STEP",
+ dest = "sync", default = None,
+ help = "check and print state from STEP"))]:
op.add_option(short, long, **kw)
opts, args = op.parse_args()
me.limit = opts.limit
OPTS = Options()
ST = State(OPTS)
KID = SUB.Popen(OPTS.testprog, stdin = SUB.PIPE, stdout = SUB.PIPE)
-SYNC = OPTS.sync
+SYNC = False
def fail(msg):
SYS.stderr.write("%s: FAILED: %s\n" % (PROG, msg))
STEP = CSTEP = 0
ch = choices()
while OPTS.nsteps is None or STEP < OPTS.nsteps:
+
+ if OPTS.sync is not None and OPTS.sync == STEP:
+ SYNC = True
+ OPTS.sync = None
+ snapshot()
+ SYS.stdout.write("\n;; initial stack\n")
+ for i, lv in enumerate(ST.stack):
+ SYS.stdout.write(";; %3d = %s\n" % (i, lv.tree))
+ SYS.stdout.write(";; TOP = %s\n" % ST.cur.tree)
+ check_tree()
+
if SYNC: SYS.stdout.write("\n;; step %d\n" % CSTEP)
op = ch.choose(ST.rand)