Exemple #1
0
def test_capi2_get_ttptttg():
    from fusesoc.core import Core

    core = Core(os.path.join(cores_dir, "generate.core"))

    flags = {'is_toplevel' : True}
    expected = [
        {'name'      : 'testgenerate_without_params',
         'generator' : 'generator1',
         'pos'        : 'append',
         'config'    : {}},
        {'name'      : 'testgenerate_with_params',
         'generator' : 'generator1',
         'pos'       : 'append',
         'config'    : {'param1' : 'a param',
                        'param2' : ['list', 'of', 'stuff']}},
    ]
    assert expected == core.get_ttptttg(flags)

    flags['target'] = 'nogenerate'
    assert [] == core.get_ttptttg(flags)

    flags['target'] = 'invalid_generate'
    with pytest.raises(SyntaxError) as excinfo:
        core.get_ttptttg(flags)
    assert "Generator instance 'idontexist', requested by target 'invalid_generate', was not found" in str(excinfo.value)

    flags['target'] = 'invalid_target'
    assert [] == core.get_ttptttg(flags)
def test_capi2_get_ttptttg():
    from fusesoc.core import Core

    core = Core(os.path.join(cores_dir, "generate", "generate.core"))

    flags = {"is_toplevel": True}
    expected = [
        {
            "name": "testgenerate_without_params",
            "generator": "generator1",
            "pos": "append",
            "config": {},
        },
        {
            "name": "testgenerate_with_params",
            "generator": "generator1",
            "pos": "append",
            "config": {"param1": "a param", "param2": ["list", "of", "stuff"]},
        },
    ]
    assert expected == core.get_ttptttg(flags)

    flags["target"] = "nogenerate"
    assert [] == core.get_ttptttg(flags)

    flags["target"] = "invalid_generate"
    with pytest.raises(SyntaxError) as excinfo:
        core.get_ttptttg(flags)
    assert (
        "Generator instance 'idontexist', requested by target 'invalid_generate', was not found"
        in str(excinfo.value)
    )

    flags["target"] = "invalid_target"
    assert [] == core.get_ttptttg(flags)