Exemplo n.º 1
0
def load_state(monitor, efg_file):
    cache_file = '%s.cache' % efg_file
    if os.path.exists(cache_file):
        try:
            # reload cache file
            log.info('loading cache file from %s' % cache_file)
            return parser.load(cache_file)
        except Exception, e:
            log.exception(e)
Exemplo n.º 2
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
Exemplo n.º 3
0
def main(monitors, cfg):
    efg_file = cfg.get('general', 'efg_file')

    state, lock = load_state(monitors[0], efg_file), threading.Lock()

    config_loc = cfg.get('general', 'configuration')
    ignored_patterns = []
    try:
        ignored_patterns = parser.load(config_loc)
    except Exception, e:
        # Some error happened when reading the configuration file
        log.exception(e)
Exemplo n.º 4
0
    def run(self):
        try:
            while True:
                interrupt_point()

                with self._lock:
                    testfile = self._testcases.pop()
                    left = len(self._testcases)
                log.info('running %s on monitor %s (%d left)' %
                         (testfile, self._monitor.name, left))
                test = parser.load(testfile)

                name = os.path.split(testfile)[1]
                logfile = os.path.join(
                    self._out_dir, os.path.splitext(name)[0]) + '.log'
                stdout = StringIO.StringIO()
                with self._monitor.open(logfile, stdout):
                    interrupt_point()

                    # Perform each action in the test
                    try:
                        for event in test:
                            event.perform(self._monitor)
                            time.sleep(self._steptime)
                            interrupt_point()

                        # Take final snapshot of the state and save it
                        snapshot = self._monitor.take_snapshot()
                        parser.dump(snapshot, os.path.join(
                                self._out_dir, name))
                    except Exception, e:
                        log.exception(e)
                        self._results.error(
                            testfile,
                            message = str(e),
                            stdout = stdout.getvalue())
                    else:
                        # Validate with oracles
                        for oracle in self._oracles:
                            reason = oracle.validate(
                                self._monitor, snapshot, testfile, test)
                            if reason:
                                log.error('test %s failed (oracle %s)' %
                                          (testfile, type(oracle)))
                                self._results.failure(
                                    testfile,
                                    message = '%s\nreason: %s' % (type(oracle), reason),
                                    stdout = stdout.getvalue())
                                break
                        else:
                            self._results.success(
                                testfile, stdout = stdout.getvalue())
Exemplo n.º 5
0
def main(argv = None):
    cfg = guitarlib.initialize(argv)

    # Load in the efg file
    efg_file = cfg.get('general', 'efg_file')
    log.info('loading efg file %s' % efg_file)
    gr = parser.load(efg_file)

    try:
        pkg, class_ = cfg.get('testgenerator', 'plugin').rsplit('.', 1)
        testgenerator = getattr(__import__(pkg, fromlist=[class_]), class_)()
    except (ImportError, AttributeError), e:
        log.exception(e)
        return 1