def invariant_check(self, kind): if kind == "omega" or kind == "o": self._log_input_event( CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_correspondence") ) result = InvariantChecker.check_correspondence(self.simulation) message = "Controllers with miscorrepondence: " elif kind == "connectivity" or kind == "c": self._log_input_event( CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_connectivity") ) result = InvariantChecker.check_connectivity(self.simulation) message = "Disconnected host pairs: " elif kind == "python_connectivity" or kind == "pc": self._log_input_event( CheckInvariants( round=self.logical_time, invariant_check_name="InvariantChecker.python_check_connectivity" ) ) result = InvariantChecker.python_check_connectivity(self.simulation) message = "Disconnected host pairs: " elif kind == "loops" or kind == "lo": self._log_input_event( CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_loops") ) result = InvariantChecker.python_check_loops(self.simulation) message = "Loops: " elif kind == "liveness" or kind == "li": self._log_input_event( CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_liveness") ) result = InvariantChecker.check_liveness(self.simulation) message = "Crashed controllers: " elif kind == "blackholes" or kind == "bl": self._log_input_event( CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_blackholes") ) result = InvariantChecker.python_check_blackholes(self.simulation) message = "Blackholes: " else: log.warn("Unknown invariant kind...") return self.simulation.violation_tracker.track(result, self.logical_time) persistent_violations = self.simulation.violation_tracker.persistent_violations transient_violations = list(set(result) - set(persistent_violations)) msg.interactive(message + str(result)) if transient_violations != []: self._log_input_event(InvariantViolation(transient_violations)) if persistent_violations != []: msg.fail("Persistent violations detected!: %s" % str(persistent_violations)) self._log_input_event(InvariantViolation(persistent_violations, persistent=True))
def check_everything(simulation): # Check liveness once at the beginning # If there are no more live controllers, stop violations = [] down_controllers = InvariantChecker.check_liveness(simulation) violations = down_controllers # Check other invariants without checking liveness checks = [InvariantChecker.check_loops, InvariantChecker.python_check_blackholes] # InvariantChecker.check_connectivity ] for check in checks: violations += check(simulation, check_liveness_first=False) violations = list(set(violations)) return violations
def check_everything(simulation): # Check liveness once at the beginning # If there are no more live controllers, stop violations = [] down_controllers = InvariantChecker.check_liveness(simulation) violations = down_controllers # Check other invariants without checking liveness checks = [ InvariantChecker.check_loops, InvariantChecker.python_check_blackholes ] #InvariantChecker.check_connectivity ] for check in checks: violations += check(simulation, check_liveness_first=False) violations = list(set(violations)) return violations
def invariant_check(self, kind): if kind == "omega" or kind == "o": self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_correspondence")) result = InvariantChecker.check_correspondence(self.simulation) message = "Controllers with miscorrepondence: " elif kind == "connectivity" or kind == "c": self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_connectivity")) result = InvariantChecker.check_connectivity(self.simulation) message = "Disconnected host pairs: " elif kind == "python_connectivity" or kind == "pc": self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.python_check_connectivity")) result = InvariantChecker.python_check_connectivity(self.simulation) message = "Disconnected host pairs: " elif kind == "loops" or kind == "lo": self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_loops")) result = InvariantChecker.python_check_loops(self.simulation) message = "Loops: " elif kind == "liveness" or kind == "li": self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_liveness")) result = InvariantChecker.check_liveness(self.simulation) message = "Crashed controllers: " elif kind == "blackholes" or kind == "bl": self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_blackholes")) result = InvariantChecker.python_check_blackholes(self.simulation) message = "Blackholes: " else: log.warn("Unknown invariant kind...") return self.simulation.violation_tracker.track(result, self.logical_time) persistent_violations = self.simulation.violation_tracker.persistent_violations transient_violations = list(set(result) - set(persistent_violations)) msg.interactive(message + str(result)) if transient_violations != []: self._log_input_event(InvariantViolation(transient_violations)) if persistent_violations != []: msg.fail("Persistent violations detected!: %s" % str(persistent_violations)) self._log_input_event(InvariantViolation(persistent_violations, persistent=True))