def __init__(self, simulation_cfg, superlog_path_or_dag, create_event_scheduler=None, **kwargs): ControlFlow.__init__(self, simulation_cfg) self.sync_callback = ReplaySyncCallback(self.get_interpolated_time) if type(superlog_path_or_dag) == str: superlog_path = superlog_path_or_dag # The dag is codefied as a list, where each element has # a list of its dependents self.dag = EventDag(superlog_parser.parse_path(superlog_path)) else: self.dag = superlog_path_or_dag # compute interpolate to time to be just before first event self.compute_interpolated_time(self.dag.events[0]) if create_event_scheduler: self.create_event_scheduler = create_event_scheduler else: self.create_event_scheduler = \ lambda simulation: EventScheduler(simulation, **{ k: v for k,v in kwargs.items() if k in EventScheduler.kwargs })
def __init__(self, simulation_cfg, superlog_path_or_dag, invariant_check=InvariantChecker.check_correspondence, transform_dag=None, end_wait_seconds=0.5, mcs_trace_path=None, extra_log=None, dump_runtime_stats=True, **kwargs): super(MCSFinder, self).__init__(simulation_cfg) self.sync_callback = None self._log = logging.getLogger("mcs_finder") if type(superlog_path_or_dag) == str: superlog_path = superlog_path_or_dag # The dag is codefied as a list, where each element has # a list of its dependents self.dag = EventDag(superlog_parser.parse_path(superlog_path)) else: self.dag = superlog_path_or_dag self.invariant_check = invariant_check self.transform_dag = transform_dag self.mcs_trace_path = mcs_trace_path self._extra_log = extra_log self._runtime_stats = None self.kwargs = kwargs self.end_wait_seconds = end_wait_seconds if dump_runtime_stats: self._runtime_stats = {}
def __init__(self, simulation_cfg, superlog_path_or_dag, create_event_scheduler=None, print_buffers=True, wait_on_deterministic_values=False, fail_to_interactive=False, **kwargs): ControlFlow.__init__(self, simulation_cfg) if wait_on_deterministic_values: self.sync_callback = ReplaySyncCallback() else: self.sync_callback = ReplaySyncCallback(self.get_interpolated_time) if type(superlog_path_or_dag) == str: superlog_path = superlog_path_or_dag # The dag is codefied as a list, where each element has # a list of its dependents self.dag = EventDag(superlog_parser.parse_path(superlog_path)) else: self.dag = superlog_path_or_dag self.dp_checker = DataplaneChecker(self.dag) self.print_buffers = print_buffers # compute interpolate to time to be just before first event self.compute_interpolated_time(self.dag.events[0]) self.unexpected_state_changes = [] self.early_state_changes = [] self.event_scheduler_stats = None self.fail_to_interactive = fail_to_interactive if create_event_scheduler: self.create_event_scheduler = create_event_scheduler else: self.create_event_scheduler = \ lambda simulation: EventScheduler(simulation, **{ k: v for k,v in kwargs.items() if k in EventScheduler.kwargs })
def test_basic(self): name = None try: self.open_simple_superlog() events = superlog_parser.parse_path(self.tmpfile) self.assertEqual(2, len(events)) self.assertEqual(LinkFailure,type(events[0])) self.assertEqual(LinkRecovery,type(events[1])) finally: if name is not None: os.unlink(name)
def test_basic(self): name = None try: self.open_simple_superlog() events = superlog_parser.parse_path(self.tmpfile) self.assertEqual(2, len(events)) self.assertEqual(LinkFailure, type(events[0])) self.assertEqual(LinkRecovery, type(events[1])) finally: if name is not None: os.unlink(name)
def _track_new_internal_events(self, simulation, replayer): ''' Pre: simulation must have been run through a replay''' # We always check against internal events that were buffered at the end of # the original run (don't want to overcount) path = self.superlog_path + ".unacked" if not os.path.exists(path): log.warn("unacked internal events file from original run does not exists") return prev_buffered_receives = [ e.pending_receive for e in EventDag(superlog_parser.parse_path(path)).events ] new_message_receipts = [] for p in simulation.god_scheduler.pending_receives(): if p not in prev_buffered_receives: new_message_receipts.append(repr(p)) else: prev_buffered_receives.remove(p) new_state_changes = replayer.unexpected_state_changes new_internal_events = new_state_changes + new_message_receipts self._runtime_stats.record_new_internal_events(new_internal_events) self._runtime_stats.record_early_internal_events(replayer.early_state_changes) self._runtime_stats.record_timed_out_events(dict(replayer.event_scheduler_stats.event2timeouts)) self._runtime_stats.record_matched_events(dict(replayer.event_scheduler_stats.event2matched))
def __init__(self, simulation_cfg, superlog_path_or_dag, invariant_check_name=None, transform_dag=None, end_wait_seconds=0.5, mcs_trace_path=None, extra_log=None, runtime_stats_file=None, wait_on_deterministic_values=False, no_violation_verification_runs=1, optimized_filtering=False, **kwargs): super(MCSFinder, self).__init__(simulation_cfg) self.sync_callback = None self._log = logging.getLogger("mcs_finder") if invariant_check_name is None: raise ValueError("Must specify invariant check") if invariant_check_name not in name_to_invariant_check: raise ValueError('''Unknown invariant check %s.\n''' '''Invariant check name must be defined in config.invariant_checks''', invariant_check_name) self.invariant_check = name_to_invariant_check[invariant_check_name] if type(superlog_path_or_dag) == str: self.superlog_path = superlog_path_or_dag # The dag is codefied as a list, where each element has # a list of its dependents self.dag = EventDag(superlog_parser.parse_path(self.superlog_path)) else: self.dag = superlog_path_or_dag self.transform_dag = transform_dag self.mcs_trace_path = mcs_trace_path self._extra_log = extra_log self.kwargs = kwargs self.end_wait_seconds = end_wait_seconds self.wait_on_deterministic_values = wait_on_deterministic_values # `no' means "number" self.no_violation_verification_runs = no_violation_verification_runs self._runtime_stats = RuntimeStats(runtime_stats_file) self.optimized_filtering = optimized_filtering