def my_funky_invariant_check(simulation): from sts.invariant_checker import InvariantChecker result = InvariantChecker.check_loops(simulation) if result: return result result = InvariantChecker.python_check_connectivity(simulation) if not result: print "Connectivity established - bailing out" import sys sys.exit(0) return []
def fast_die_invariant_check(simulation): from sts.invariant_checker import InvariantChecker result = InvariantChecker.check_loops(simulation) if result: return result result = InvariantChecker.python_check_connectivity(simulation) if not result: print "Connectivity established - bailing out" import sys sys.exit(0) return []
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 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))