Пример #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 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()
Пример #8
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)
Пример #9
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)
Пример #10
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)
Пример #11
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()
Пример #12
0
 def test_vars_must_be_encoded(self):
     glob.flatten_hierarchy()
     with self.assertRaises(NuSMVNeedVariablesEncodedError):
         glob.build_boolean_model()