Example #1
0
    def test_NEXT_check_ltl(self):
        with tests.Configure(self, __file__, "/example.smv"):
            status, l, trace = check.check_ltl(parseLTL("()() a"), 5)
            self.assertEqual('Ok', status)
            self.assertEqual(5, l)
            self.assertIsNone(trace)

            status, l, trace = check.check_ltl(parseLTL("() a"), 5)
            self.assertEqual('Violation', status)
            self.assertEqual(1, l)
            self.assertIsNotNone(trace)
Example #2
0
    def test_EVENTUALLY_check_ltl(self):
        with tests.Configure(self, __file__, "/example.smv"):
            status, l, trace = check.check_ltl(parseLTL("<>(a <=> !b)"), 5)
            self.assertEqual('Ok', status)
            self.assertEqual(5, l)
            self.assertIsNone(trace)

            status, l, trace = check.check_ltl(parseLTL("<>(a & b)"), 5)
            self.assertEqual('Violation', status)
            self.assertEqual(2, l)
            self.assertIsNotNone(trace)
Example #3
0
    def test_check_ltl_invariants(self):
        """
        This tests the use of the invariants flag when performing the check.
        """
        with tests.Configure(self, __file__, "/dummy_with_invar.smv"):
            formula = parseLTL("[] v")

            # invariants enforced
            status, _, trace = check.check_ltl(formula, 10, no_invar=True)
            self.assertEqual("Violation", status)
            self.assertEqual(0, len(trace))

            # invariants enforced
            status, _, trace = check.check_ltl(formula, 10, no_invar=False)
            self.assertEqual("Ok", status)
            self.assertIsNone(trace)
Example #4
0
    def test_UNTIL_check_ltl(self):
        with tests.Configure(self, __file__, "/never_b.smv"):
            status, l, trace = check.check_ltl(parseLTL("b U a"), 5)
            self.assertEqual('Ok', status)
            self.assertEqual(5, l)
            self.assertIsNone(trace)

            status, l, trace = check.check_ltl(parseLTL("a U b"), 5)
            self.assertEqual('Violation', status)
            self.assertEqual(1, l)
            self.assertIsNotNone(trace)

            status, l, trace = check.check_ltl(parseLTL("b W !a"), 5)
            self.assertEqual('Violation', status)
            self.assertEqual(0, l)
            self.assertIsNotNone(trace)
def check(formula, args):
    try:
        parsed_fml          = parseLTL(formula.strip())
        status,length,trace = check_ltl(parsed_fml, args.bound, args.no_fairness, args.no_invariants, args.dry_run)
        if status != 'Ok':
            print("-- {} for length {}".format(status, length))
            print(trace)
    except Exception as e:
        print("The specification contains a syntax error")
        print(e)
Example #6
0
    def test_check_ltl_arithmetics(self):
        """
        This tests the use of the invariants flag when performing the check.
        """
        with tests.Configure(self, __file__, "/numbers.smv"):
            formula = parseLTL("[] a < 7")

            status, _, trace = check.check_ltl(formula, 10, no_invar=False)
            self.assertEqual("Ok", status)
            self.assertIsNone(trace)
Example #7
0
    def test_check_ltl_fairness(self):
        """
        This tests validates two features::
            1. the use of a non-variable symbol in the formula
            2. the use of the fairness flag when performing the check.
        """
        with tests.Configure(self, __file__, "/philo.smv"):
            # no one must wait forever:
            # -> this is entailed by fair execution but not in general
            formula = parseLTL("(!<>[](p1.waiting)) & (!<>[](p2.waiting))")

            # unfair
            status, _, trace = check.check_ltl(formula, 10, no_fairness=True)
            self.assertEqual("Violation", status)
            self.assertEqual(3, len(trace))

            # fair exec only
            status, _, trace = check.check_ltl(formula, 10, no_fairness=False)
            self.assertEqual("Ok", status)
            self.assertIsNone(trace)