chiark
/
gitweb
/
~mdw
/
xyla
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6790194
)
soak: Pull sync state out into a separate variable.
author
Mark Wooding
<mdw@distorted.org.uk>
Fri, 6 Sep 2024 20:53:59 +0000
(21:53 +0100)
committer
Mark Wooding
<mdw@distorted.org.uk>
Fri, 6 Sep 2024 20:53:59 +0000
(21:53 +0100)
soak
patch
|
blob
|
blame
|
history
diff --git
a/soak
b/soak
index 83645db6ed01df718a99c3a58407ec378513911f..7953608d988f44f89b812cfdc02c0ae11af2a7cd 100755
(executable)
--- a/
soak
+++ b/
soak
@@
-225,6
+225,7
@@
def choices():
OPTS = Options()
ST = State(OPTS)
KID = SUB.Popen(OPTS.testprog, stdin = SUB.PIPE, stdout = SUB.PIPE)
OPTS = Options()
ST = State(OPTS)
KID = SUB.Popen(OPTS.testprog, stdin = SUB.PIPE, stdout = SUB.PIPE)
+SYNC = OPTS.sync
def fail(msg):
SYS.stderr.write("%s: FAILED: %s\n" % (PROG, msg))
def fail(msg):
SYS.stderr.write("%s: FAILED: %s\n" % (PROG, msg))
@@
-238,17
+239,17
@@
def fail(msg):
def put(msg, echo = True):
try: KID.stdin.write(msg.encode()); KID.stdin.flush()
except OSError as err: fail("write failed: %s" % err)
def put(msg, echo = True):
try: KID.stdin.write(msg.encode()); KID.stdin.flush()
except OSError as err: fail("write failed: %s" % err)
- if
OPTS.sync
and echo: SYS.stdout.write("$ " + msg); SYS.stdout.flush()
+ if
SYNC
and echo: SYS.stdout.write("$ " + msg); SYS.stdout.flush()
def get(echo = True):
try: line = KID.stdout.readline().decode()
except OSError as err: fail("read failed: %s" % err)
if line == "": fail("unexpected end of file")
def get(echo = True):
try: line = KID.stdout.readline().decode()
except OSError as err: fail("read failed: %s" % err)
if line == "": fail("unexpected end of file")
- if
OPTS.sync
and echo: SYS.stdout.write(line)
+ if
SYNC
and echo: SYS.stdout.write(line)
if line[-1] == "\n": return line[:-1]
else: return line
def dump_tree():
if line[-1] == "\n": return line[:-1]
else: return line
def dump_tree():
- if
OPTS.sync
:
+ if
SYNC
:
put("D\n:;;END DUMP\n", echo = False)
while True:
line = get(echo = False)
put("D\n:;;END DUMP\n", echo = False)
while True:
line = get(echo = False)
@@
-279,7
+280,7
@@
dump_tree()
STEP = CSTEP = 0
ch = choices()
while OPTS.nsteps is None or STEP < OPTS.nsteps:
STEP = CSTEP = 0
ch = choices()
while OPTS.nsteps is None or STEP < OPTS.nsteps:
- if
OPTS.sync
: SYS.stdout.write("\n;; step %d\n" % CSTEP)
+ if
SYNC
: SYS.stdout.write("\n;; step %d\n" % CSTEP)
op = ch.choose(ST.rand)
if op == "addrm1":
op = ch.choose(ST.rand)
if op == "addrm1":
@@
-393,11
+394,11
@@
while OPTS.nsteps is None or STEP < OPTS.nsteps:
STEP += 1; CSTEP += 1
dump_tree()
STEP += 1; CSTEP += 1
dump_tree()
- if
OPTS.sync
or CSTEP == OPTS.ckpt_steps: check_tree()
+ if
SYNC
or CSTEP == OPTS.ckpt_steps: check_tree()
if CSTEP == OPTS.ckpt_steps:
snapshot()
ST.write_ckpt()
if CSTEP == OPTS.ckpt_steps:
snapshot()
ST.write_ckpt()
- CSTEP = 0;
OPTS.sync
= False
+ CSTEP = 0;
SYNC
= False
while True:
check_tree()
while True:
check_tree()