コード例 #1
0
ファイル: test_sdf.py プロジェクト: sglumac/sdf4sim
def test_invalid_connection1():
    """ check for invalid tokens """
    sdf_graph = get_two_unit_graph()
    agents, buffers = sdf_graph
    buffers.append(
        sdf.Buffer(src=sdf.Src('nonexisting_actor', 'nonexisting_port'),
                   dst=sdf.Dst('two', 'u'),
                   tokens=deque([4])))
    assert not sdf.validate_graph(sdf_graph)
コード例 #2
0
ファイル: test_sdf.py プロジェクト: sglumac/sdf4sim
def test_invalid_connection2():
    """Actors do not match the connections!"""
    sdf_graph = get_two_unit_graph()
    actors, buffers = sdf_graph
    buffers[0] = sdf.Buffer(src=sdf.Src('nonexisting_actor1',
                                        'nonexisting_port1'),
                            dst=sdf.Dst('nonexisting_actor2',
                                        'nonexisting_port2'),
                            tokens=buffers[0].tokens)
    assert not sdf.validate_graph(sdf_graph)
コード例 #3
0
ファイル: test_sdf.py プロジェクト: sglumac/sdf4sim
def test_valid_graph():
    """ as the name says """
    sdf_graph = get_two_unit_graph()
    assert sdf.validate_graph(sdf_graph)
    topology_matrix = sdf.calculate_topology_matrix(sdf_graph)
    assert sdf.is_consistent(topology_matrix)
    repetitions = sdf.repetition_vector(topology_matrix)
    assert repetitions[0] == 1
    assert repetitions[1] == 1
    sequence = sdf.calculate_schedule(sdf_graph)
    assert sequence == ['two', 'one']

    iterations = 10

    def terminate(sdf_graph: sdf.Graph, results: sdf.Results) -> bool:
        nonlocal iterations
        iterations -= 1
        return iterations <= 0

    results = sdf.sequential_run(sdf_graph, terminate)
    for tokens in results.tokens.values():
        assert len(tokens) > 5
        for token in tokens:
            assert token == pytest.approx(13)
コード例 #4
0
ファイル: test_sdf.py プロジェクト: sglumac/sdf4sim
def test_deadlock():
    """ as the name says """
    sdf_graph = get_two_unit_graph()
    _, buffers = sdf_graph
    buffers[0].tokens.popleft()
    assert not sdf.validate_graph(sdf_graph)
コード例 #5
0
ファイル: test_sdf.py プロジェクト: sglumac/sdf4sim
def test_inconsistent_graph():
    """ as the name says """
    sdf_graph = get_two_unit_graph()
    agents, _ = sdf_graph
    agents['one'] = GainRate(1)
    assert not sdf.validate_graph(sdf_graph)
コード例 #6
0
def test_control_cs_valid():
    """Check if conversion to cs gives a valid graph"""
    sdf_graph = cs.convert_to_sdf(example.control.gauss_seidel(1., 5., 1.))
    assert sdf.validate_graph(sdf_graph)