def main(dirs, options=None): for dirname in dirs: debug.log('reprocessing %s' % dirname) debug.verbose('parse %s/description.txt for test' % dirname) testname = test = None f = open(os.path.join(dirname, 'description.txt'), 'r') for line in f: m = re.match(r'test:\s+(.*)', line) if m: testname = m.group(1) break f.close() if not testname: debug.error('unable to parse description for %s, skipped' % dirname) continue debug.verbose('locate test "%s"' % testname) for t in tests.all_tests: if t.name.lower() == testname.lower(): test = t(options) if not test: debug.error('unknown test "%s" in %s, skipped' % (testname, dirname)) continue debug.verbose('reprocess results') h = harness.Harness() h.process_results(test, dirname)
def __init__(self, options): self._harness = harness.Harness() self._options = options
def run(self, trace): ''' Takes the L{Trace} and runs it in a L{Harness}, monitoring for crashes. This function spawns a new process using a L{Harness} object connected to this process by a pair of pipes. A debugger is attached to the L{Harness} process and handlers are attached to monitor for crashes and hangs (defined as the harness not completing by a certain time limit). The given L{Trace} is then sent over the pipe to the L{Harness} for replay, and the L{Harness} is watched for completion. If a crash or hang occurs, relevant information is collected and dumped to a file for inspection and possible reproduction. Each L{Trace} is identified as a certain run (the iteration) of a certain batch (the trace number), and this identification is reflected by the file name if a dump occurs. The scheme is based off the common fuzzing pattern of taking one "base" trace and fuzzing the values in it to create multiple fuzzed versions - so a batch is all traces that were generated by fuzzing the same base trace. @param trace: The trace to run and monitor @type trace: L{Trace} object ''' self.log.info("Monitor is running. Creating pipe and harness") self.last_trace = trace # Spawn a new test harness and connect to it (inpipe, outpipe) = multiprocessing.Pipe() h = harness.Harness(self.cfg, (inpipe, outpipe)) self.log.info("Running the harness") h.start() self.inpipe = inpipe if self.log.isEnabledFor(logging.DEBUG) : tracestr = trace.toString() self.log.debug("Trace %d run %d contents:\n\n%s\n", \ self.tracenum, self.iter, tracestr) # Send the trace self.log.info("Sending trace %d run %d", self.tracenum, self.iter) try : outpipe.send(trace) except : msg = "Error sending trace over pipe to harness" self.log.exception(msg) raise Exception(msg) # Attach the debugger to the waiting harness pid = h.pid self.log.debug("Stopping and attaching to harness, pid %d", pid) dbg = pydbg.pydbg() dbg.attach(pid) dbg.set_callback(defines.EXCEPTION_ACCESS_VIOLATION, self.crash_handler) dbg.set_callback(defines.USER_CALLBACK_DEBUG_EVENT, self.time_check) # Send continue signal self.log.debug("Sending continuation flag to harness") outpipe.send(True) # Prepare our timeout object self.log.debug("Setting timeout to %d seconds", self.limit) self.timed_out = False t = threading.Timer(self.limit, self.timeout) # Release the test harness self.log.debug("Releasing the harness") t.start() dbg.run() t.cancel() self.log.info("Harness exited, cleaning up") outpipe.close() self.inpipe.close() self.iter += 1 self.log.info("Monitor exiting")
try: logger = LogHandler(thismodule, console_level, log_level, True, bds, logf) except IOError as e: print e print 'Error creating the log handlers. Exiting...' sys.exit(1) thisuser = getpass.getuser() csmii = csmi.CsmiInterface(logger, csmidir, usecsm, mconfig['allocation_id'], runid, thisuser) logger.set_csmi(csmii) if mgmt_mode: import harness tharness = harness.Harness(mconfig, tconfig, logger, runid, logd, csmii, thisuser, args.target) else: import base_harness tharness = base_harness.BaseHarness(mconfig, tconfig, logger, runid, logd, csmii, thisuser, args.target) # now we can start logging! logger.ras( 'hcdiag.fwk.started', 'version=%s, os=%s, osversion=%s, location_name=%s' % (__version__, os.uname()[0], os.uname()[2], thishost)) logger.info('Using configuration file {0}.'.format(mprop)) if not mgmt_mode: logger.info('XCAT fanout ignored, allocation disabled.') logger.info('Using tests configuration file {0}.'.format( mconfig['testproperties'])) logger.info(