コード例 #1
0
ファイル: test_functions.py プロジェクト: mstarecek/spsdk
def test_value_range():
    cmd = CmdErase(address=1000, length=1000)
    cmd.address = 1000
    cmd.length = 1000

    assert 0x00000000 <= cmd.address <= 0xFFFFFFFF
    assert 0x00000000 <= cmd.length <= 0xFFFFFFFF
コード例 #2
0
def test_parse_invalid_cmd_loadkeyblob_cmd_tag():
    """CmdLoadKeyBlob tag validity test."""
    cmd = CmdLoadKeyBlob(offset=100,  key_wrap_id=CmdLoadKeyBlob.KeyWraps.NXP_CUST_KEK_EXT_SK, data=bytes(10))
    cmd.cmd_tag = EnumCmdTag.CALL
    data = cmd.export()
    with pytest.raises(ValueError):
        CmdErase.parse(data=data)
コード例 #3
0
def test_cmd_erase():
    """Test address, length, memory_id, info value, size after export and parsing of CmdErase command."""
    cmd = CmdErase(address=100, length=0xFF, memory_id=10)
    assert cmd.address == 100
    assert cmd.length == 0xFF
    assert cmd.memory_id == 10
    assert cmd.info()

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

    cmd_parsed = CmdErase.parse(data=data)
    assert cmd == cmd_parsed
コード例 #4
0
def test_parse_invalid_cmd_erase_cmd_tag():
    """CmdErase tag validity test."""
    cmd = CmdErase(address=0, length=0, memory_id=0)
    cmd.cmd_tag = EnumCmdTag.CALL
    data = cmd.export()
    with pytest.raises(SPSDKError):
        CmdErase.parse(data=data)
コード例 #5
0
ファイル: test_functions.py プロジェクト: mstarecek/spsdk
def test_implementation_function_parse():
    cmd = CmdErase(address=100, length=0)
    data = cmd.export()
    with pytest.raises(NotImplementedError):
        MainCmd.parse(data=data)
コード例 #6
0
ファイル: test_functions.py プロジェクト: mstarecek/spsdk
def test_implementation_function_export():
    cmd = CmdErase(address=100, length=0)
    with pytest.raises(NotImplementedError):
        MainCmd.export(cmd)
コード例 #7
0
ファイル: test_functions.py プロジェクト: mstarecek/spsdk
def test_implementation_function_str():
    cmd = CmdErase(address=100, length=0)
    with pytest.raises(NotImplementedError):
        BaseCmd.info(cmd)
        MainCmd.__str__(cmd)
コード例 #8
0
def test_parse_cmd_erase_invalid_padding():
    cmd = CmdErase(address=100, length=0xFF)
    data = b"U\xaa\xaaUd\x00\x00\x00\xff\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
    with pytest.raises(SPSDKError, match="Invalid padding"):
        cmd.parse(data)