From: Mark Wooding Date: Fri, 6 Sep 2024 20:55:32 +0000 (+0100) Subject: soak: Add a step counter to the `--sync' option. X-Git-Tag: 0.99.0~100 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/xyla/commitdiff_plain/6d502a2d0f0cbb5aaf4b8c9261d2a4698821f124 soak: Add a step counter to the `--sync' option. Now you don't have to wait through all of the initial nonsense before the bit that went wrong. For additional convenience, print the initial state before we start running in sync. --- diff --git a/soak b/soak index 7953608..354df22 100755 --- a/soak +++ b/soak @@ -97,8 +97,8 @@ class Collection (object): 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", @@ -118,8 +118,9 @@ class Options (object): 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 @@ -225,7 +226,7 @@ def choices(): 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)) @@ -280,6 +281,17 @@ dump_tree() 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)