Example #1
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)
Example #2
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
Example #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)
Example #4
0
def test_basic_cmpa():
    cmpa = CMPA('lpc55xx')
    with pytest.raises(AssertionError):
        cmpa.export()
Example #5
0
def test_supported_devices():
    cfpa_devices = CFPA.devices()
    cmpa_devices = CMPA.devices()

    assert sorted(cmpa_devices) == sorted(cfpa_devices)
Example #6
0
def test_cli_devices_global():
    runner = CliRunner()
    result = runner.invoke(spsdk_apps.main, ['pfr', 'devices'])
    for device in CMPA.devices():
        assert device in result.stdout
Example #7
0
def test_cli_devices():
    runner = CliRunner()
    result = runner.invoke(cli.main, ['devices'])
    for device in CMPA.devices():
        assert device in result.stdout
Example #8
0
def test_generate_html():
    data = _get_data_for_html(CMPA('lpc55xx'))
    html = _generate_html('CMPA', data)
    assert "<h1>CMPA</h1>" in html
Example #9
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