Ejemplo n.º 1
0
def full_analysis_worker(fts_file, out_file, queue, event):
    atexit.unregister(fm.final_delete)
    dead = []
    false = []
    hidden = []
    with open(fts_file, 'r') as fts_source:
        fts = load_dot(fts_source)
    with open(out_file, 'w') as sys.stdout:
        event.set()
        z3_analyse_full(fts)
        fts.report()
        sys.stdout.flush()
    for transition in fts._set_dead:
        dead.append({
            'src': transition._in._id,
            'dst': transition._out._id,
            'label': str(transition._label),
            'constraint': str(transition._constraint)
        })
    for transition in fts._set_false_optional:
        false.append({
            'src': transition._in._id,
            'dst': transition._out._id,
            'label': str(transition._label),
            'constraint': str(transition._constraint)
        })
    for state in fts._set_hidden_deadlock:
        hidden.append(state._id)
    queue.put(
        {'ambiguities': {
            'dead': dead,
            'false': false,
            'hidden': hidden
        }})
Ejemplo n.º 2
0
def main(source, target):
    with open(source, 'r') as fts_source:
        fts = analyser.load_dot(fts_source)
    fts_source.close()
    analyser.z3_analyse_full(fts)
    dis = Disambiguator.from_file(source)
    dis.remove_transitions(fts._set_dead)
    dis.set_true_list(fts._set_false_optional)
    dis.solve_hidden_deadlocks(fts._set_hidden_deadlock)
    with open(target, 'w') as out:
        out.write(dis.get_graph())
Ejemplo n.º 3
0
 def vendingnew(self, tmp_path):
     import src.internals.analyser as analyser
     from src.internals.disambiguator import Disambiguator
     with open(os.path.join('tests', 'dot', 'vendingnew.dot'),
               'r') as fts_source:
         fts = analyser.load_dot(fts_source)
     fts_source.close()
     analyser.z3_analyse_full(fts)
     dis = Disambiguator.from_file(
         os.path.join('tests', 'dot', 'vendingnew.dot'))
     dis.remove_transitions(fts._set_dead)
     dis.set_true_list(fts._set_false_optional)
     dis.solve_hidden_deadlocks(fts._set_hidden_deadlock)
     with open(os.path.join(tmp_path, "fixed-vendingnew.dot"), 'w') as out:
         out.write(dis.get_graph())
     return os.path.join(tmp_path, 'fixed-vendingnew.dot')
Ejemplo n.º 4
0
 def fixed_dot(self, tmp_path):
     import src.internals.analyser as analyser
     from src.internals.disambiguator import Disambiguator
     dots = []
     dot = os.listdir(os.path.join('tests', 'dot'))
     for source in dot:
         with open(os.path.join('tests', 'dot', source), 'r') as fts_source:
             fts = analyser.load_dot(fts_source)
         fts_source.close()
         analyser.z3_analyse_full(fts)
         dis = Disambiguator.from_file(os.path.join('tests', 'dot', source))
         dis.remove_transitions(fts._set_dead)
         dis.set_true_list(fts._set_false_optional)
         dis.solve_hidden_deadlocks(fts._set_hidden_deadlock)
         dots.append(os.path.join(tmp_path, "fixed-" + source))
         with open(os.path.join(tmp_path, "fixed-" + source), 'w') as out:
             out.write(dis.get_graph())
     return dots
def full_analysis_worker(fts_file, out_file, queue):
    dead = [] 
    false = [] 
    hidden = []
    fts_source = open(fts_file, 'r')
    sys.stdout = open(out_file, 'w')
    fts = load_dot(fts_source)
    z3_analyse_full(fts)
    for transition in fts._set_dead:
        dead.append({'src':transition._in._id, 'dst':transition._out._id,
            'label':str(transition._label), 'constraint':str(transition._constraint)})
    for transition in fts._set_false_optional:
        false.append({'src':transition._in._id, 'dst':transition._out._id,
            'label':str(transition._label), 'constraint':str(transition._constraint)})
    for state in fts._set_hidden_deadlock:
        hidden.append(state._id)
    queue.put({'ambiguities':{'dead': dead, 'false': false, 'hidden': hidden}})
    fts.report()
    sys.stdout.close()
    fts_source.close()
Ejemplo n.º 6
0
 def test_disambiguate(self, tmp_path):
     import os
     import src.internals.analyser as analyser
     dot = os.listdir(os.path.join('tests', 'dot'))
     for source in dot:
         dead = []
         false = []
         hidden = []
         with open(os.path.join('tests', 'dot', source), 'r') as fts_source:
             fts = analyser.load_dot(fts_source)
         fts_source.close()
         analyser.z3_analyse_full(fts)
         dis = Disambiguator.from_file(os.path.join('tests', 'dot', source))
         dis.remove_transitions(fts._set_dead)
         dis.set_true_list(fts._set_false_optional)
         dis.solve_hidden_deadlocks(fts._set_hidden_deadlock)
         with open(os.path.join(tmp_path, "fixed-" + source), 'w') as out:
             out.write(dis.get_graph())
         with open(os.path.join(tmp_path, "fixed-" + source), 'r') as fixed:
             fts = analyser.load_dot(fixed)
         analyser.z3_analyse_full(fts)
         assert not (fts._set_dead or fts._set_false_optional
                     or fts._set_hidden_deadlock)