Beispiel #1
0
 def proxy(name):
     """Tries to convert a host into a proxy"""
     try:
         return guitarlib.ApplicationPrx.checkedCast(
             self.communicator().stringToProxy(
                 'Application:%s' % potential_hosts[name]))
     except Exception, e:
         log.warn('monitor %s is invalid' % name)
         log.exception(e)
         return None
Beispiel #2
0
def main(monitors, cfg):
    # ant_glob for testcases
    testpattern = cfg.get('replayer', 'testcase')
    testcases = util.ant_glob(testpattern)

    log.info('collected %d test cases' % len(testcases))
    log.debug(`testcases`)

    assert len(monitors) > 0, 'No monitors available'

    # Load oracles
    oracles = []
    oracle_names = cfg.get('replayer', 'oracles')
    if len(oracle_names.strip()) != 0:
        for pkg, class_ in (s.strip().rsplit('.', 1)
                                for s in oracle_names.split(',')):
            try:
                oracle = getattr(__import__(pkg,fromlist=[class_]), class_)()
                oracle.add_options(cfg)
                oracles.append(oracle)
                log.info('loaded oracle %r' % oracle)
            except (ImportError, AttributeError):
                log.warn('could not load oracle %s.%s' % (pkg, class_))

    lock = threading.Lock()
    steptime = float(cfg.get('general', 'steptime'))
    out_dir = cfg.get('replayer', 'state_dir')
    if not os.path.exists(out_dir):
        log.debug('creating folder %s' % os.path.abspath(out_dir))
        os.makedirs(out_dir)
    results = Results()
    replayers = [ Replayer(monitor = m,
                           config = cfg,
                           oracles = oracles,
                           testcases = testcases,
                           lock = lock,
                           steptime = steptime,
                           out_dir = out_dir,
                           results = results)
                  for m in monitors ]

    for replayer in replayers:
        replayer.start()

    while any(( replayer.is_alive() for replayer in replayers )):
        time.sleep(steptime)

    results_file = cfg.get('replayer', 'results')
    with open(results_file, 'w') as f:
        f.write( results.xmlreport().toprettyxml(indent = '  ') )

    return 0 if not interrupt else 1
Beispiel #3
0
    def _parse_preprocess(self, line):
        m = re_preprocess.match(line)

        if m:
            if m.group(1) == 'import':
                # save current section
                current_section = self._name

                # load contents of the file
                with guitarlib.util.open(m.group(2)) as f:
                    self._loads(f.read())

                # reset current section
                self._name = current_section
            elif m.group(1) == 'include':
                # load the section directly
                with guitarlib.util.open(m.group(2)) as f:
                    self._loads(f.read())
            else:
                log.warn('unrecognized preprocessor directive "%s"' %
                         m.group(1))
        return m is not None