Пример #1
0
    def test_bmc_setup(self):
        # pre conditions not satisfied
        # model must be loaded
        with self.assertRaises(NuSMVNeedBooleanModelError):
            bmcglob.bmc_setup()

        # vars need to be encoded
        load(self.model())
        with self.assertRaises(NuSMVNeedBooleanModelError):
            bmcglob.bmc_setup()

        # boolean model must be compiled out of the sexp
        flatten_hierarchy()
        with self.assertRaises(NuSMVNeedBooleanModelError):
            bmcglob.bmc_setup()

        # hierarchy must be flattened (actually, this is a requirement for the
        # boolean model too)
        encode_variables()
        with self.assertRaises(NuSMVNeedBooleanModelError):
            bmcglob.bmc_setup()

        # may not be called 2 times
        build_boolean_model()
        with self.assertRaises(NuSMVBmcAlreadyInitializedError):
            bmcglob.bmc_setup()
            bmcglob.bmc_setup()

        # even if the force flag is on (that's COI related)
        with self.assertRaises(NuSMVBmcAlreadyInitializedError):
            bmcglob.bmc_setup(force=True)

        bmcglob.bmc_exit()
Пример #2
0
    def test_bmc_setup(self):
        # pre conditions not satisfied
        # model must be loaded
        with self.assertRaises(NuSMVNeedBooleanModelError):
            bmcglob.bmc_setup()
        
        # vars need to be encoded
        load(self.model())
        with self.assertRaises(NuSMVNeedBooleanModelError):
            bmcglob.bmc_setup()
        
        # boolean model must be compiled out of the sexp
        flatten_hierarchy()
        with self.assertRaises(NuSMVNeedBooleanModelError):
            bmcglob.bmc_setup()

        # hierarchy must be flattened (actually, this is a requirement for the
        # boolean model too)
        encode_variables()
        with self.assertRaises(NuSMVNeedBooleanModelError):
            bmcglob.bmc_setup()
        
        # may not be called 2 times
        build_boolean_model()
        with self.assertRaises(NuSMVBmcAlreadyInitializedError):
            bmcglob.bmc_setup()
            bmcglob.bmc_setup()
            
        # even if the force flag is on (that's COI related)
        with self.assertRaises(NuSMVBmcAlreadyInitializedError):
            bmcglob.bmc_setup(force=True)
            
        bmcglob.bmc_exit()
Пример #3
0
    def test_sets_the_global_values(self):
        glob.flatten_hierarchy()
        glob.encode_variables()

        with self.assertRaises(NuSMVNeedBooleanModelError):
            glob.master_bool_sexp_fsm()

        glob.build_boolean_model()
        self.assertIsNotNone(glob.master_bool_sexp_fsm())
Пример #4
0
 def test_master_be_fsm(self):
     load(self.model())
     flatten_hierarchy()
     encode_variables()
     build_boolean_model()
     bmcglob.bmc_setup()
     # may not provoke C assert failures
     bmcglob.build_master_be_fsm()
     self.assertEqual(bmcglob.master_be_fsm(), BeFsm.global_master_instance())
     bmcglob.bmc_exit()
Пример #5
0
 def test_build_master_be_fsm(self):
     load(self.model())
     flatten_hierarchy()
     encode_variables()
     build_boolean_model()
     bmcglob.bmc_setup()
     # may not provoke C assert failures
     bmcglob.build_master_be_fsm()
     
     bmcglob.bmc_exit()
Пример #6
0
    def test_build_master_be_fsm(self):
        load(self.model())
        flatten_hierarchy()
        encode_variables()
        build_boolean_model()
        bmcglob.bmc_setup()
        # may not provoke C assert failures
        bmcglob.build_master_be_fsm()

        bmcglob.bmc_exit()
Пример #7
0
 def setUp(self):
     init_nusmv()
     glob.load(self.model())
     glob.flatten_hierarchy()
     glob.encode_variables()  # does it for BDD
     self.go_bmc()
     
     pd = _prop.PropPkg_get_prop_database()
     fsm= _prop.PropDb_master_get_be_fsm(pd)
     self._TEST = _be.BeFsm_get_fairness_list(fsm)
Пример #8
0
    def setUp(self):
        init_nusmv()
        glob.load(self.model())
        glob.flatten_hierarchy()
        glob.encode_variables()  # does it for BDD
        self.go_bmc()

        pd = _prop.PropPkg_get_prop_database()
        fsm = _prop.PropDb_master_get_be_fsm(pd)
        self._TEST = _be.BeFsm_get_fairness_list(fsm)
Пример #9
0
 def test_master_be_fsm(self):
     load(self.model())
     flatten_hierarchy()
     encode_variables()
     build_boolean_model()
     bmcglob.bmc_setup()
     # may not provoke C assert failures
     bmcglob.build_master_be_fsm()
     self.assertEqual(bmcglob.master_be_fsm(),
                      BeFsm.global_master_instance())
     bmcglob.bmc_exit()
Пример #10
0
 def test_variables_ordering(self):
     glob.load_from_file("tests/pynusmv/models/constraints.smv")
     glob.flatten_hierarchy()
     glob.encode_variables(variables_ordering=
                           "tests/pynusmv/models/constraints.ord")
     glob.compute_model()
     fsm = glob.prop_database().master.bddFsm
     
     with open("tests/pynusmv/models/constraints.ord", "r") as f:
         order = f.read().split("\n")
         self.assertListEqual(order,
                              list(fsm.bddEnc.get_variables_ordering()))
