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 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")
- 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 OPTS.sync:
+ if SYNC:
put("D\n:;;END DUMP\n", echo = False)
while True:
line = get(echo = False)
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":
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()
- CSTEP = 0; OPTS.sync = False
+ CSTEP = 0; SYNC = False
while True:
check_tree()