def createRandomStateTest(): (name, isDocker) = getBaseCmd("testeth") if isDocker: cmd = ['docker', "run", "--rm", name] else: cmd = [name] cmd.extend(["-t", "GeneralStateTests", "--", "--createRandomTest"]) outp = "".join(VMUtils.finishProc(VMUtils.startProc(cmd))) #Validate that it's json try: test = json.loads(outp) test['randomStatetest']['_info'] = { 'sourceHash': "0000000000000000000000000000000000000000000000000000000000001337", "comment": "x" } return test except: print("Exception generating test") print('-' * 60) traceback.print_exc(file=sys.stdout) print('-' * 60) return None
def finishProc(name, process, canonicalizer): outp = VMUtils.finishProc(process) logging.info("End of %s trace, processing..." % name) canon_steps = canonicalizer(outp) canon_text = [toText(step) for step in canon_steps] logging.info( "Done processing %s trace (%d steps), returning in canon format" % (name, len(canon_text))) return canon_text
def finishProc(name, processInfo, canonicalizer, fulltrace_filename=None): """ Ends the process, returns the canonical trace and also writes the full process output to a file, along with the command used to start the process""" process = processInfo['proc'] extraTime = False if name == "py": extraTime = True outp = VMUtils.finishProc(processInfo['proc'], extraTime, processInfo['output']) if fulltrace_filename is not None: #logging.info("Writing %s full trace to %s" % (name, fulltrace_filename)) with open(fulltrace_filename, "w+") as f: f.write("# command\n") f.write("# %s\n\n" % processInfo['cmd']) f.write("\n".join(outp)) canon_text = [VMUtils.toText(step) for step in canonicalizer(outp)] return canon_text