chiark / gitweb /
soak: Add a step counter to the `--sync' option.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 6 Sep 2024 20:55:32 +0000 (21:55 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 6 Sep 2024 20:55:32 +0000 (21:55 +0100)
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.

soak

diff --git a/soak b/soak
index 7953608d988f44f89b812cfdc02c0ae11af2a7cd..354df2215f601624c5ee3fca635a63956e52383f 100755 (executable)
--- 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)