Exemple #1
0
def test_cmd_load():
    """Test address, len, memory_id, info value, size after append, export and parsing of CmdLoad command."""
    cmd = CmdLoad(address=100, data=bytes(range(10)), memory_id=1)
    assert cmd.address == 100
    assert cmd.length == 10
    assert cmd.memory_id == 1
    assert cmd.info()

    data = cmd.export()
    assert len(data) == 48

    cmd_parsed = CmdLoad.parse(data=data)
    assert cmd == cmd_parsed
Exemple #2
0
def test_cmd_load():
    """Test address, len, memory_id, info value, size after append, export and parsing of CmdLoad command."""
    cmd = CmdLoad(address=100, length=0, memory_id=0)
    assert cmd.address == 100
    assert cmd.length == 0
    assert cmd.memory_id == 0
    assert cmd.info()

    data = cmd.export()
    assert len(data) % 16 == 0

    cmd_parsed = CmdLoad.parse(data=data)
    assert cmd.address == cmd_parsed.address
    assert cmd.length == cmd_parsed.length
    assert cmd.memory_id == cmd_parsed.memory_id

    assert 0x00000000 <= cmd.address <= 0xFFFFFFFF
    assert 0x00000000 <= cmd.length <= 0xFFFFFFFF
Exemple #3
0
def test_parse_invalid_cmd_load_cmd_tag():
    """CmdLoad tag validity test."""
    cmd = CmdLoad(address=0, data=bytes(4), memory_id=0)
    cmd.cmd_tag = EnumCmdTag.CALL
    data = cmd.export()
    with pytest.raises(SPSDKError):
        CmdLoad.parse(data=data)