示例#1
0
def test_parse_invalid_cmd_copy_cmd_tag():
    """CmdCopy tag validity test."""
    cmd = CmdCopy(address=100, length=0, destination_address=0, memory_id_from=0, memory_id_to=0)
    cmd.cmd_tag = EnumCmdTag.CALL
    data = cmd.export()
    with pytest.raises(SPSDKError):
        CmdLoadCmac.parse(data=data)
示例#2
0
def test_cmd_loadcmac():
    """Test address, length, memory_id, info value, size after export and parsing of CmdLoadCmac command."""
    cmd = CmdLoadCmac(address=100, data=bytes(range(10)), memory_id=0)
    assert cmd.address == 100
    assert cmd.length == 10
    assert cmd.memory_id == 0
    assert cmd.info()

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

    cmd_parsed = CmdLoadCmac.parse(data=data)
    assert cmd == cmd_parsed
示例#3
0
def test_cmd_loadcmac():
    """Test address, length, memory_id, info value, size after export and parsing of CmdLoadCmac command."""
    cmd = CmdLoadCmac(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 = CmdLoadCmac.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
示例#4
0
def test_parse_invalid_cmd_loadcmac_cmd_tag():
    """CmdLoadCmac tag validity test."""
    cmd = CmdLoadCmac(address=0, data=bytes(10), memory_id=0)
    cmd.cmd_tag = EnumCmdTag.CALL
    data = cmd.export()
    with pytest.raises(SPSDKError):
        CmdLoadCmac.parse(data=data)