Пример #11
0
    def test_variables_ordering(self):
        glob.load_from_file("tests/pynusmv/models/constraints.smv")
        glob.flatten_hierarchy()
        glob.encode_variables(
            variables_ordering="tests/pynusmv/models/constraints.ord")
        glob.compute_model()
        fsm = glob.prop_database().master.bddFsm

        with open("tests/pynusmv/models/constraints.ord", "r") as f:
            order = f.read().split("\n")
            self.assertListEqual(order,
                                 list(fsm.bddEnc.get_variables_ordering()))
Пример #12
0
 def test_no_model(self):
     with self.assertRaises(NuSMVNeedFlatModelError):
         glob.build_model()
     glob.load_from_file("tests/pynusmv/models/counters.smv")
     with self.assertRaises(NuSMVNeedFlatModelError):
         glob.build_model()
     glob.flatten_hierarchy()
     with self.assertRaises(NuSMVNeedFlatModelError):
         glob.build_model()
     glob.build_flat_model()
     with self.assertRaises(NuSMVNeedVariablesEncodedError):
         glob.build_model()
     glob.encode_variables()
     glob.build_model()
     with self.assertRaises(NuSMVModelAlreadyBuiltError):
         glob.build_model()
Пример #13
0
def go_bmc(force=False):
    """
    Performs all the necessary steps to use loaded model and be able to perform
    bmc related operations on it.
    
    :raises NuSMVNoReadModelError: if no module was read (:func:`pynusmv.glob.load`) 
      before this method was called. 
    """
    cmp = glob.global_compile_cmps() 
    if not _compile.cmp_struct_get_read_model(cmp):
        raise NuSMVNoReadModelError("No read model.")

    # Check cmps and perform what is needed
    if not _compile.cmp_struct_get_flatten_hrc(cmp):
        glob.flatten_hierarchy()
    if not _compile.cmp_struct_get_encode_variables(cmp):
        glob.encode_variables()
    if not _compile.cmp_struct_get_build_bool_model(cmp):
        glob.build_boolean_model(force=force)
    if not _compile.cmp_struct_get_bmc_setup(cmp):
        bmc_setup(force=force)
Пример #14
0
def go_bmc(force=False):
    """
    Performs all the necessary steps to use loaded model and be able to perform
    bmc related operations on it.
    
    :raises NuSMVNoReadModelError: if no module was read (:see:`glob.load`) 
      before this method was called. 
    """
    cmp = glob.global_compile_cmps() 
    if not _compile.cmp_struct_get_read_model(cmp):
        raise NuSMVNoReadModelError("No read model.")

    # Check cmps and perform what is needed
    if not _compile.cmp_struct_get_flatten_hrc(cmp):
        glob.flatten_hierarchy()
    if not _compile.cmp_struct_get_encode_variables(cmp):
        glob.encode_variables()
    if not _compile.cmp_struct_get_build_bool_model(cmp):
        glob.build_boolean_model(force=force)
    if not _compile.cmp_struct_get_bmc_setup(cmp):
        bmc_setup(force=force)
Пример #15
0
 def test_model(self):
     glob.load_from_file("tests/pynusmv/models/counters.smv")
     glob.flatten_hierarchy()
     glob.encode_variables()
     glob.build_flat_model()
     glob.build_model()
Пример #16
0
 def test_no_encoding_after_parsing(self):
     glob.load_from_file("tests/pynusmv/models/counters.smv")
     with self.assertRaises(NuSMVNeedFlatHierarchyError):
         glob.encode_variables()
Пример #17
0
 def test_no_encoding(self):
     with self.assertRaises(NuSMVNeedFlatHierarchyError):
         glob.encode_variables()
Пример #18
0
 def test_model(self):
     glob.load_from_file("tests/pynusmv/models/counters.smv")
     glob.flatten_hierarchy()
     glob.encode_variables()
     glob.build_flat_model()
     glob.build_model()
Пример #19
0
 def test_already_encoded(self):
     glob.load_from_file("tests/pynusmv/models/counters.smv")
     glob.flatten_hierarchy()
     glob.encode_variables()
     with self.assertRaises(NuSMVModelAlreadyEncodedError):
         glob.encode_variables()
Пример #20
0
 def test_must_not_be_already_built_unless_force_flag(self):
     glob.flatten_hierarchy()
     glob.encode_variables()
     glob.build_boolean_model()
     glob.build_boolean_model(force=True)
Пример #21
0
 def test_no_encoding(self):
     with self.assertRaises(NuSMVNeedFlatHierarchyError):
         glob.encode_variables()
Пример #22
0
 def test_no_encoding_after_parsing(self):
     glob.load_from_file("tests/pynusmv/models/counters.smv")
     with self.assertRaises(NuSMVNeedFlatHierarchyError):
         glob.encode_variables()
Пример #23
0
 def test_must_not_be_already_built(self):
     glob.flatten_hierarchy()
     glob.encode_variables()
     glob.build_boolean_model()
     with self.assertRaises(NuSMVModelAlreadyBuiltError):
         glob.build_boolean_model()