Ejemplo n.º 1
0
def test_config_cmpa():

    cmpa = CMPA('lpc55xx')
    config = cmpa.generate_config()
    config2 = cmpa.generate_config(exclude_computed=False)

    assert config != config2

    cmpa2 = CMPA('lpc55xx', user_config=config2)
    out = cmpa2.parse(bytes(512), exclude_computed=False)

    assert out == config2
Ejemplo n.º 2
0
def test_generate_cmpa(data_dir):
    config = json.loads(read_file(data_dir, 'cmpa_96mhz.json'))
    binary = read_file(data_dir, 'CMPA_96MHz.bin', 'rb')
    key = load_pem_private_key(read_file(data_dir,
                                         'selfsign_privatekey_rsa2048.pem',
                                         'rb'),
                               password=None,
                               backend=default_backend())

    cmpa = CMPA('lpc55xx', keys=[key.public_key()], user_config=config)
    assert binary == cmpa.export(add_hash=False, compute_inverses=True)
Ejemplo n.º 3
0
def test_address():
    cmpa = CMPA('lpc55xx')
    assert '0x9_E400' == cmpa.get_address(remove_underscore=False)
    assert '0x9E400' == cmpa.get_address(remove_underscore=True)
Ejemplo n.º 4
0
def test_basic_cmpa():
    cmpa = CMPA('lpc55xx')
    with pytest.raises(AssertionError):
        cmpa.export()
Ejemplo n.º 5
0
def test_generate_html():
    data = _get_data_for_html(CMPA('lpc55xx'))
    html = _generate_html('CMPA', data)
    assert "<h1>CMPA</h1>" in html
Ejemplo n.º 6
0
def test_get_data_for_html(data_dir):
    data = _get_data_for_html(CMPA('lpc55xx'))
    schema = json.loads(read_file(data_dir, 'html_data.schema'))
    # in case of a failure, an exception is thrown
    jsonschema.validate(data, schema)
    assert True